Call REST API in UI Action button using client callable Script Include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 11:47 AM
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:
UI Action:
Alert message:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 11:56 AM
Hi,
Looking at your script include, from where you getting the details of inc.short_description etc. etc..
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 10:49 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 11:54 PM
But how this current is reaching to your script include to UI action?
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2023 04:41 AM
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 !