The Zurich release has arrived! Interested in new features and functionalities? Click here for more

auto close button on form in workspace

jai281997
Tera Contributor

Hi Everyone Good morning/Good evening,

I am facing an issue with UI action button on form,

i have a button save and close on related list on change record

jai281997_0-1758722640964.png

when ever i click on save and close button it should close the current change and incident tabs 
ui action button am using

jai281997_1-1758723046712.png

function onClick(g_form) {
    var msg = getMessage("closing the ticket");
    g_modal.confirm(getMessage("please confirm to close"), msg, function(confirmed) {
        if (confirmed) {
            setTimeout(function(){
                g_aw.closeRecord();
                alert("test07line");
            },1200);
        }
    });
}

expected result: when ever i click save and close button on  change record  which is available in incident related list then change tab and incident tab should be close.

Thanks in advance!!



3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@jai281997 

it seems you opened the CHG from INC form and hence it got opened in new tab in workspace.

with your workspace client script on CHG table you can only close CHG and not the INC from where you navigated here

try this -> alert doesn't work in workspace client script

function onClick(g_form) {
    getMessage("closing the ticket", function(msg) {
        g_modal.confirm(getMessage("Confirmation"), msg, function(confirmed) {
            if (confirmed) {
                g_aw.closeRecord();
            }
        });
    });
}

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

Thanks for your response,
I have tried removing alerts also but still is closing change record tab, but my for my scenario it should close both change and incident records

function onClick(g_form) {
    var msg = getMessage("closing the ticket");
    g_modal.confirm(getMessage("please confirm to close"), msg, function(confirmed) {
        if (confirmed) {
            setTimeout(function(){
                g_aw.closeRecord();
            },1200);
        }
    });
}

@jai281997 

I don't think it's possible.

g_aw knows only the current tab which is open.

That's OOTB platform behavior.

Please inform this to your customer and ask them to train their agents.

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