BeasScript can be defined to be executed for post command.
Call this with:
post [entityname]
The JSON object, which you define in the body is available for Beas script with JSON object.
For example: <j.jsonproperty>
Note:
In BeasScript this present a ue_json-object
if Script start with #jbs the sytem deliver a jbs-object
Additional variables that are available:
Variable |
Description |
---|---|
result |
Write the text, which you want send to the client. JBScript: You can return every variable / object type |
code |
Return the code (the default is 200 = ok). If not 200 or return with -1, then the system return error with messagetext as error text |
messagetext |
Define the error code and error message, if the code is not 200 |
j |
The Body as Json. Note: in BeasScript property name is: b |
[CompanyWorkOrderActivity/post]
// Add script to AddActivity
[/CompanyWorkOrderActivity/post]
Example: Create Activity
Body of the post command:
{
"DocEntry":[workorder docentry],
"ActivityInfo":[infoString]
}
Script must start with #jbs. Comments before not allowed
[CompanyWorkOrderActivity/post]
#jbs
// check, if correct properties available
try {
let ll_docentry=j.DocEntry;
let ls_info=j.ActivityInfo;
}
catch (re) {
setvar result='"error":"DocEntry or ReceiptDocEntry not defined in the body"';
return -1;}
let b=bsl.Workorder(ll_docentry)?$select=DocNum,CardCode;
if (b.Cardcode) == "" {
setvar result='"error":"Work order not found or empty cardcode"';
return 1;
}
let di=new ue_api_sbo;
di.getbusinessobject("ocontacts");
di.CardCode=b.CardCode;
di.DocType=59;
di.DocEntry=j.docentry;
di.details="Receipt item for "+b.DocNum+" "+ls_info
di.add();
result="Document added";
[/CompanyWorkOrderActivity/post]
[CompanyWorkOrderActivity/post]
instance bsl b
b.Workorder(<DocEntry>)?$select=DocNum,CardCode
if <b.Cardcode> = "" then
setvar=result={"error":200,"errormessage":"Work order <j.DocEntry> not found or without cardcode"}
return success
end if
declare=di=ue_api_sbo
di=getbusinessobject=ocontacts
di=CardCode=<b.CardCode>
di=DocType=59
di=details=Receipt item for <b.DocNum>
di=add
destroy=di
[/CompanyWorkOrderActivity/post]