I want to create a new record using a workflow

lexy
Kilo Expert

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();

17 REPLIES 17

Thanks a lot Chuck. It worked. However, the variables didn't populate reference fields. Was wondering how I could achieve that....


DilipKumar DJ
Kilo Guru

Hi Lexy,



Please remove gr.query();


Hello all, similar to this, from within a workflow, I am having an issue where I cannot get the RITM number into the new created story. Everything else is working fine but just one line of code I am having trouble with. I am not sure what am I missing.   My code is as follows:



createStory();


function createStory() {


var rmStory = new GlideRecord("rm_story");


rmStory.initialize();


rmStory.description = current.variables.u_er_description;


rmStory.u_requested_item = current.number;   // where 'u_request_item' is a reference field on the rm_story table and current.number is the RITM number that I want to get there.


rmStory.u_rm_story_use_case = current.variables.u_er_use_case;


rmStory.insert();


}



Thanks for all the help.