How to copy Planned start date and Planned end date from Change Request to Change Task when state is New record?

Akkapolk
Giga Expert

Create Change Request and then Click Change Tasks -> New.

find_real_file.png

 

How to copy Planned start date and Planned end date from Change Request to Change Task when state is New record?

find_real_file.png

 

 

 

1 ACCEPTED SOLUTION

The SN Nerd
Giga Sage
Giga Sage

You could write a before Business Rule, however, the record hasn't been created yet, so those fields won't be populated until you click submit.

I'd suggest using a display business rule to do the job with the following code:

(function executeRule(current, previous /*null when async*/) {
	
	var parentChange = current.change_request.getRefRecord();
	
	if (parentChange.isValidRecord()) {
		current.planned_start_date = parentChange.start_date;
		current.planned_end_date = parentChange.end_date;
	}


})(current, previous);

find_real_file.png


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

View solution in original post

8 REPLIES 8

The SN Nerd
Giga Sage
Giga Sage

You could write a before Business Rule, however, the record hasn't been created yet, so those fields won't be populated until you click submit.

I'd suggest using a display business rule to do the job with the following code:

(function executeRule(current, previous /*null when async*/) {
	
	var parentChange = current.change_request.getRefRecord();
	
	if (parentChange.isValidRecord()) {
		current.planned_start_date = parentChange.start_date;
		current.planned_end_date = parentChange.end_date;
	}


})(current, previous);

find_real_file.png


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Thank you very much.

What will be the When to run condition? I'm writing the above code at change task table with before Insert and Update when Change request field is not empty.

Not working for me.

Can you share the complete details that how can we achieve it.

Thanks in advance.