i want to update the close notes with given reason by the user while cancel change UI Action button

srushikesan
Tera Contributor

i want to update the change request "close notes" field  with given cancel reason by the user through on cancel change UI Action button.

2 ACCEPTED SOLUTIONS

pr8172510
Tera Guru

Hi @srushikesan,

I was able to achieve the requirement without modifying the OOTB Cancel Change UI Action.

Since the cancellation reason entered in the Cancel Change Request dialog is already stored in Work Notes, I created a Before Update Business Rule on the Change Request [change_request] table that triggers when the Change moves to the Canceled state and copies the latest Work Note into Close Notes.

(function executeRule(current, previous) {

    if (current.state.changesTo('4')) {

        var reason = current.work_notes.getJournalEntry(1);

        if (reason) {
            current.close_notes = reason;
        }
    }

})(current, previous);






pr8172510_0-1781876274396.png

 

pr8172510_1-1781876301330.png

 

 

View solution in original post

Hi @srushikesan ,

You can use this 

(function executeRule(current, previous) {

    if (current.state.changesTo('4')) {

        var reason = current.work_notes.getJournalEntry(1);

        if (reason) {

            // Remove timestamp, user name and "(Work notes)" header
            reason = reason.replace(/^[^\n]*\n/, '').trim();

            current.close_notes = reason;
        }
    }

})(current, previous);

This will store only:Server reboot no longer required


instead of:2026-06-19 19:22:26 - System Administrator (Work notes) Server reboot no longer required

  

pr8172510_0-1781878460443.png

 

View solution in original post

4 REPLIES 4

pr8172510
Tera Guru

Hi @srushikesan,

I was able to achieve the requirement without modifying the OOTB Cancel Change UI Action.

Since the cancellation reason entered in the Cancel Change Request dialog is already stored in Work Notes, I created a Before Update Business Rule on the Change Request [change_request] table that triggers when the Change moves to the Canceled state and copies the latest Work Note into Close Notes.

(function executeRule(current, previous) {

    if (current.state.changesTo('4')) {

        var reason = current.work_notes.getJournalEntry(1);

        if (reason) {
            current.close_notes = reason;
        }
    }

})(current, previous);






pr8172510_0-1781876274396.png

 

pr8172510_1-1781876301330.png

 

 

Hi Pawan Rathod,

Thanks for your response and it is working as expected but i don't want to show the "026-06-19 19:22:26 - user name (Work notes)" in close notes only the reason text.

Thanks 
S Rushikesan

srushikesan
Tera Contributor

Thanks Pawan Rathod can you suggest to remove the "2026-06-19 19:20:25 - user name (Work notes)" in close notes

Hi @srushikesan ,

You can use this 

(function executeRule(current, previous) {

    if (current.state.changesTo('4')) {

        var reason = current.work_notes.getJournalEntry(1);

        if (reason) {

            // Remove timestamp, user name and "(Work notes)" header
            reason = reason.replace(/^[^\n]*\n/, '').trim();

            current.close_notes = reason;
        }
    }

})(current, previous);

This will store only:Server reboot no longer required


instead of:2026-06-19 19:22:26 - System Administrator (Work notes) Server reboot no longer required

  

pr8172510_0-1781878460443.png