- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 05:27 AM
Hello Experts.
We developed one catalog item and once user submit the request, REQ ticket and RITM ticket will create initially.
And Once REQ ticket approved one more RITM will create and each RITM ticket have one unique SCTASK ticket.
When SCTASK ticket state changed to closed complete then RITM state will also change to Resolved and after 3 business days Job scheduler will change the RITM state from resolved to closed complete then REQ state also change to closed complete then RITM workflow will also end.
Note: Once both the RITM tickets state change to resolved then only REQ ticket state changing to resolved. [So far everything working fine and Existing business rule changing the REQ state to resolved after RITm tickets state are changed to resolved]
And now when any one RITM ticket reopened before the job scheduler close the RITM tickets, then we need to create one more SCTASK under reopened the RITM ticket and we need to change the REQ state as well from resolved to Work in progress.
Can anyone please advice the best approach to fulfill the requirement.
Many thanks for the support.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2022 02:54 AM
Hi
In that case you need to follow the steps below and then do it:
1) First create a hidden field on Requested Item Table say name it as "Check Reopen" and type of the field will be as "True/False" as shown below:
2) Now create a Before Update business Rule as per details shared below:
BR Details:
Table Name : Requested Item
When: Before Update
Condition: State Changes to Reopen and Check Reopen is False
Script:
This BR will set the value of the hidden field to True only once when any of the RITM is moved to Reopen. So using this you can identify for which RITM the catalog task need to be created and also it will be created just once.
Now the next step is to write another BR on Requested Item table and use the details as shared below:
BR Details:
Table Name: Requested Item
When: After Update
Order : 1000
Condition: Check Reopen Changes to True AND State is Reopen
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var getRequest = current.request;
var gr = new GlideRecord('sc_request');
gr.addQuery('sys_id',getRequest);
gr.query();
if(gr.next()){
var getRITM = getAllRITM(gr.sys_id,current,gr);
}
function getAllRITM(reqID,current,gr){
var gr1 = new GlideRecord('sc_req_item');
gr1.addQuery('request',reqID);
gr1.addQuery('u_check_reopen',true);
gr1.query();
if(!gr1.next()){
createCatalogTask(current,gr1);
}
}
function createCatalogTask(current,gr1,gr){
var gr2 = new GlideRecord('sc_task');
gr2.initialize();
gr2.request_item = gr1.sys_id;
gr2.parent= gr1.sys_id;
gr2.FIELD_NAME = gr1.Field_Name; // Replace "FIELD_NAME" with field of Catalog Task and "Field_Name" with the field of Requested Item table which you want to copy
gr2.insert();
}
})(current, previous);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 05:37 AM
Hi RC,
Here is an approach:
Create a business rule,
Before, Insert/update on the [sc_req_item] table.
Trigger is when RITM state changes from resolved
create a new record for SCTASK and populate fields..
Example:
var scTask = new GlideRecord('sc_task');
scTask.newRecord();
scTask.number = //set all the scTask fields.
scTask.insert();
Then in the script do a glide record query to find the parent of the RITM (the Request) and change the state to work in progress.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:36 AM
Hi,
Many thanks for the response.
Could you please check my latest response and helps me out.
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 05:42 AM
Hi RC,
Depending on what needs to be done relative to the new task, you have a couple of choices.
The simple one is when the state on the RITM changes, have a business rule (before insert) that looks at current.state and previous.state. If previous.state was resolved and current.state is any of the open states, your BR can create the task and update the state on the request. When the task is closed, that should roll up to the RITM, etc. as per usual. This assumes that there is no workflow needed to manage what happens with the task.
If things need to be more controlled, you can manage it through your workflow such that your flow can anticipate the reopening of an item which would then be able to do whatever is needed before returning to a wait for where the conditions are that all items have reached their resolved state and from there continue doing your closing.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 07:35 AM
Hi,
Many thanks for the response.
Could you please check my latest response and helps me out.
Advance thanks.