How to launch a Process with JQuery
Include https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js in the footer of your webform
then execute this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | function trigger_process(process_url, input_params) { //process_url : STRING : eg: https://live.runmyprocess.com/live/621199258/process/59619?P_mode=TEST // input_params : JSON : input params of the process eg: {"firstname":"John","lastname":"Smith"} var xml_input_params = "<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xml:base='https://live.runmyprocess.com/'><entry><category term='initial' /><content type='xml'>" + JSON.stringify(input_params) + "</content></entry></feed>"; $.ajax({ type : "POST", url : process_url, data : xml_input_params, cache : false, async : false, dataType : "json", beforeSend : function (xhr) { xhr.setRequestHeader('Content-Type', 'application/xml+atom'); }, success : parse_result, error : popup_ko }); } function parse_result(data, textStatus, jqXHR) { alert(data.feed.id); // will popup the process instance id } function popup_ko(jqXHR, textStatus, errorThrown) { alert(textStatus + " : " + errorThrown); } trigger_process("https://live.runmyprocess.com/live/621199258/process/59619?P_mode=TEST", { "firstname" : "John", "lastname" : "Smith" }); |
Notes : This will work if you trigger the script from a RunMyProcess webinterface (web interface and process are on the same domain).
If you'd like to use an authentication different from the one of the webinterface, do add:
1 2 3 | var rmp_login = your_rmp_login; var rmp_password = your_rmp_password; var auth='Basic '+Base64.encode (rmp_login+':'+rmp_password); |
and add this in beforeSend parameter:
1 | xhr.setRequestHeader('Authorization', auth); |
NB : If you want to trigger the script from an html page not hosted on RunMyProcess, you'll have to configure settings in your browser: firefox -internet explorer
Please give details of the problem