How to make fields mandatory in service portal widget ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 05:18 AM
Hello SN Team,
I have requirement when "substate != non" then "location" field should be mandatory or it should show some error message on location field "Location is Required ".
Please help me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 05:21 AM
Hi,
You need Client script or UI Policy.
If you use UI Policy than don't need any coding.
Br,
Jozsef

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 05:23 AM
Hi Vinod,
Please check if this could help.
1. If you have created a custom widget then use the below method.
<input type="text" required/>
//Client script
$scope.submit = function(){
if(!$scope.state){
spUtil.addErrorMessage("Please fill the required fields.");
return;
}
}
2. But if you are using the OOB form widget then you just have to set the field as mandatory in the table.
Reference : How to make fields mandatory on a service portal widget
Mark Correct or Helpful if it helps.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 05:34 AM
Hi,
Can be done easily using UI policy
What did you start with and where are you stuck?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2022 05:41 AM
Hello vinod ,
you built a custom form using widgets?
of is it catalog item?
if its a custom form can you post the code so that i can suggest you ?