make a field mandatory when clicking on a ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 04:21 AM
Hi community, the client asked me for the following configuration: in the demand form, when clicking on the "approved" button he wants certain fields, for example due date (requeted_by) to ask it as mandatory and the flow not to continue. What is the best way? Ui_Policy combined with Client_scripts? Business rules? modify Ui_action? I read them! Thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 11:05 AM
@Daiana Botta - In ServiceNow, you can enforce the "Due Date" field as mandatory before allowing the approval process to continue by using a Client Script or a Business Rule. The best approach, I would recommend is Business rules:
If you want to enforce this check at the database level (in case of API updates or by manual approvals), you can use the Business Rules.
Steps:
1. Go to System Definition → Business Rules.
2. Click New to create a Business Rule.
3. Fill in the details:
- Name: Ensure Due Date before Approval
- Table: demand (or your specific table)
- Advanced: Checkbox (Check this option)
- When to Run: Before Insert or Update
- Condition: approval == "approved"
4. Script:
5. Click Submit to save.
How it Works?
- If an approval action is triggered and due_date is empty, then update is blocked, and the user gets an error message.
Kindly mark it as correct/helpful, if it resolves your issue. Please press the "like" button to vote for me.
With Regards,
Krishna Kumar M
