Hi I am doing some testing with Scripts. I have a Script which opens a Word Document.
function OpenWord(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var objEditor = new ActiveXObject("Word.Application");
objEditor.Visible = true;
//objEditor.Documents.Open("C:\\Temp1\\test2.docx");
var doc = objEditor.Documents.Add ();
var sel = objEditor.Selection;
sel.TypeText("This is Text inputed to word");
}
I want to send Customer details like Name, Address, Email, Phone etc. to the word document. This is my first attempt at Scripts. Would I need create another script to get the customer information from Sambapos and then call that script from the above script.
I know there is probably easier ways to do this but I want to learn about scripts. Could someone give an example of how I would pass customer details to the script. When I run the above script Word opens and has the Text “This is Text inputed to word”
api.Entity(Test Customer).Data(Email).Get();
The best overloaded method match for 'Samba.Services.Implementations.ExpressionModule.Accessors.ApiService.ApiServiceAccessor.Entity(string)' has some invalid arguments
I was reading @JTRTech Update rooms Scritpt and he was doing it like below but I get Customers is undefined.
api.Entity(Customers).Data(Test Customer).Get(Email);
'Customers' is undefined
Put the values in quotes so they are strings, or define varables to contain the strings and use the variables:
api.Entity('Test Customer').Data('Email').Get();
If you don’t do that, then it is a literal, a variable, in which case it would be undefined, since you have not defined the content of the variable named Customers, Email, etc. And Test Customer cannot be used as a variable name, since it has a space in it.
I hope you can grasp that concept, if not, you are in over your head and won’t get far.
var entityType = 'Customers';
var entityName = 'Test Customer';
var customFieldName = 'Email';
api.Entity(entityName).Data(customFieldName).Get();
I understand what you are doing here and have it working on the Script page when I test. What I do not understand is -
I have a customer ticket open. I have a button called export. How do I get the selected customer from a ticket when I press export. Can I pass the selected customer details to the script?