when i edit the change planned start and end date in change record new change task is created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 09:29 AM
Hi,
Could any one help me on this!!
When i try to edit the start and end date of the existing change request, corresponding dates are not updated in the change task. Instead it is creating the change task newly.
Below is the code i am using :
BR( after, Update) ;
Filter condition: When Planned start and end date changes
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('change_task');
gr.addQuery('change_request',current.sys_id);
gr.query();
if(gr.next())
{
gr.planned_start_date = current.start_date;
gr.planned_end_date = current.end_date;
gr.update();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 10:35 AM
I just created a business rule on the change_request table based on the script and trigger conditions provided by you. The BR just works fine for me. The planned start and end date gets updated on the change task via this business rule. Can you check if any other BR is getting triggered on the change request table which is causing this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 11:39 AM
Hi @Gayathree Seeth,
There would be some other script that might be triggering when you are updating the start and end date.
You can troubleshoot to find that code and make it inactive and try to test your code.
Also, your code looks correct to update the change task. Only small change I will do is to use while instead of if to make sure that all the change tasks are getting updated.
var gr = new GlideRecord('change_task');
gr.addQuery('change_request',current.sys_id.toString());
gr.query();
while(gr.next())
{
gr.planned_start_date = current.start_date;
gr.planned_end_date = current.end_date;
gr.update();
}
Mark helpful if it helps in solving your query.
Regards,
Johns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 02:43 AM
Hi Johns and Sandeep thanks for your reply!!
I am using BR(Before, insert) on the change_task table to insert the start and end dates with the below code
current.planned_start_date=current.change_request.start_date +'';
current.planned_end_date=current.change_request.end_date +'';
Does this affects the above code which i pasted earlier?? Because without using this two line codes the Dates are not getting inserted.
Note: Except this i am not using any code on Change_request table for update.
Pls suggest

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 03:45 AM
The before insert BR on change_task for setting the change task start and end date shouldn't cause any issues as it populates the dates when the new task is inserted whereas the after update BR on change request updates the start and end date of change task when the change request date and time is changed.
Will it be possible for you to share the screenshot of the BR on change request table. May be it will give us some hint about the issue.