A Field should be Mandatory to fill-in when clicked on "Defer" button on the Idea form

Vaishnavi35
Tera Guru

Hi,

 

1. When "Defer" button is clicked I want "Reason for Rejection(u_reason_for_rejection)" field mandatory to fill-in. Once that field in filled in, Approver will click on "Defer" again. and form is updated/Saved, state moves to "Closed Skipped"

Vaishnavi35_0-1718699765610.png

 

Updated code,

function ReaFRejc()
{
if(g_form.getValue('u_reason_for_rejection') == '')
{
g_form.setMandatory('u_reason_for_rejection', true);
g_form.gs.addInfoMessage(gs.getMessage("Mention the 'reason for rejection' of the Idea"));
return false; //Abort submission
}


//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'sysverb_defer'); //MUST call the 'Action name' set in this UI Action
}
if(typeof window == 'undefined')
serverReopen();

current.state = '7';
current.close_notes = "Deferred by Demand Manager.";
current.update();
if (action.get('isFormPage') == 'true')
	action.setRedirectURL(current);
else
	action.setRedirectURL('/'+current.getTableName()+'_list.do');

When I click on "Defer', 'Reason for Rejection' is mandatory to fill-in, I update the field and click on "Defer" again. State does not move to "Close skipped" stays in "submitted' state'. 

 

2. 'Reason for Rejection' field should only be visible when "Defer' is clicked.

How can I achieve this help?

 

Thanks,

Vaishnavi

1 ACCEPTED SOLUTION

Slava Savitsky
Giga Sage

This article explains how to combine client-side and server-side code in a single UI action. In the client-side part, you can use the following code to make your field mandatory:

g_form.setMandatory('u_reason_for_rejection', true);

View solution in original post

8 REPLIES 8

Configure a UI policy to hide reason for rejection by default. Then call setDisplay() before setMandatory() in the code of your UI action like this:

g_form.setDisplay('u_reason_for_rejection', true);
g_form.setMandatory('u_reason_for_rejection', true);

 

Okay. It worked. 🙂 I have added the comment in the rejection email. Even that worked.

 

But it does not show the field again on the form? after rejection. Its always hidden.

How can I make the commented field visible?

 

THANK YOU SO MUCH FOR THE HELP.

In your UI policy that hides the field, add a condition: State is not Closed Skipped (or whatever state you are using).

Thank you so much for the continued help!!