Business rule is not giving the desired result when change request state is closed from workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2024 12:37 AM
I have a change request and it has child change request. When parent record is closed, child record should automatically be closed. The parent record is getting closed from workflow. I have created a BR on after update to set the state of child record to be closed when parent is closed. But the BR i have created is giving me the count as 0 which is incorrect.
When the parent record is closed and I go the form and update the form and save the form then my BR is working perfectly fine and giving me the count as 1 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2024 12:47 AM
Hi @Akanksha35 ,
Are you adding the current.update() in your workflow script to update the parent change request record.
Can you share the script that you tried in workflow.
And instead of creating business rule, you can create 1 more run script activity in your workflow and write the below script in that activity.
var gt=new GlideRecord('change_request');
gt.addQuery('parent',current.sys_id);
gt.query();
if(gt.next())
{
gt.state=choice value of state field for closed;
gt.update();
}
Please mark my answer as correct and helpful if it helps to resolve your issue.
Regards,
Namrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2024 12:51 AM
Hi Namrata,
Thanks for replying. I am not using current.update() in workflow.
I am using BR because i need to do this requirement for all the types of change request so I have to make changes in all the workflows. That's why I am opting after BR to avoid making changes in all the workflows
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2024 01:01 AM
Hi @Akanksha35 ,
Can you add current.update() in the script where you are changing the state of parent change request as closed and try once. And in the business rule add condition state is closed.
Regards,
Namrata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2024 01:08 AM
Hi Namrata,
I have used the condition 'state is closed' in my BR . The BR is executing. I have logs statement in line 1 , it is getting printed , then i added my logic. Count is coming incorrect, when workflow sets the state to closed.
When i am opening a closed change request form and update anything to make my BR trigger, then count is coming correct.