- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 07:43 AM
Hi,
I have a requirement where we have a field called 'Active Directory Group'. So based on the drop down of variable 'Account type', the show field message of the 'Active Directory Group' changes and based on the selection, it accepts only particular kind of message format. Even though the message says something like 'sbx_' in small letters, some are entering in CAPS and it is clearing off the field. They want to accept all CAPS as well as small. I worked for small, I don't know how to make it to accept capitals. Kindly help.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg("active_directory_group", "true");
var group = newValue;
var accounttype = g_form.getValue("account_type");
if (accounttype == "Sandbox") {
if (!group.toString().startsWith("sbx_")) {
g_form.clearValue("active_directory_group");
g_form.showFieldMsg("active_directory_group", "The Active Directory group should begin with sbx_ if the account is sandbox specific.");
}
} else {
if (!group.toString().startsWith("cloud_aws")) {
g_form.clearValue("active_directory_group");
g_form.showFieldMsg("active_directory_group", "The Active Directory group should begin with cloud_aws if the account is not sandbox specific.");
}
}
}
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 08:26 AM
try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg("active_directory_group", "true");
var group = newValue.toString().toLowerCase(); // Convert input to lowercase
var accounttype = g_form.getValue("account_type");
if (accounttype == "Sandbox") {
if (!group.startsWith("sbx_")) {
g_form.clearValue("active_directory_group");
g_form.showFieldMsg("active_directory_group", "The Active Directory group should begin with sbx_ if the account is sandbox specific.");
}
} else {
if (!group.startsWith("cloud_aws")) {
g_form.clearValue("active_directory_group");
g_form.showFieldMsg("active_directory_group", "The Active Directory group should begin with cloud_aws if the account is not sandbox specific.");
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 07:59 AM
Hi @Dave_p
We had a similar requirement as well.
To address it, we created two fields: one for capturing user input and another, a read-only field, which retrieves the user input, converts it to lowercase, and stores it accordingly.
Then we used the read-only field value for our automations etc..
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 08:26 AM
try this
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg("active_directory_group", "true");
var group = newValue.toString().toLowerCase(); // Convert input to lowercase
var accounttype = g_form.getValue("account_type");
if (accounttype == "Sandbox") {
if (!group.startsWith("sbx_")) {
g_form.clearValue("active_directory_group");
g_form.showFieldMsg("active_directory_group", "The Active Directory group should begin with sbx_ if the account is sandbox specific.");
}
} else {
if (!group.startsWith("cloud_aws")) {
g_form.clearValue("active_directory_group");
g_form.showFieldMsg("active_directory_group", "The Active Directory group should begin with cloud_aws if the account is not sandbox specific.");
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 09:07 AM
Hello, try by converting input to lower case
var group = newValue.toString().toLowerCase();
Regards