I want to create a new record using a workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2017 08:52 AM
Using a workflow, I want to create a new record on a table. However, this is creating multiple records. In addition,
I would also like to create a new record related record in the related table of proc_po_item.
var gr = new GlideRecord('proc_po');
gr.query();
gr.initialize();
gr.vendor_account = current.variables.u_first_name; //variables.u_first_name is the field from the variable this should be
gr.number = current.variables.u_last_name;
gr.insert();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2017 10:56 AM
Hello Lexy,
Replace gr.setValue('requested_by', current.requested_for); with
gr.setValue('requested_by', current.request.requested_for);
Code for the Child record (proc_po_item table): Make sure to create an AFTER business rule and put few log statements to check
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2017 01:07 PM
Thanks a lot Pradeep. Requested_for worked, but the child table creation did not work. I will continue to review and try other approaches. I appreciate your help.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2017 01:11 PM
You are very welcome Lexy. From the screenshot, I see child table has a field "Purchase order" which refers to the parent table record. If that is correct, then please share the column name of the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2017 03:26 AM
It worked, thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2017 11:18 PM
Using the same model,
I am trying to have the requested item and the list price of my item display on the proc_po_item table and doesn't seem to be working. My code is below. The "product_catalog" is a reference field. I can't seem to see why it is not working
var gr = new GlideRecord('proc_po_item');
gr.addQuery('purchase_order', current.sys_id);//reference field on related list table
gr.query();
if (!gr.next()) {
gr.newRecord();
gr.purchase_order = current.sys_id;
gr.list_price = current.cat_item.price; //Price of the catalog item
gr.vendor = current.vendor;
gr.setValue('product_catalog', current.cat_item.name); // Catalog item name
gr.insert();
}