The CreatorCon Call for Content is officially open! Get started here.

When Change is created by clicking on "Copy change" then add worknotes on new change with change

Samuel Penumaka
Tera Contributor

When Change is created by clicking on "Copy change" then add worknotes on new change with change number it was copied from.

I tried business rule below, dint work.

(function executeRule(current, previous /*null when async*/) {
// Check if the change request is created by copying from another change
if (current.changes_made == 'copied') {
// Add work notes to the new change request with the change number it was copied from
var workNotes = "This change request is copied from change " + current.copied_from.change_number;
current.work_notes = workNotes + "\n" + current.work_notes;
}
})(current, previous);

3 REPLIES 3

Sohail Khilji
Kilo Patron

Hi @Samuel Penumaka ,

 

Refer this logic ;

 

https://www.servicenow.com/community/developer-forum/modifying-the-copy-change-ui-action/m-p/2130082


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Amit Gujarathi
Giga Sage
Giga Sage

HI @Samuel Penumaka ,
I trust you are doing great.
Please find the updated business rule as given below :

(function executeRule(current, previous /*null when async*/) {
    // Check if the change request is created by copying from another change
    if (current.changes_made == 'copied') {
        // Add work notes to the new change request with the change number it was copied from
        var copiedFrom = current.getValue('copied_from');
        if (copiedFrom) {
            var copiedFromChangeNumber = copiedFrom.getValue('change_number');
            if (copiedFromChangeNumber) {
                var workNotes = "This change request is copied from change " + copiedFromChangeNumber;
                current.work_notes = workNotes + "\n" + current.work_notes;
            }
        }
    }
})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Samuel Penumaka
Tera Contributor

Hello Amit,

Unfortunatly, it dint work as expected.Community.PNG