How to create a UI action that auto populates the assignment group based on value of specific field?

JordyZ
Mega Sage

Hi,

 

I have a client script + script include in place that auto populates the assignment group based on the "managed by group" field of the business application field on the incident form. 

Client script:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading)
        return;

    if (newValue == oldValue) {
        return;
    }

    var businessAppId = g_form.getValue('u_business_application'); // Get the ID of the business application

    //Call script include
    var ga = new GlideAjax('DVTIncidentUtils'); // Script Include
    ga.addParam('sysparm_name', 'businessAppManagedByGroup'); // Function
    ga.addParam('sysparm_appId', businessAppId); // Parameters
    ga.getXMLAnswer(getResponse);
}

function getResponse(response) {
    if (response) {
        g_form.setValue('assignment_group', response);
    } else {
        g_form.addErrorMessage(getMessage("An assignment group was not found"), 'info', false);
    }
}

 

So when the Business application is chosen on the incident form, this client script will take the "managed by group" field value of the business application, and auto populates the assignment group of the incident form.

 

I'd like to know: how do I create a UI button on the incident form that does exactly this? I'd like to have a button instead of this client script, because the button will give the user a choice whether they want to escalate (to the "managed by group" group) or not.

 

It should work like this: when a business application is chosen, the assignment group remains as is. When the "escalate" button has been pressed, then the assignment group gets populated based on the managed by group of the business application.

 

How do I go about creating this? Thanks in advance.

 

1 ACCEPTED SOLUTION

Teja11
Giga Guru

Hi @JordyZ ,

 

Refer to the link below to see how to execute both Server side code and client side code in UI ACTION

https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/ 

 

Regards,

Teja

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

View solution in original post

2 REPLIES 2

Teja11
Giga Guru

Hi @JordyZ ,

 

Refer to the link below to see how to execute both Server side code and client side code in UI ACTION

https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/ 

 

Regards,

Teja

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

Thanks @Teja11 , exactly what I needed.