Set Field Mandatory When Closing Incident Task w/ UI Action

kevinthury
Tera Guru

Our Incident Tasks have two button (UI Actions) that are designed to change the state to Closed Complete or Closed Skipped.   When one of these buttons is clicked, we are looking to set the close_notes field on The Incident Task as Mandatory to ensure something is entered in the field.

I have created a UI Policy that sets the field as mandatory when the State is Closed Complete or Closed Skipped.   With this UI policy active, the Close button changes the state to Closed Complete and sets the field to mandatory.   What need to happen is the the field is to become mandatory without changing the State.   In addition, if I select the Closed Complete option from the field drop-down, the field becomes mandatory (as I would expect).

In short, the UI Action is not enforcing the mandatory field to be populate prior to changing the state.   Below is a copy of that UI Action followed by the UI Policy.

I'm not sure what I am missing.   Ideas/Suggestions?

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Prateek kumar
Mega Sage

Hello Kevin


Can we try something like this


community.PNG


Script:



function runClientCode(){


if(g_form.getValue('work_notes') == ''){


g_form.addErrorMessage("This state cannont be changed with empty worknotes");


return false;


}


gsftSubmit(null, g_form.getFormElement(), 'closed_complete'); //MUST call the 'Action name' set in this UI Action


}



if(typeof window == 'undefined'){


serverQualify();


}


function serverQualify(){


current.state = 3;


//Create the html contents of the information message


current.update();


action.setRedirectURL(current);


}



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

4 REPLIES 4

EashVerma
Giga Expert

You can try writing the script inside a if-loop in the following manner,



if(current.close_notes != null){


current.state = '3';


action.setRedirectURL(current);


current.update();


}



else{


alert("Close Notes are Empty");


}



I hope it works.


Prateek kumar
Mega Sage

Hello Kevin


Can we try something like this


community.PNG


Script:



function runClientCode(){


if(g_form.getValue('work_notes') == ''){


g_form.addErrorMessage("This state cannont be changed with empty worknotes");


return false;


}


gsftSubmit(null, g_form.getFormElement(), 'closed_complete'); //MUST call the 'Action name' set in this UI Action


}



if(typeof window == 'undefined'){


serverQualify();


}


function serverQualify(){


current.state = 3;


//Create the html contents of the information message


current.update();


action.setRedirectURL(current);


}



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Thank you, Prateek!   Your suggestion worked great!   Here is a screenshot of the UI Action for others to reference:



find_real_file.png


Hello Kevin


Glad that it worked for you. Cheers



Please mark my response as correct and helpful if it helped solved your question.
-Thanks