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

Auto populate close note when cancel change button is selected

Malo
Tera Contributor

hi all

 

When I select the UI form button fore cancel change, a reason field displays where I can enter reason for cancelling the change, I did like to auto populate this reason to  the close note so I dont have to re-enter in upon canceling 

 

Thanks in advance 

1 ACCEPTED SOLUTION

Hi @Malo 

Please replace with the reason with the work_notes and test the code. It will work for sure.

 

Thanks,
Murthy

View solution in original post

13 REPLIES 13

AlexTod1_1-1695673620648.png

 

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

 

current.close_notes.setDisplayValue("current.reason");

 

})(current, previous);

Malo
Tera Contributor

This is wrong, will set the value on the close notes to current.reason

 

The goal here is to display whatever data I have enetered in the reason to populate in the close note field 

Murthy Ch
Giga Sage

Hi @Malo 

You need to write a before update BR on change request when state changes to cancelled or you can update the OOB UI action if you want to copy everytime when change cancelled.

With before update BR:

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

    current.close_code = "unsuccessful"; //optional
    current.close_notes = current.work_notes.getJournalEntry(1).match(/\n.*/gm).join('').replace(/^\s*\n/gm, "");

})(current, previous);

It will copy the latest worknotes into close notes filed.

 

With UI action:
Find the cancel change ui action and use the same logic if you want to do.

(=tested)

Thanks,

Murthy

Thanks,
Murthy

Malo
Tera Contributor

Ideally this will only occur once because when you select cancel change, it cancels out the change request. I just want to document the close reason to be the same reason for what is entered in the reason field when it pops up

 

If I may ask, what would be the logic behind it copying every-time?  Just looking to get a better understanding.

 

for your solution, however, I am looking to copy the reason and not the work note

Malo_0-1695695772355.png

OOB frunctionality, when you click on cancel change it displays that text box and is mandatory, I did like whatever I enter i this box to populate on the close note

 

Hi @Malo 

Yes. I understood your scenario. Use my above code it will work. 
(=tested in my PDI)

Thanks,

Murthy

Thanks,
Murthy