How can I write field data to a custom table from a run script in Workflow Editor

Justin T
Tera Contributor

Hello,

I would like to know the best method to write fields to a custom table, using a run script within workflow editor.

Here is an example of my run script

var dr = new GlideRecord('u_direct_enterprise_software');
dr.addQuery('u_record_number', workflow.scratchpad.newRecID);
dr.query();
while (dr.next()) {
    var cvar = current.variables;
    dr.u_is_the_vendor_on_a_sactioned_list = cvar.is_the_vendor_on_a_sactioned_list;
    dr.u_has_the_vendor_or_software_been_breached_in_the_past_3_years = cvar._has_the_vendor_or_software_been_breached_in_the_past_3_years;
    dr.u_vendor_website = cvar.vendor_website;
    dr.u_vendor_headquarters = cvar.vendor_headquarters;
    dr.u_vendor_locations = cvar.vendor_locations;
    dr.u_company_officers = cvar.company_officers;
    dr.u_vendor_status_from_securityscorecard = cvar.vendor_status_from_securityscorecard;
    dr.u_fedramp_level_if_applicable = cvar.fedramp_level_if_applicable;
    dr.u_cve_mitre_vulnerabilities_noted = cvar.cve_mitre_vulnerabilities_noted;
    dr.u_virus_total_results = cvar.virus_total_results;
    dr.u_data_stored_in_the_software = cvar.data_stored_in_the_software;
    dr.u_us_developed = cvar.us_developed;
    dr.update();
}
 
I'll attach various images of how my flow is constructed 
JustinT_0-1713238530360.png

Essentially,

The catalog task is created -> it gets completed (the new fields are filled out on the catalog task by the user) -> runs through the approval stage -> after approval, the fields that are filled out on the catalog task get written to a record on the custom table u_direct_enterprise_software

 

At the moment, I currently have all functionality working besides the fields writing to the record on the table.

They simply do not populate to the table and I do not know why.

JustinT_1-1713238679758.png

 

JustinT_2-1713238876945.png

 

 

3 REPLIES 3

Vishwa Pandya19
Mega Sage

Hello Justin,

 

May i know why you are using "cvar" instead of current.variables.xyz?

Hi Vishwa, I used this as a personal preference method,

 

However I am curious now.

Would using current.variables directly prove to be a different result?

Deepak Shaerma
Kilo Sage

Hi @Justin T 

follow the correct approach for updating fields in a table based on user input from a Catalog Task. However, it looks like there might be a typo or misunderstanding in how you’re accessing the variables from the current record. The way you access catalog item variables should work correctly if current is indeed referring to the catalog task record, but it’s always good to confirm the context in which your script is running. Additionally, ensure that the variables are named exactly as they appear, paying close attention to any cases of potential typos (e.g., a single underscore in variable names within the script but not in the actual variable names).
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma