Create/Update record thru workflow script

hongsok
Tera Contributor

Dear all,

I created a catalog item to Create New or Update Existing record on the table name Company [core_company].

There are 3 variables:

  • Create New or Update Existing - Multiple Choice
  • Current Manufactory - reference to Company [core_company]
  • New Manufactory - Single Line Test

Note that: the field that need to update/create new in theCompany [core_company] table call name.

I created the following workflow script to update/create new record somehow it is not working.

var mft = current.current_manufacturer_name;
var gr = new GlideRecord('core_company');
gr.addQuery('name', mft);
gr.query();

if (gr.next())

{
current.setAbortAction(true);
gr.name = current.new_manufacturer_name;
gr.update();
}

I would appreciate your help.

 

Regards,

Hong

 

 

1 ACCEPTED SOLUTION

Hello,

Please see my last reply, above.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

11 REPLIES 11

hongsok
Tera Contributor

Hi Maik,

I have removed it.

Here is the new script, and it is still not working.

var mft = current.variables.current_manufacturer_name;
var gr = new GlideRecord('core_company');
gr.addQuery('name', mft);
gr.query();

if (gr.next())

{

gr.name = current.variables.new_manufacturer_name;
gr.setWorkflow(false);
gr.update();
}

Hi

can you please spend some more details about what exactly is not working?

What is your expectation and what is the result?

Do you get any meaningful error outputs? Is your workflow stuck anyhow?

Kind regards
Maik