Work Notes mandatory when problem goes to closed state when we click re- analyze UI action?

pooja30
Tera Contributor

When we click on re-analyze UI action, when problem goes to closed state, work notes should be mandatory. 

7 REPLIES 7

Filipe Cruz
Kilo Sage
Kilo Sage

Hello pooja,

You need to do a couple of changes in the UI Action:

- mark the checkbox "client"
- on the onclick, insert "reanalize();"
- replace the script by this one:

function reanalize(){
	g_form.setMandatory("work_notes", true);
	if(g_form.getValue("work_notes") != "")
		gsftSubmit(null, g_form.getFormElement(), 're_analyze'); //MUST call the 'Action name' set in this UI Action
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined') {
    action.setRedirectURL(current);
    new ProblemStateUtils().onReAnalyze(current);
}

Then your UI Action should be similar to this:


find_real_file.png

 

Just for you to understand:

- when the ui action is pressed, the onclick will execute the code that is there, in this case it will execute the function "reanalize".
- The function sets the work_notes as mandatory and if the work notes are populated it will trigger the code that will run outside of the onclick function. That is the code that was there before!

Let me know if this works for you!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz

Musab Rasheed
Tera Sage
Tera Sage

Hi Pooja,

Try this make sure you check 'Client' as checked and add 'reanalyze()' in Onclick field. Mark my answer as correct if that helps.

function reanalyzeproblem(){
   if (g_form.getValue('work_notes') == '') {
      // Remove any existing field message, set work notes mandatory, and show a new field message
      try {
         g_form.hideFieldMsg('work_notes');
      } catch(e) {}
      g_form.setMandatory('work_notes', true);
      g_form.showFieldMsg('work_notes', getMessage('Please enter a work_notes'), 'error');
      return false;  // Abort submission
   }
   // Call the UI Action and skip the 'onclick' function
   gsftSubmit(null, g_form.getFormElement(), 're_analyze'); // MUST call the 'Action name' set in this UI Action
}

// Code that runs without 'onclick'
// Ensure call to server side function with no browser errors
if (typeof window == 'undefined')
   serverReopen();

function serverReopen() {

action.setRedirectURL(current);
new ProblemStateUtils().onReAnalyze(current);
}

 

Please hit like and mark my response as correct if that helps
Regards,
Musab

hello Rasheed,

we don't want to touch OOB functionality.

is there any other option to make worknotes mandetory when problem goes to close state.

 

 

Hi Pooja,

Then simply write onsubmit client script like below. Don't forgot to mark my as correct

function onSubmit()

{

var r = g_form.getValue('work_notes');
var er = g_form.getValue('state');

if(r == '' && er == 'closed')

{

g_form.setMandatory('work_notes', true);

return false;

}

}

 

Please hit like and mark my response as correct if that helps
Regards,
Musab