How do you make work notes mandatory when a state changes?

KB30
Tera Expert

I tried to create a UI policy but there is not action for when a state changes. I want to make work notes mandatory when the states changes from on hold to work in progress

9 REPLIES 9

How do I add to a UI action I created? I have a UI action button that changes the state to In progress. Script is below.

 

current.incident_state = 2;
current.update();
action.setRedirectURL(current);

Aishwaryaaa_
Kilo Sage

AishwaryaS1_0-1708691480013.png

@KB30 You Can do this with the help of onChange() Client script.

Please refer my snapshot provided above.

Here is a Code:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '' || g_form.isNewRecord())
        return;
    else if (newValue == oldValue)
        g_form.setMandatory("work_notes", false);
    else if(oldValue != newValue )
        g_form.setMandatory("work_notes", true);
}
 
 
If it is helpful please mark it as a helpful.
Aishwarya Shelake

@Aishwaryaaa_ is this possible via a UI action? The client script still calls for hte user to change it but the state is updated via a UI action button I created.

@KB30 , you can call the client script in the UI Action.

Aishwarya Shelake

@Aishwaryaaa_ How can I call it? Here is my sample script

 

function onLoad() {
if (oldValue == 3 && newValue == 2) {
g_form.setMandatory('work_notes', true);
} else {
g_form.setMandatory('work_notes', false);
}
   //Type appropriate comment here, and begin script below
   
}
 
// You can call this in UI Actions
// Only works in global scope (does not work in scoped apps)
// Will only work for UI Action of the same table
function yourFunctionHere() {
 
 
// Code here
}