Autopopulate variable value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 05:09 AM
I am working on a requirement. Using UI Action creating a request from an Incident. Once we click on the UI Action a request will be created and incident will be cancelled. This portion is working.
There are 3 variables on the catalog item for example abc, def and xyz.
abc should be auto populated as per the incident short description, def should be auto populated as per the incident description and xyz should be auto populated as per the incident urgency. This portion is not working.
Below is the script I have written:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 05:30 AM - edited ‎06-13-2024 05:31 AM
Hi @abhisek
In your script, itemGr.abc is simply going to update the RITM fields. Not the variables.
For Variables, you need to do something like this: itemGr.variables.abc= current.short_description;
Mark as correct and helpful if it solved your query.
Regards,
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 06:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 08:55 AM
Hi @Harish_K07
Both the catalog item and UI action are in different application scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 05:34 AM
Hi @abhisek ,
I believe abc, def, xyz are variable of catalog item, so they won't be set if you are Gliding into "sc_request" table. Try removing the code from there and set the all the field later in the script where you are Gliding into the "sc_req_item" table.
I've updated the code, pasted below:
(function executeRule(current, previous /*null when async*/) {
try {
var requestGr = new GlideRecord('sc_request');
requestGr.initialize();
requestGr.requested_for = current.caller_id;
var requestID = requestGr.insert();
var itemGr = new GlideRecord('sc_req_item');
itemGr.initialize();
itemGr.request = requestID;
itemGr.cat_item = 'sysid of the catalog item';
itemGr.requested_for = current.caller_id;
var itemID = itemGr.insert();
// Update the RITM with the request summary, description, and urgency
itemGr.abc= current.short_description;
itemGr.def= current.description;
itemGr.xyz= current.urgency;
itemGr.update();
Thanks.