Form Button not showing up in Service Portal

cnharris1
Kilo Sage

Good morning everyone,

I have a print button that I created on form in ServiceNow. The button works fine within the platform but when I view the form within the Service Portal, the button is missing. Its an client-side button, which I'm sure is part of my problem. I've tried using the gsftSubmit(null, g_form.getFormElement(),'print') but haven't had any luck. Could someone check out my code and tell me what I'm doing wrong? Here's my code along with a screenshot of the ui action:

gsftSubmit(null, g_form.getFormElement(),'print');

if (typeof window == 'undefined')
     popOutLink();

function popOutLink() {    
    var user = g_form.getReference('u_name');
    var signature= new GlideRecord('u_signature');
    signature.addQuery('u_document_id', user.sys_id);
    signature.orderByDesc('sys_created_on');
    signature.query();
    if(signature.next())
    {
        
    }
    window.open('wow_document.do?sysparm_signature=' + signature.sys_id+"&sysparm_wow_doc="+g_form.getUniqueValue()+"&sysparm_name="+user.name);
    
}

find_real_file.png

Any help will be greatly appreciated!

 

Best regards,

 

 

cnharris

8 REPLIES 8

Hi Harris,

Then any error you see in browser console while form loads in portal?

Regards

Ankur

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

Hi Ankur,

I have the client checkbox checked so my button isn't showing up at all when I view the form in the portal, however when I uncheck the client checkbox, the button shows up. However, when I click the button, I get these error messages:

find_real_file.png

Hi Harris,

That is because on Service Portal side GlideRecord is not allowed in client side code; you can use getReference() with callback and also use script include with GlideAjax and try once

OR else directly do GlideAjax and send value of u_name to script include function and rest do in script include function

update it as below:

function popOutLink() {    
    var user = g_form.getReference('u_name', callBackMethod);

}

function callBackMethod(user){

 

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur,

I update my code but still can't get the button to display on the form in the Service Portal, however, you did point me in the right direction.

Best regards,

 

cnharri