We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

“Copy Change” functionality to correctly duplicate original Change Request details post-template

Mounika B1
Tera Contributor

Hi Team,

when am trying to click on copy change button original change request not copying along with custom template .
we have created custom template

 

MounikaB1_1-1770641135844.png

after clicking on copy change in justification field add data was not copied in copy change request 

MounikaB1_2-1770641285373.png

can anyone give me suggestion why template data is not copied and environment as well not populated

3 REPLIES 3

Mark Manders
Mega Patron

Can you share the code behind your 'copy change'? I suspect the issue being in the fields not being mentioned as 'to copy' fields. It could be in the UI action itself or in a script include called from the ui action.

 

Just to be sure: did you save the Change request before copying? Because without saving, it can't get the data from the original change.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Mounika B1
Tera Contributor

Hi Mark,

Thanks for the response , below is the code
Copy change Ui action.

MounikaB1_1-1770793059226.png

 

MounikaB1_0-1770793026692.png

Script includes :

MounikaB1_2-1770793188088.png

i have tried with added  template variable in below property, but still no changes, please do the need full

MounikaB1_3-1770793372380.png

 

Mounika B1
Tera Contributor

Hi Mark,

 

I have custom template that should apply from original change request to copy change. In my scenario  copy change is not working with template date, how to achieve this.
I have custom template to apply this to change i wrote one onload client script.

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (g_form.isNewRecord()) {


        var changeType = g_form.getValue('type');
        var model = g_form.getValue('chg_model');

        if (changeType == 'normal' || changeType == 'emergency' || changeType == 'expedited') {
            applyTemplate('13d2e5ee2b57a2502b62f4596e91bf0f'); // sys ID of Change_Default_Template //sys_template
        }
    }
}