How to open url into new tab in agent workspace

Poorna7
Tera Expert

I have written below code in ui action client script , it is working fine if but it is opening a link in new window outside of agent workspace but I want to open it in the new tab with n agent workspace only. Could someone help me how should I achieve this.

function onClick(g_form) {
var url = 'sp?id=sc_cat_item&sys_id=14287122db109050665dd855ca961914&parent=' + g_form.getUniqueValue();
open(url);
}

 

1 ACCEPTED SOLUTION

My bad I thought you want to open new browser tab. 

To open inside the workspace tab, have you checked g_service_catalog.openCatalogItem()

 

eg: you can refer ootb UI Action, "Create Request" 

Reference:

 

https://docs.servicenow.com/bundle/quebec-it-service-management/page/product/service-catalog-managem...

 

View solution in original post

28 REPLIES 28

Thanks so much Harsh. I marked the answer helpful and I am also able to figure out about that error but not able to resolve that.

In the catalog item there is client script written to check attachments in which sp_form is there due to which it is causing error and always throwing exception.

Can you please help me how should I fix this. I have highlighted the line which is causing the issue in agent workspace.

 

 

function onSubmit() {

var errorMessage = "Before you can submit this request, you must attach a screen shot to assist with troubleshooting.";

try {
//if document and gel available, in old iframe view. Check attachments using older methods
//Otherwise try using new method for OOB portal widgets
if (document && gel) {
var ajax = new GlideAjax('checkAttachments');
ajax.addParam('sysparm_name', 'checkAttach');
ajax.addParam('sysparm_user', g_user.userName);
if (gel('sysparm_item_guid') !== null) {
ajax.addParam('sysparm_sys_id', gel('sysparm_item_guid').value); //itens
} else {
ajax.addParam('sysparm_sys_id', gel('sysparm_cart_edit').value); //order guide
}
ajax.getXMLWait();
if (ajax.getAnswer() == 'false') {
top.sweetAlert(errorMessage, '', 'error');
return false;
} else {
return true;
}
} else {
var catItemId = g_form.getUniqueValue();
if (!sp_form.hasRequiredAttachments(catItemId)) {
g_form.addErrorMessage(errorMessage);
return false;
}
return true;
}
} catch (e) {
g_form.addErrorMessage("Error - unable to check attachments - contact support for troubleshooting by navigating <a href='https://instance.service-now.com/sp?id=sc_cat_item&sys_id=c19b74e5dbc497008e14ff431d961980'>here</a> and completing the form.<br><br>Error detected: " + e);
return false;
}
}

You can put the alert to check sp_form.hasRequiredAttachments(catItemId) value, 

Anyway, alternate solution. try with below blog solution, see if it is working or not.

 

https://community.servicenow.com/community?id=community_blog&sys_id=00edd9751bb090d0ada243f6fe4bcba8

Any update on this thread?

Do you need any further help ?

 

If my answer helped you, kindly mark it as correct and close this thread. 

Thanks Harsh for the help. I have marked the answer correct to close the thread.