Issue with using g_form in UI Action

irfanshaik
Tera Contributor

Hello,

 

I have created a rest message and the Preview REST Message script usage looks like this - 

 

 

try { 
 var r = new sn_ws.RESTMessageV2('x_775122_enviro_tr.Get Tree Name', 'Post');
 r.setStringParameterNoEscape('clientName', 'client2');
 r.setStringParameterNoEscape('jobId', 'job2');

//override authentication profile 
//authentication type ='basic'/ 'oauth2'
//r.setAuthenticationProfile(authentication type, profile name);

//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');

//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);

 var response = r.execute();
 var responseBody = response.getBody();
 var httpStatus = response.getStatusCode();
}
catch(ex) {
 var message = ex.message;
}

 

 

I want to add this script as a UI Action to create a button for my form. When i add this script directly, it works fine.

 

However i also want to get the values of clientName and jobId dynamically from the form. So, i modified the query to this - 

 

 

try {

    var clientName = g_form.getValue('client_name');
    var jobId = g_form.getValue('job_id');
	
    var r = new sn_ws.RESTMessageV2('x_775122_enviro_tr.Get Tree Name', 'Post');
    r.setStringParameterNoEscape('clientName', clientName);
    r.setStringParameterNoEscape('jobId', jobId);

    //override authentication profile 
    //authentication type ='basic'/ 'oauth2'
    //r.setAuthenticationProfile(authentication type, profile name);

    //set a MID server name if one wants to run the message on MID
    //r.setMIDServer('MY_MID_SERVER');

    //if the message is configured to communicate through ECC queue, either
    //by setting a MID server or calling executeAsync, one needs to set skip_sensor
    //to true. Otherwise, one may get an intermittent error that the response body is null
    //r.setEccParameter('skip_sensor', true);

    var response = r.execute();
    var responseBody = response.getBody();
    var httpStatus = response.getStatusCode();
} catch (ex) {
    var message = ex.message;
}

 

But now the script doesnt work. What am i doing wrong here ?

 

 

1 ACCEPTED SOLUTION

piyushsain
Tera Guru

Hi @irfanshaik 

Please check the Client checkbox is True and onClick function is used in the script

View solution in original post

2 REPLIES 2

vermaamit16
Kilo Patron

Hi @irfanshaik 

 

Have you checked the Client Checkbox on the UI action ?

 

Thanks & Regards

Amit Verma

piyushsain
Tera Guru

Hi @irfanshaik 

Please check the Client checkbox is True and onClick function is used in the script