Copy change details in the change task

Samiksha2
Mega Sage

Hi All,

I have a requirement to create a UI action to copy change Planned start and end date, short description, description in the change task.

Please help in this.

Thanks,
Sam

22 REPLIES 22

Sorry , my bad., This property not work here.

 

https://www.servicenow.com/community/developer-forum/how-copy-value-date-time-from-change-request-to...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

SN_Learn
Kilo Patron
Kilo Patron

Hi @Samiksha2 ,

 

The reason the below code is not working because the change task is not yet saved in the server side and is not having sysId associated with it. Hence, the script is not working.

 

You can utilize g_scratchpad and store the change details and call those in the client side of UI action

Use this as reference: Display Business Rule and g_scratchpad 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Nishant8
Giga Sage

Hello @Samiksha2 , Can you please update your script section with the script, mentioned below, and share the feedback?

Although this script should solve the problem for now, I'll strongly recommend to either populate g_scrathpad variable (you can refer any of existing business rules on Change_task for e.g. 'Scratchpad Variables from parent Change') and make use here in the script or call the glideAjax SI, if script to be used frequently.

---------script to be used-----------

function copyDetails(){
var taskGR = new GlideRecord('change_request');
taskGR.get(g_form.getValue('change_request'));
g_form.setValue('short_description',taskGR.getValue('short_description'));
g_form.setValue('description',taskGR.getValue('description'));
g_form.setValue('planned_start_date',taskGR.getValue('start_date'));
g_form.setValue('planned_end_date',taskGR.getValue('end_date'));
}