Make a field mandatory if incident is created from new call

Community Alums
Not applicable

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.

1 ACCEPTED SOLUTION

Pavankumar_1
Mega Patron

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
        }
    }
}

Screenshot (612).png

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

View solution in original post

10 REPLIES 10

Hi @Community Alums ,

it will check only whether it is new record or not isNewRecord() will not check what module you are using.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Pavankumar_1
Mega Patron

Hi @Community Alums ,

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.
If not reply and share details.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Community Alums
Not applicable

Hi @Pavankumar_1 

I have tried about code but it is not meeting my requirement. It is making contact number mandatory when we are creating incident from "Create New" module but its not making mandatory if incident is created from New Call>Call type>Incident.

Can you check the URL values to determine if the incident is created from "Create New" module or "New Call" module , rest of the code is already there. Also can you paste exact screenshots to let us know what exactly is the process you are following to create the incident.

Hi @Community Alums ,

As per my script if it is a new record it will set contact number mandatory.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar