- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2016 07:44 AM
We would like our asset management team to be able to use the publish to catalog links in the product catalog, but need to have them provide a workflow and then automatically add a standard variable set to the catalog item when created. I have successfully updated the UI Page and the Script Include to capture the workflow and pass that to the produced catalog item, but have not had success with adding the variables.
This is what works to add the workflow:
ProductCatalogUtils:
createProductCatalog: function(source, category, type, table, workflow) {
var destination = new GlideRecord(table);
this._syncRows(destination, source, category, type, workflow);
var sys_id = destination.insert();
this._syncPicture(source, table, sys_id);
return sys_id
},
publish_to_product_catalog (edited line only):
gr.product_catalog_item = (new ProductCatalogUtils()).createProductCatalog(gr, sc_category, type, catalog, wf_workflow);
I've added a couple new functions to the ProductCatalogUtils. A copy of the createProductCatalog which includes a call to another new function to add a variable set to the catalog item, and then from the publish_to_product_catalog, I have tried calling this new function. When I click the "Publish" link, it prompts me for the category and workflow, but when I click OK, the page refreshes and I see the prompt on the full screen. These are the new functions.
createProductCatalogwVar: function(source, category, type, table, workflow) {
var destination = new GlideRecord(table);
this._syncRows(destination, source, category, type, workflow);
var sys_id = destination.insert();
this._syncPicture(source, table, sys_id);
this._addVariables(sys_id);
return sys_id
},
_addVariables: function(cat_sys) {
var destination = new GlideRecord(io_set_item);
destination.sc_cat_item = cat_sys;
destination.variable_set = '37ce635a4fe9160079a5e9628110c764';
destination.insert();
},
I'm not sure what I'm doing incorrectly here.
Thanks,
Kristen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 09:17 AM
We were unable to resolve this in our environment with either solution above, so we will be manually adding variable sets when publishing to the catalog.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2016 09:17 AM
We were unable to resolve this in our environment with either solution above, so we will be manually adding variable sets when publishing to the catalog.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2016 10:33 AM
Hi Kristen,
I found this discussion when I too am having the same issues. We've had this code in place since Jan 2015 and didn't have this problem, but it seems that some patch updates (possibly Fuji patch 13?) looks to be duplicating 1 variable within a variable set each time when publishing to the catalog we are seeing this happen in different variable sets on different items. I agree that it must be a bug in SN code that seems to be picking one variable in the variable set to insert when the entire variable set is added to a new item. I really don't want to have to manually add variable sets after our product manager would publish the items, so I was hoping that maybe you have any new information on this? I realize that you marked it resolved due to manually doing it, so I'm just checking in on it.
Thanks,
Trena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2016 02:00 PM
Hi Trena,
Unfortunately we weren't able to find a way around the duplicated variable, so are just doing the variable adds manually.
Thanks,
Kristen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 12:35 PM
I'm having the same problem, just starting to try and debug now.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 12:57 PM
I added a Business Rule "Leave <variable set name> Alone" for the table "Variable [item_option_new]" which runs, on Insert only and when Variable set is <name of affected variable set>.
Under action, only the Abort action is checked.
It's ugly as heck but works like a charm so far, I'll report back if it fails in QA.