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-20-2017 11:35 AM
Hello Lexy,
Script should be
var gr = new GlideRecord('proc_po');
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();
Can you please give more info on "I would also like to create a new record related record in the related table of proc_po_item.".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2017 07:00 AM
Thanks a lot Pradeep. it worked.
Regarding the proc_co_item table, I am trying to create an equivalent sets of related records to the ones just created on the proc_po table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2017 05:35 PM
Thanks for the update Lexy. Sorry, I'm still confused. Do you want to copy the same records on proc_co_item table? Please confirm.
Screenshots will be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2017 02:05 AM
Thanks a lot Pradeep,
Parent Table: proc_po (fields: vendor, price, description, requested_by)
Child Table: proc_po_item (fields: vendor, order dates, price, model)
Common reference field between Parent and Child tables: "vendor", "price",
Mission:
- To create a Parent record from the Workflow = Almost complete
- The Parent Record will automatically create a child record using some details from the parent record and others from the catalog item.
Script to Create a new record from the workflow:
- New Record in Parent Table (proc_po)
//
var gr = new GlideRecord('proc_po' table);
gr.initialize();
gr.vendor_account = current.variables.u_first_name;
gr.description = current.variables.u_description;
gr.setValue('vendor', current.variables.u_vendor); //vendor
gr.total_cost = current.price; //price
gr.setValue('ship_to', current.variables.u_ship_to);
gr.setValue('requested_by', current.requested_for); //THIS IS NOT WORKING (set Requested_by in the variable to requested_for on the proc_po table)
gr.insert();
//
Code for the Child record (proc_po_item table)
//Trying to use a BR to auto-create the related list record
Tried a BR to create …
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gri = new GlideRecord('proc_po_item');
gri.addQuery('vendor', current.sys_id);//reference field on related list table
gri.query();
if (!gri.next()) {
gri.newRecord();
gri.vendor = current.sys_id;
gri.total_cost = current.price; //price
gri.insert();
}
})(current, previous);