Modal /Pop up for selection of Closing state of Catalog Task in SOW

sayali97
Tera Contributor

Hello All,

 

I want to create the modal pop up in catalog task of the SOW. When we click on UI action Close task then the modal should appear in SOW and having 2 fields 1 is choice one and another is Textarea. How we can achieve it in service operational Workspace.

 

 

1 ACCEPTED SOLUTION

Shruti
Mega Sage
Mega Sage

Hi,

 

1. Make sure client checkbox and workspace button is checked on UI action

Shruti_0-1752035712930.png

 

Shruti_1-1752035786649.png

 

 

2. Sample workspace client script code

function onClick(g_form) {
    var fields = [{
            type: 'choice',
            name: 'reason_code',
            label: 'Reason code',
            value: ' -- Select -- ',
            choices: [{
                    displayValue: 'Duplicate',
                    value: 'duplicate'
                },
                {
                    displayValue: 'Canceled',
                    value: 'canceled'
                }
            ],
            mandatory: true
        },
        {
            type: 'textarea',
            name: 'comments',
            label: 'Comments',
            mandatory: true
        }
    ];
    g_modal.showFields({
        title: 'Additional information needed',
        fields: fields,
        cancelTitle: 'Cancel',
        confirmTitle: 'Submit',
        cancelType: 'default',
        confirmType: 'confirm',
        size: 'lg'
    }).then(function(fieldValues) {
       
        g_form.setValue('work_notes', fieldValues.updatedFields[0].value);
        g_form.save();
    });
}
 

 

 

View solution in original post

4 REPLIES 4

Shruti
Mega Sage
Mega Sage

Hi,

 

1. Make sure client checkbox and workspace button is checked on UI action

Shruti_0-1752035712930.png

 

Shruti_1-1752035786649.png

 

 

2. Sample workspace client script code

function onClick(g_form) {
    var fields = [{
            type: 'choice',
            name: 'reason_code',
            label: 'Reason code',
            value: ' -- Select -- ',
            choices: [{
                    displayValue: 'Duplicate',
                    value: 'duplicate'
                },
                {
                    displayValue: 'Canceled',
                    value: 'canceled'
                }
            ],
            mandatory: true
        },
        {
            type: 'textarea',
            name: 'comments',
            label: 'Comments',
            mandatory: true
        }
    ];
    g_modal.showFields({
        title: 'Additional information needed',
        fields: fields,
        cancelTitle: 'Cancel',
        confirmTitle: 'Submit',
        cancelType: 'default',
        confirmType: 'confirm',
        size: 'lg'
    }).then(function(fieldValues) {
       
        g_form.setValue('work_notes', fieldValues.updatedFields[0].value);
        g_form.save();
    });
}
 

 

 

Hi @Shruti  ,

For workspace is fine but what we can do for native UI?

Ankur Bawiskar
Tera Patron
Tera Patron

@sayali97 

there are lot of OOTB examples on how to render modal in sow

you can use g_modal API

check this

How to use UI Actions in Workspaces 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

sayali97
Tera Contributor

Hi @Shruti  ,

For workspace is fine but what we can do for native UI?