gel("sys_uniqueValue").value not working inside UI Action

Ajit Natarajan1
Kilo Expert

I am trying to implement a UI action (form link) that shows in the Catalog Item form that lets developers preview the item inside Service Portal with following script. However, the gel() reference doesnt seem to work. I have an Orlando developer instance where this seems to work fine. Looking for some guidance.

function previewInPortal(){
    var catItem = gel("sys_uniqueValue").value;
    var url = '/sp?id=sc_cat_item&sys_id='+catItem; // replace dev Id with your instance id
    window.open(url,'_blank');    
}

1 ACCEPTED SOLUTION

Ajit Natarajan1
Kilo Expert

All suggestions are valid. The issue was resolved after I set the "isolate scripts" to false. I had to make that attribute visible by going into configure > form layout.

Got the hint from => https://community.servicenow.com/community?id=community_question&sys_id=be150ce2db766780656a5583ca961935

 

 

View solution in original post

5 REPLIES 5

Harsh Vardhan
Giga Patron

gel() does not work on portal end. 

Sorry, I shouldnt have tagged the portal. This shouldnt pertain to portal, instead only on the catalog item configuration area.

so user is clicking this button on native ui ? are you getting any error in console log ?

Jaspal Singh
Mega Patron
Mega Patron

Hi Ajit,

 

Can you check this blog it has an update set attached & that is to be committed so as to get an view of 'Try It' on Portal.

Also, in your code replace

var catItem = gel("sys_uniqueValue").value;
    var url = '/sp?id=sc_cat_item&sys_id='+catItem; // replace dev Id with your instance id
    window.open(url,'_blank');  

with

window.open("sp?id=sc_cat_item&sys_id=" + g_form.getUniqueValue(), "_blank");