var RequestId = getControlValue('request','request_id'); var params = {}; params.request_id = RequestId; var response = executePerform('start_work_flow',RequestId); if(response.message != null && response.message != '') { alert(response.message); }
Cheers!
Thanks @Shneor Cheshin,
We had tried the parameter approach yesterday but ran into issues with that. When I paste in your code and run it in the client scripts screen we get the error that a ; is missing though on looking at your code it deos not seem to be missing.
Regards,
Barry
@MWAMAITTEAM
My bad, I did not replace it with params
var RequestId = getControlValue('request','request_id'); var params = {}; params.request_id = RequestId; var response = executePerform('start_work_flow',params); if(response.message != null && response.message != '') { alert(response.message); }
Cheers!
Hi @Shneor Cheshin - good point. I didnt notice that, however still the same issue after that change.
This time I again have the Unexpected Token error.
Regards,
Barry
@MWAMAITTEAM
Did you try running this in Webclient? Or is it just the debug screen?
If not, please try a real scenario from the Webclient.
Cheers!
Hi Shenor,
I have been on annual leave. Back today so will try this week and let you know!
Regards,
Barry
Hi Shenor,
This time I again have the Unexpected Token error.
Regards,
Barry
Hi @MWAMAITTEAM ,
Looks like the issue is coming from the “response.message” syntax here as the mpm does not return a message element in a successful response (it returns a taskRow). It should have a general condition check with (response != null && response !=’ ’)
Hence suggesting you to alter your code as below.
var RequestId = getControlValue('request','request_id'); var params = {}; params.request_id = RequestId; var response = executePerform('start_work_flow',params); if(response != null && response != '') { if (response.$type == 'ErrorResponse') { alert(response.message); //will throw a message element only if an error was thrown during the mpm execution } else { alert("A new task with task id "+response.task.task_id+" has been created!"); // will generate a taskRow response if the mpm is successful (you can use any valid task field here for the response). } }
Also, suggesting you not to test this on the smart client’s client script debugger as it’s likely to throw syntax exceptions. Make sure to associate your script on the button click event using the UI designer and then directly test it on the web client.
Hi Samlk,
Your version of the script works and I have associated it with the click event on the button and tested successfully.