- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2018 08:51 AM
Hello,
We have a table for freeware called u_freeware_software and we have a catalog item that users fill out to add new approved freeware to the list. Once submitted, I added a runscript on the workflow that will take the values from the RITM and add a record to the u_freeware_software table. All of the fields that are just text values are inserting correctly (name, short_description, version, and comments.
The manufacturer field is not populating. This field is a reference variable to the core_company table. How do you insert a new value for a reference field in a workflow script?
Here is the script I have:
var freeware_name = current.variables.freeware_title;
var description = current.variables.details;
var version = current.variables.version;
var manufacturer = current.variables.manufacturer;
var url = current.variables.url;
var gr = new GlideRecord('u_freeware_software');
gr.initialize();
gr.name = freeware_name;
gr.short_description = description;
gr.version = version;
gr.manufacturer.setDisplayValue(manufacturer);
gr.comments = url;
gr.insert();
I tried doing gr.manufacturer = manufacturer; but then I read on the community site that for reference variables you need to use setDisplayValue but that still didn't work.
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2018 09:13 AM
Hello Hannah
If the core_company record don't exist you must insert first that record.
You can use something similar to this:
You must use the gliderecord to insert the core_company.
in the "insert statement" you can make this:
var grCoreCompany = new GlideRecord('core_company');
grCoreCompany.initialize();
grCoreCompany.field1 = valueField1;
var coreCompanyInserted = grCoreCompany.insert(); //to obtain the sys_id generated
Then you can use the coreCompanyInserted
gr.manufacturer = coreCompanyInserted;
Please, mark correct or useful if I helped you
Thanks
Ariel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2018 02:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2018 09:08 AM
Hello,
Is current.variables.manufacturer a text field or reference field on the catalog item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2018 09:10 AM
If this is a reference then you can just add
gr.manufacturer = manufacturer
Also make sure the target table has no reference qualifier applied on the manufacturer field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2018 09:18 AM
It is a text field