
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 08:48 PM
Hi All,
I want to make 'contact number' field on incident form to mandatory when incident is created from New Call. And mandatory only on new record and if assignment group is Software. Can someone help me in achieving this functionality.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 09:13 PM
Hi @Community Alums ,
try below onchange client script on assignment group
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.isNewRecord()) {
if (newValue == 'b8ef24616fc331003b3c498f5d3ee434') { //add software group sysid
g_form.setMandatory('contact_number', true); //give contact number backend name
}
}
}
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 09:09 PM - edited 01-26-2023 09:15 PM
@Community Alums
1] Create onChange Client script for Assignment Group field. Try below script.
if (g_form.isNewRecord()) {
if (newValue == 'sysid_of_software') {
g_form.setMandatory('contact_number', true);
}
}
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
Thank You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2023 09:13 PM
Hi @Community Alums ,
try below onchange client script on assignment group
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.isNewRecord()) {
if (newValue == 'b8ef24616fc331003b3c498f5d3ee434') { //add software group sysid
g_form.setMandatory('contact_number', true); //give contact number backend name
}
}
}
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 07:45 AM
Hello ,
Using sys id in scripts is not recommended . I understand you are thinking its client scripts and how to use gs.getProperty , but as per health scan reports this script will be marked as a finding.
Instead please use
var group = (g_form.getDisplayBox('assignment_group').value);
if (group == "Software"){
// same as above post .
}
Please mark it helpful when you get your Output correct.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 12:01 PM
Above code does not fulfil my requirement. It is making field mandatory when incident is created from create new module. But my requirement is to make contact number mandatory if incident is created from new call.