- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 04:20 AM - edited 09-11-2024 04:21 AM
I want to know when a sc_task is closed to query the variable and/or the short description then update the same short description/variable to the sc_req_item
I was thinking something like this but it is not working:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 05:30 AM
Just to be clear, variables only exist once, in an object that is available to all sc_task records within a sc_req_item record, so you don't need to copy one to/from the other. You can copy a variable to a field like short description, or copy the short description to the short description or whatever. It would be best to do this as a Business Rule. In your scenario this BR would be on the sc_task table, after Update. Add Filter Conditions for a specific Catalog Item and/or Catalog Tasks, unless you always want this to run when every Catalog Task is closed, and one for State changes to Closed Complete, or whatever fits your criteria. In the Script on the Advanced tab is where you would do the GR on sc_req_item to update that record
(function executeRule(current, previous /*null when async*/ ) {
var grRITM = new GlideRecord('sc_req_item'); // Use 'sc_req_item' for RITM
if (grRITM.get(current.request_item)) { // Use 'request_item' to get the related RITM
grRITM.short_description = current.short_description; // Update the RITM short description
//grRITM.description = current.variables.var_name; //Update the RITM description with a variable
grRITM.update(); // Update the RITM record
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 05:30 AM
Just to be clear, variables only exist once, in an object that is available to all sc_task records within a sc_req_item record, so you don't need to copy one to/from the other. You can copy a variable to a field like short description, or copy the short description to the short description or whatever. It would be best to do this as a Business Rule. In your scenario this BR would be on the sc_task table, after Update. Add Filter Conditions for a specific Catalog Item and/or Catalog Tasks, unless you always want this to run when every Catalog Task is closed, and one for State changes to Closed Complete, or whatever fits your criteria. In the Script on the Advanced tab is where you would do the GR on sc_req_item to update that record
(function executeRule(current, previous /*null when async*/ ) {
var grRITM = new GlideRecord('sc_req_item'); // Use 'sc_req_item' for RITM
if (grRITM.get(current.request_item)) { // Use 'request_item' to get the related RITM
grRITM.short_description = current.short_description; // Update the RITM short description
//grRITM.description = current.variables.var_name; //Update the RITM description with a variable
grRITM.update(); // Update the RITM record
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 06:59 AM
I have a drop down field that I want when it is changed from the sctask upon closure of the sctask
to update the RITM.
I think the coding would need to glide to the sc_task?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 07:33 AM
With the script I supplied, the Business Rule runs on the sc_task table, so it has access to the entire record (that is being closed in this case). current.field_name or current.variables.var_name is the way to do this, as shown in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 10:04 AM - edited 09-11-2024 10:15 AM
that worked but I had it actually the opposite on what I am trying to accomplish
so instead of taking the short description from the closed task how to grab the short description from the next sctask that gets created? @Brad Bowman
