×

Please give details of the problem

Skip to content

How to launch a Process with JQuery

then execute this code:

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:

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:

xhr.setRequestHeader('Authorization', auth);

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