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

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);

Hi @Slava Savitsky ,

 

I have updated the code accordingly, but the state is in "Submitted" state only, it does not move to "Close skipped".

When I click on "defer" , 'Reason for rejection; is mandatory, I fill-in the details. When I click on defer again. The form updates the comments, state is not close skipped and redirects me to Idea list.

 

If you can help me what is wrong in my code please?

Vaishnavi35_0-1718705136724.png

 

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');

 

Thanks,

Vaishnavi

There must be a business rule that prevents the state change. Review the code of the applicable business rules or use the business rule debugger to find out which one it is.

Hi,

the script worked. 🙂

It did not define the server side script. I added the function and called it, it worked.

 

Can you help me with the other part?

I want 'reason for rejection" field visible only when defer is clicked. How can I achieve that?