Display message within a catalog item after it has loaded

leochavez
Tera Guru

 

After a catalog item has loaded, I would like a simple info message displayed at the top of each one.  Think of it as a global message for all catalog items.  Since most of our catalog items contain a common variable set, I figured I could simply create and tie a catalog client script to this common variable set.  That said, I created the following catalog client script:

Applies to: A Variable Set
Variable set: My variable set selected (and verified multiple times)
Type: onLoad()
Active: checked
UI Type: All (also tried using Desktop)
Applies on a Catalog Item view: checked
Order: 9999
Script:

function onLoad() {
    g_form.addInfoMessage("Info message here");
    alert("Alert here");
}

When I load a catalog item containing the variable set, the alert pops up, but no info message is displayed.  I also switched them around and received the same results.

Also, there is another 'onLoad()' script within the same variable set, but it does not contain 'g_form.clearMessages()' or the like.  I also set this script (order) to run last (e.g. 9999).

Is this a limitation of the system or one of those issues in which I'm simply overlooking something?

3 REPLIES 3

Jace Benson
Mega Sage

So this works for me OOB on my Personal developer instance;

I'd do the following;

1.  Enusre there's no errors in your browsers console(f12) if you are getting an error in a client script before this client script gets run, this will fail to run.
2.  Ensure this is a a "Catalog Client Script" I'm pretty sure it is but thats another option.
3.  Still not working, try to recreate this on a new item, or on a personal developer instance.

Here's the code I used;

 

And here's what it did;

 

Hi Jace,

Thanks for response.  In your example, you have tied the script to a catalog item.  This works correctly, but only for that specific catalog item. 

My example ties the script to a variable set (exists within most of my catalog items), but fails to produce a info message (js alert works).  Again, not sure if I'm overlooking something, or just a limitation of the tool.

- Leo

I moved my client script to a new variable set, and associated the variable set to the item and it still works for me in both places.