How to populate change request field information to change task

Zuri
Tera Expert

I want to copy information from change request when new change task is added.

change configuration item

 

find_real_file.png

 

Change task I want the field to auto populate information from change request

find_real_file.png

1 ACCEPTED SOLUTION

Hi Zuri!
I think I did a mistake there!
I pointed you to sc_task table and not the change_task table!

Your code should be something like:

var gr = new GlideRecord("change_task");
gr.addQuery("change_request", current.sys_id);
gr.query();
while(gr.next()){
   gr.planned_start_date = current.getValue("start_date");
gr.planned_end_date = current.getValue("end_date");
gr.update();
}

Only use the gr.update() if your business rule is executing AFTER update. If it is Before update remove the gr.update().

Hope this helps!!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

View solution in original post

26 REPLIES 26

Filipe Cruz
Kilo Sage
Kilo Sage

Hello Zuri,

Create a business rule to run after Insert of the Change task with the following code:

(function executeRule(current, previous /*null when async*/) {

	current.cmdb_ci = current.change_request.cmdb_ci;
	current.update();

})(current, previous);

 

This should do what you need.

Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz



@Filipe Cruz thank you. I want also to copy the planned start date from change form to populate in change task form when you click new to add change task.

Hello Zuri,

You can then replace the previous code by this one:

(function executeRule(current, previous /*null when async*/) {

	current.cmdb_ci = current.change_request.cmdb_ci;
        current.planned_start_date = current.change_request.planned_start_date;

	current.update();

})(current, previous);

 

Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

Thank you @Filipe Cruz...The business rule will be on change task table?