- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 12:06 AM
Hi All
I need to validate the languages in user table while end user is sending data through payload. The similar kind of validation I did for company and its working fine but how we can give the same for a drop down choice?
sample company filed validation->
var user_company = body['Company'].toString().trim();
if (user_company == '' || user_company == null || user_company == undefined)
return {
"Status": "Enter the Company"
};
var company = new GlideRecord('core_company');
company.addQuery('name', user_company);
company.query();
if (company.next()) {
user.company = company.getUniqueValue();
} else {
return {
"Status": "Invalid company"
};
}
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 02:13 AM
Hi,
if it's a creation then against what you wish to perform the validation?
are you saying you wish to check the sys_choice table and check value they pass is present in choice list or not?
in that case you can query sys_choice with element - preferred_language
name=sys_user^element=preferred_language
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
‎03-30-2022 12:08 AM
@shloke04
Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 12:35 AM
Hi,
are you receiving the user_name from external system?
if yes then you can query in sys_user for that user and get the language
what's the challenge faced?
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
‎03-30-2022 01:22 AM
sample company filed validation->
var user_company = body['Company'].toString().trim();
if (user_company == '' || user_company == null || user_company == undefined)
return {
"Status": "Enter the Company"
};
var company = new GlideRecord('core_company');
company.addQuery('name', user_company);
company.query();
if (company.next()) {
user.company = company.getUniqueValue();
} else {
return {
"Status": "Invalid company"
};
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 02:13 AM
Hi,
if it's a creation then against what you wish to perform the validation?
are you saying you wish to check the sys_choice table and check value they pass is present in choice list or not?
in that case you can query sys_choice with element - preferred_language
name=sys_user^element=preferred_language
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader