ui macro not rendered in service portal

rvenkataraman
Kilo Contributor

Hi,

I have some ui macro variables in my service catalog item, basically this ui macro displays some text.   However, when i am trying to view the item in the service portal, the form does not show the ui macro at all. Is this a constaint in Helsinki or am i missing something.

Regards,

Raj

22 REPLIES 22

Similar to the mobile app, the Service Portal only supports catalog script that utilize the mobile friendly version of the API. Secondly, you have to set the type to "Both" for it to take affect in portal.



screen_catalog_script.png


Jamie, did you get any resolution to this issue?   I'm in the same boat.   In Service Portal, Catalog Items Catalog Client Scripts don't seem to fire (perhaps not even present).   The UI Type for all my scripts is set to Both.   My scripts are simply used for client-side input validation and adding placeholder text (Re: Support for HTML 5 placeholder attribute ).


Community Alums
Not applicable

Seth,



The 'g_form.getControl' function is not supported in Mobile Client, thus not supported in Service Portal:



Mobile Client GlideForm (g form) Scripting - ServiceNow Wiki



So, to my understanding, the UI script used for the placeholder attribute will not run. I had to modify a client script I used to switch a field label so it followed the mobile compatible version of the script API. It was using the 'getControl' method to modify the field label (setLabelOf does not work in Service Catalog), and I ended up using the 'setLabel' function, as it works on mobile. There is some good info found here:



documentation/client_scripting.md at master · service-portal/documentation · GitHub  



Definitely will have to change some things when migrating to SP from CMS.



Cheers,



Tim


Thanks Tim.   I'm not sure why I'm having such a mental block on this process.   My Catalog Item's availability is set to "Desktop and Mobile" and I have updated my Catalog Client Script to:



function onLoad() {


    g_form.setFieldPlaceholder('move1_number_transfer','Phone Number');


}



But it still doesn't show up in ServicePortal.



Should it be put in a widget instead and then reference the widget for the variable?   If this is the process, I guess I'll be creating a widget for every variable?   It would be great if you could create a reuseable widget that could be like: g_form.setFieldPlaceholder(this-one,this-one.description).


Community Alums
Not applicable

That might work if you added a function to the 'client controller' script field of the 'form' widget. However, catalog client scripts and Catalog UI policies should work in SP; most of mine do.



Does the script work in the native UI, just not in Service Portal? I am not familiar with the 'g_form.setFieldPlaceholder()' function. Is that part of the g_form API?



Cheers,



Tim