Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

New Contact Button is not working Properly

madhu110
Giga Contributor

Hi Team,

 

I have added a New Contact Button with Ui action on Service Now Workspace . On clicking + Menu  the  Create New Incident . Create New Incident Page is displayed. There on clicking New Contact , it is directed to Contact Directory Page. Here it is working but  When I am selecting on the list  page  of the incidents,  in the details Section, on clicking of New contact it is not working. Can any one please provide the solution , why ui action is not working Properly.

 

madhu110_0-1786458502474.png

It is working Properly here.

madhu110_1-1786458543850.png

but it is not working here.

 

5 REPLIES 5

Dinesh Chilaka
Mega Sage

@madhu110 ,

Does the same UI Action referring at both places?If possible try to share your code.

Thanks,

Dinesh

Yes, created only one Ui action ,please find the code below

function onClick(g_form) {

}function onClick() {
    var result = g_form.submit('sysverb_ws_save');
    if (!result) {
        //failed form submission
        return;
    }

    result.then(function() {
        var params = {};
        params.sysparm_parent_table = "incident";
        params.sysparm_parent_sys_id = g_form.getUniqueValue();
        g_service_catalog.openCatalogItem('u_contact_directory', '-1', params);
    });
}

@madhu110 ,

Your script has worked for me , make sure you have filled all the mandatory fields on the existing record.

Thanks,

Dinesh

Shivambitanwar1
Tera Contributor

Hi @madhu110 , 

 

Can you remove multiple function declaration and have only one as below: 

function onClick(g_form) {
    var result = g_form.submit('sysverb_ws_save');
    if (!result) {
        //failed form submission
        return;
    }

 

    result.then(function() {
        var params = {};
        params.sysparm_parent_table = "incident";
        params.sysparm_parent_sys_id = g_form.getUniqueValue();
        g_service_catalog.openCatalogItem('u_contact_directory''-1', params);
    });
}


Also, make sure that onclick checkbox is checked on your ui action (screenshot attached).