After October updates. The H5 script started failing for one of our customer.
I have a similiar use case for one more customer.
But really want to know if any workaround is there.
My script is just calling an ION workflow with POST method.
Please see my below typescript. and Error I get in console.
Also raised a case on Infor support portal. But don't know when it will be solved
class CRS620E_suppApprovalWorkflow {
private controller: IInstanceController;
private log: IScriptLog;
private unsubscribeRequesting;
private newButton = null;
private jsonBody = "";
private supplierNumber: string;
private currentCompany: string;
private User: string;
private currentPanel: string;
private date: Date = new Date();
private supplierGroup:string='';
private oldStatus;
constructor(args: IScriptArgs) {
this.controller = args.controller;
this.log = args.log;
}
/**
* Script initialization function.
*/
public static Init(args: IScriptArgs): void {
new CRS620E_suppApprovalWorkflow(args).run();
}
private async run() {
this.supplierNumber = ScriptUtil.GetFieldValue("WWSUNO");
this.currentCompany = ScriptUtil.GetUserContext('CurrentCompany');
this.User = ScriptUtil.GetUserContext('USID');
this.currentPanel = this.controller.GetPanelName();;
this.oldStatus = ScriptUtil.GetFieldValue('WISTAT');
console.log('In run method'+this.currentPanel+this.oldStatus);
if (this.currentPanel == "CRA620E0" && this.controller.GetMode() == "5") {
let getbasicdata = await this.CRS620_GetBasicData(this.currentCompany, this.supplierNumber);
if (getbasicdata != null) {
this.supplierNumber = getbasicdata[0].SUNO;
console.log('In panel e');
}
this.newButton = this.attachButton();
ScriptUtil.AddEventHandler(this.newButton, "click", (event) => {
if (this.oldStatus != '10') {
this.controller.ShowMessage('Supplier approval could not be submitted [status = ' + this.oldStatus + ']');
} else {
if (ScriptUtil.GetFieldValue('WISTAT') != '10') {
this.controller.ShowMessage('Supplier approval could not be submitted [status = ' + ScriptUtil.GetFieldValue('WISTAT') + ']');
} else {
this.addEvent();
}
}
});
}
}
private addEvent() {
console.log("inputSupplier"+this.supplierNumber)
//this.jsonBody = '{"workflowName": "M3_SupplierApproval_Workflow_V1","instanceName": "' + this.date + '","inputVariables": [{"name": "SUNO","dataType": "STRING","value": "' + this.supplierNumber + '"},{"name": "User","dataType": "STRING","value": "' + this.User + '"},{"name": "CONO","dataType": "STRING","value": "' + this.currentCompany + '"},{"name": "SupplierGroup","dataType": "STRING","value": "' + this.supplierGroup + '"}],"inputStructures": []}';
//this.jsonBody = '{"workflowName": "M3_SupplierApproval_Workflow_V0","instanceName": "' + this.date + '","inputVariables": [{"name": "supp","dataType": "STRING","value": "' + this.supplierNumber + '"}],"inputStructures": []}';
//let headers:Object = {Accept: "application/json"};
var request: IonApiRequest = {
url: '/IONSERVICES/process/application/v1/workflow/start',
method: "POST",
record: {
"workflowName":"M3_SupplierApproval_Workflow_V0",
instanceName: this.date,
"inputVariables": [{
"name": "supp",
"dataType": "STRING",
"value":"' + this.supplierNumber + '"}]
//logicalId: "lid://infor.m3.m3"
},
//data: this.jsonBody,
headers: { "accept": 'application/json', "content-type": "application/json" }
};
IonApiService.Current.execute(request).then(function (response) {
console.log("Responseworkflow", response);
});
this.controller.ShowMessage("Supplier approval workflow submitted by " + this.User);
}
private attachButton() {
console.log("In add button method")
let button: ButtonElement = new ButtonElement();
button.Name = "Run";
button.Value = "Send for approval";
let positionElement: PositionElement = new PositionElement();
positionElement.Left = 30;
positionElement.Top = 3;
button.Position = positionElement;
const newButton = this.controller.GetContentElement().AddElement(button);
return newButton;
}
private CRS620_GetBasicData(company, supplier) {
return new Promise(function (resolve) {
const request: IonApiRequest = {
url: '/M3/m3api-rest/v2/execute/CRS620MI/GetBasicData/',
method: 'GET',
record: { CONO: company, SUNO: supplier }
};
IonApiService.Current.execute(request).then((response: IonApiResponse) => {
console.log('responseGetBasicData' + response);
resolve(response.data.results[0].records);
});
});
}
}