The CreatorCon Call for Content is officially open! Get started here.

Scripting Help- Issue with Auto Populated Variables in a Catalog Item from a UI Action

Su522
Kilo Sage

I have a UI Action and an onLoad Catalog Client Script that auto-populates a variable from a record to the Catalog Item form.

This works perfect. 

However, if I manually open the Catalog Item on the Portal, the variable is auto- populated with the previous variable from using the UI Action.

How can I prevent this?

When manually ordering the Catalog Item, the variable should be blank when opening the Catalog Item form.

 

Here is my code.

UI Action:

var session = gs.getSession();
session.putClientData('short_desc', current.short_description);
var short_desc = current.short_description;
gs.setRedirect('com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=ea3841fc4751351010057cb2a36d438b&sysparm_short_desc=' + short_desc);

 

Catalog Client Script:

function onLoad() {
var sd = g_user.getClientData('short_desc');  
g_form.setValue('short_desc', sd);    
}

 

Help is Greatly appreciated!!

Thank you.

1 ACCEPTED SOLUTION

In that case, the simplest solution may be to use your original UI Action and Catalog Client Script, but change the UI Type on the CCS to 'Desktop' so that it doesn't run in Service Portal. 

View solution in original post

9 REPLIES 9

You mentioned that you open the Catalog Item in Portal - do you also ever open it directly in the native UI?  When you use the UI Action, is this ever or always in Portal or the native UI or both?

@Brad Bowman  

Hi Brad,

We always open the Catalog Item in the Service Portal- when we manually need to order Catalog Items.

We don't utilize the native UI for Catalog Items.

When we use this UI Action, it is always from the record in the native UI (never from the SP).

 

I appreciate your help!!!

Thank you,

Susan

In that case, the simplest solution may be to use your original UI Action and Catalog Client Script, but change the UI Type on the CCS to 'Desktop' so that it doesn't run in Service Portal. 

Su522
Kilo Sage

@Brad Bowman  

That worked!!! Thank you so much!!!!!!!!!!!!! 😀

You are welcome - happy to help!

 

 

Connect with me https://www.linkedin.com/in/brad-bowman-321b1567/