- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2025 09:10 AM
Hi
i would like to know how this scenario can be done.
I have a variable named "Expenditure type" and this expenditure type has a value named"Lease"
the "Lease" should be visible only for the users from the US. (i,e) when the user's email id ends with @usa.com
Can you please help me with this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2025 02:49 AM
Hi @Abdul ,
create this client callable script include
var CheckUserEmailDomain = Class.create();
CheckUserEmailDomain.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isParklandUser: function() {
var email = gs.getUser().getEmail();
return email && email.endsWith('@usa.com');
}
});
you may see the highlighted field as Client callable ( check it )
create onload client script
function onLoad() {
var expenditureType = 'u_expenditure_type'; //update this with expenditure type varialbe name if required
var ga = new GlideAjax('CheckUserEmailDomain');
ga.addParam('sysparm_name', 'isParklandUser');
ga.getXMLAnswer(function(response) {
if (response == 'true' || response == true)
g_form.removeOption(expenditureType, 'lease'); // is lease is the backend value of lease choice else update it with correct value
});
}
update the variable names and choice values if required with correct values
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2025 09:13 AM
yes you can write a client script and do the dot walk to location.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 07:45 AM
should i use script includes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 08:01 AM
Yes you'll want to make a script include for the server side actions. You'll need to make it client callable and use GlideAjax in your client script. You can then add/remove choices using g_form based on the result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2025 08:17 AM
Can you please correct my code
Script Include: