Call REST API in UI Action button using client callable Script Include

Ranjith Ram
Tera Contributor

Hi All,

 

I'm trying to call a REST API trigger in UI Action using client callable Script Include. The purpose is to create an Incident in 2nd Instance, when an UI action button is clicked in 1st Instance.
I have referred community and build the below code and its not working as expected. So, kindly help on this to achieve the results.

Client callable Script Include:

RanjithRam_1-1672688200033.png

 

UI Action:

RanjithRam_2-1672688288146.png

Alert message:

RanjithRam_3-1672688801223.png

 

 

4 REPLIES 4

Saurabh Gupta
Kilo Patron

Hi,
Looking at your script include, from where you getting the details of inc.short_description etc. etc..

 

 


Thanks and Regards,

Saurabh Gupta

Hi Saurabh,
inc.short_description, inc.state, inc.priority all are the values of current incident form where I'm using my UI action button in 1st instance. Im setting those values to 2nd Instance incident form fields.

But how this current is reaching to your script include to UI action?



Thanks and Regards,

Saurabh Gupta

Gayatri Sharma1
Tera Contributor

Hi

Please perform the following changes in the Script include and the client script respectively:

.....Script include........

createWorkorder : function()

{

var short_description = this.getParameter('sysparrm_short_description');

var description = this.getParameter('sysparm_description');

var priority = this.getParameter('sysparm_priority');

var state = this.getParameter('sysparm_state');

var state = this.getParameter('sysparm_sysID'); //use these variables instead of inc.state etc.

}

.....Client script.......

ga.addParam('sysparm_name', 'createWorkorder');

ga.addParam('sysparm_sysID', g_form.getUniqueValue());

ga.addParam('sysparm_short_description', g_form.getValue('short_description'));

ga.addParam('sysparm_description', g_form.getValue('description'));

ga.addParam('sysparm_priority', g_form.getValue('priority'));

ga.addParam('sysparm_state', g_form.getValue('state'));

.....

 

Please mark the answer as correct and helpful, If I answered your query. Thank you !