Copy Request short_description to Requested Item short_description via workflow script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 03:38 AM
Hi All,
I've created a script that is run via the workflow to set the Request short_description to what has been entered in the summary variable.
I'd like to now copy what is in the Request short_description to the Requested Item short_description (done this way so I don't have to customise both scripts for different catalog items.
This is what I currently have which works to update the request - how can I change it to work to update the request item from what is on the request?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 04:24 AM
To update the short description of the requested item based on the short description of the request, you can use a similar approach as you did for updating the request:
// Get the short description and number of the request
var requestShortDescription = current.short_description;
var requestNumber = current.number;
// Query the requested item related to the request
var requestedItemGR = new GlideRecord('sc_req_item');
requestedItemGR.addQuery('request', current.sys_id); // Assuming 'request' is the reference field to the request table
requestedItemGR.query();
// Update the short description of each related requested item
while (requestedItemGR.next()) {
requestedItemGR.short_description = requestShortDescription;
requestedItemGR.update();
gs.info('Updated short description for requested item: ' + requestedItemGR.number);
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 04:38 AM
Thank you, but unfortunately, this is not working. I'd be happy to use the variable instead of copying it from the Request. Would that be easier?
So I would instead do: