make a field visible and mandatory if other field changes values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 06:08 AM
Hello,
I am trying to make the field "Reject reason" visible and mandatory to fill in in order to change the status.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:50 PM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:55 PM
Somehow I feel there should be a straightforward way of doing this. It seems it is an easy functionality:
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 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 02:59 PM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 11:47 PM
Ok I see. Can this be achieved in one single UI Policy? Initially I used it to change
as a result when approver "clicks" reject" there are new alert messages showing and nothing happens:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 05:24 AM
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,