The development interface fmscript has several tools for the code compilation, the simulation, the debug, the preview (data of requests, tables, JSON, etc.), the presentation of several system variables (Variables Users, CRM , Invoices, Sales, etc.), as well as several data access variables of the device that consumes your service. We will immediately present some essential elements composing it.
NB: For all script to develop in FMScript, the Result variable must always be declared first.
VAR Result : String ;
//----Add your varibles here
//----Code your service here
these are the invoice variables available only in production Mode. you can use them inside an event on your code.
For examples:
here is a sample of code of how to create a bill on Further Market from a business account.
var Result : String;
var Url : string;
var Bill : string;
var GotoUssdCode : string;
var Quitus : string;
var Value : string;
var Infos : string;
GotoUssdCode := 'Your_code';
Url := 'http://api.furthermarket.com/FM/BUSINESS/BILL?MyAccountID=YOUR_ACCOUNTID&Password=PASSWORD_OF_YOUR_ACCOUNT';
Infos := 'Frais medicaux;Frais de preinscription;Frais universitaires;Frais Concours';
//---New Input format: Input(1):Visible:Password:Default:Length:Align:PickList:SendCaption:Color:TextColor:Disabled:ReadOnly:DigitsOnly
Result := Input('Hello', 'Name,Reference,Quitus-Number,Date,PhoneCode,Amount (XAF),PhoneNumber,Type', 500,
'1::::left::Save:::0:0:0' +','+
'1::::left:2018/2019;2017/2018;2016/2017;2015/2016:Save:::0:0:0' +','+
'1::::left::Save:::0:0:1' +','+
'1::::left:DateType:Save:::0:0:0' +','+
'1::::left:237:Save:::0:0:0' +','+
'1::::left::Save:::0:0:1' +','+
'1::::left::Save:::0:0:1'+','+
'1::::left:'+Infos+':Save:::0:0:0'
);
//---Return--------------------------------------------------------------------------------------------------------
IF Result = '00' THEN
(
Exit;
);
//---API Build Post request----------------------------------------------------------------------------------
ArrayStrToArray('Data', Result, '*');
Bill := '';
Bill := Bill + 'CustomerName=' + ArrayGetValue('Data', 0) +'&';
Bill := Bill + 'BillReference=' + ArrayGetValue('Data', 1) +'&';
Bill := Bill + 'BillNumber=' + ArrayGetValue('Data', 2) +'&';
Bill := Bill + 'BillDate=' + ArrayGetValue('Data', 3) +'&';
Bill := Bill + 'ExpiryDate=' + ArrayGetValue('Data', 3) +'&';
Bill := Bill + 'CountryPhoneCode=' + ArrayGetValue('Data', 4) +'&';
Bill := Bill + 'Amount=' + ArrayGetValue('Data', 5) +'&';
Bill := Bill + 'MinimumPayment=' + ArrayGetValue('Data', 5) +'&';
Bill := Bill + 'ExpiryPenaltyAmount=' + '0' +'&';
Bill := Bill + 'Currency=' + 'XAF' +'&';
Bill := Bill + 'Informations=' + ArrayGetValue('Data', 7) +'&';
Bill := Bill + 'PhoneNumber=' + ArrayGetValue('Data', 6) +'&';
Bill := Bill + 'Published=' + '1' +'&';
Bill := Bill + 'OverRideDuplicate=' + '1' +'&';
Bill := Bill + 'BillNumberCustomName=' +'&';
Bill := Bill + 'BillReferenceCustomName=' +'&';
Bill := Bill + 'Reserved1=' +'&';
Bill := Bill + 'Reserved2=' +'&';
Bill := Bill + 'Reserved3=' +'&';
Bill := Bill + 'Reserved4=' +'&';
Bill := Bill + 'Reserved5=' +'&';
Bill := Bill + 'Reserved6=' +'&';
Bill := Bill + 'Reserved7=' + '';
//ShowMessage(Bill);
Quitus := ArrayGetValue('Data', 2);
Result := HTTP_POST(Url, Bill, '', '', 0); // Headers=ContentType:CharSet:Accept
IF Copy(Result, 1,1) = '1' THEN
(
GotoUssdCode := '*141*4*'+Quitus+'#';
Exit;
);
ShowMessage(Result);
Exit;
It allows you to have informations about accounts that run your Applet. When a user in session consumes your script, you have at your disposal a set of its parameters that can allow you to anticipate from conception to certain future treatment. Imagine a single script that can display based on the language of the logged-in user. that said, 2 users connected simultaneously on your applet can have different renderings.
For examples:
Examples:
VAR Result : String;
Result := 'Unknown Language.';
IF USER_Language = 'EN' THEN
(
Result := 'I am Anglophone.';
);
IF USER_Language = 'FR' THEN
(
Result := 'Je suis Francophone.';
);
Exit;
the example below helps you visualize the contents of any user variable.
Var Result: string;
MenuItemAdd('MyMenu', 'Users variables', 'Users variables', '', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', '', '', '', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'user name ('+USER_Name+')', 'user name ('+USER_Name+')', '8', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'phone number ('+ USER_PhoneNumber+')', 'phone number ('+ USER_PhoneNumber+')', '8', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'My accountId ('+ USER_AccountID+')', 'My accountId ('+ USER_AccountID+')', '8', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'user root value ('+ USER_RootUser+')', 'user root value ('+ USER_RootUser+')', '8', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', '', '', '', '', '', '', '', '', '', '');
Result := InputMenu('MyMenu', 6000, '', '');
Exit ;
Here is the result.
The CRM varibles are indications representing the fields of the CRM table exposed to the developers to store simple data communicating with the FM scripts. for a CRM_CustomerCode Variable the field of the database is CustomerCode. it is the same for the other fields with the exception of the variable CRM_PhoneNumber so the field of the database is Phone_Number. Learn more about CRM Manipulation features.
VAR Result : String;
VAR Result2 : String;
VAR FileID : String;
VAR ValueStr: String;
VAR Count,i : Integer;
FileID := '8';
Result := CRM_Select('Query1',FileID, 'Name,CustomerCode,EMail','', '',1);
Count := Query_RecordsCount('Query1');
Result := MenuItemAdd('MyMenu','Select', '', '', '', '', '', '', '', '');
Query_First('Query1');
FOR i:=0 TO PRED(Count) DO
(
ValueStr := Query_FieldValue('Query1', 'Name');
Result := MenuItemAdd('MyMenu',IntToStr(i+1)+'. '+ValueStr, ValueStr, IntToStr(i+1) , '', '', '', '', '', '', '');
Query_Next('Query1');
);
Result := InputMenu('MyMenu', 60000, '', '');
Exit;
As you see above, on CRM_Select function, you may notice that we request just 3 fields that are Name , CustomerCode and EMail
this section stores detailed information about the device that accesses your service. that it is the IP, the geographical coordinates, etc .; some very basics variables are: ExternalFunctionParameters
For examples:
Examples:
VAR Result : String;
Result := ExternalFunction('MY_SCRIPT_ID','My_PARAMS')
Exit;
ExternalFunctionParameters = My_PARAMS
let's print some device variables in one demo.
Var Result: string;
MenuItemAdd('MyMenu', 'System and devices variables', 'System and devices variables', '', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', '', '', '', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'Device model ('+Device_Model+')', 'Device model ('+Device_Model+')', '1', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'Device version ('+ Device_Version+')', 'Device version ('+Device_Version+')', '2', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'Terminal version ('+ TerminalVersion+')', 'Terminal version ('+TerminalVersion+')', '3', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'session entry code ('+ SessionEntryCode+')', 'session entry code ('+SessionEntryCode+')', '4', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'screen width ('+ScreenWidth+')', 'screen width ('+ ScreenWidth+')', '5', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', 'screen height ('+ScreenHeight+')', 'screen height ('+ScreenHeight+')', '6', '', '', '', '', '', '', '');
MenuItemAdd('MyMenu', '', '', '', '', '', '', '', '', '', '');
Result := InputMenu('MyMenu', 6000, '', '');
Here is the result.