The CreatorCon Call for Content is officially open! Get started here.

make a field visible and mandatory if other field changes values

hadron_collider
Tera Contributor

Hello,

 

 

I am trying to make the field "Reject reason" visible and mandatory to fill in in order to change the status.

 

kata90_0-1704463611188.png

 

 

 

23 REPLIES 23

@hadron_collider ,

 

We need to do the below:

 

  • Go to System Application > Application Cross-Scope Access
  • Create a new [sys_scope_privilege] record.
  • Select Target Scope as Global
  • Target Name as ScopedGlideSystem
  • Target Type as Scriptable
  • Operation as Execute API
  • Status as Allowed
  • Click on Update

Can you try this.

 

Thank,

Somehow I feel there should be a straightforward way of doing this. It seems it is an easy functionality:

kata90_0-1704495256515.png

I just need to ake sure that when approver rejects this request he fills in 'reject reason' which is by default hidden. I hope we are on the same page on this 🙂

 

@hadron_collider ,

 

The straight forward way is to make the field always visible.

Show a message at the top of the form, stating please select reject reason if rejecting.

Check in the server side, when the user clicks reject and if the reject reason is empty, we abort the action and force the user to select the reason.

Preventing the user from saving the record if they click on reject and reject reason is empty.

 

That is how servicenow does it as well by making comments field mandatory when someone rejects the approval.

 

Please mark helpful if this helped or accept the solution if it solved your query.

 

Thanks,

Ok I see. Can this be achieved in one single UI Policy? Initially I used it to change 

u_reject_reason = "Rejected" and exp_amount = 0. I tried to change it to "client" and to set u_Activity to mandatory and visible however this solution does not work:
kata90_0-1704699899098.png

as a result when approver "clicks" reject" there are new alert messages showing and nothing happens:

 

kata90_1-1704700064618.png

 

 

@hadron_collider ,

 

I see you have modified the code further.

Here is what you need to do:

 

if (g_form.getValue('u_activity') == ""){
g_form.setValue('u_reject_reason' , 'rejected');
g_form.setValue('exp_amount' , 0);
}

 

I hope the other code is still there.

Additionally you will need to return false; on line 52 of your code in the screenshot.

 

A UI policy will only work when you change a field on the form. I believe you need to do validation when the reject button is clicked.

 

Please mark helpful if this helped or accept the solution if it solved your query.

 

Thanks,