Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Fields are not populating after submitting record producer

sinu2
Tera Expert

HI Team,

 

I have a record producer. Inside record producer i have created a multi row variable set name calle d as "item_list". Inside multi row variable set i had 6 variables. 

As soon as i submit the record producer from portal,  A record is creating to that table but fields are showing empty.

So how can i map those MRVS variable content inside native view table fields?

\

I had created a before Business rule to map MRVS to table fields but not working

the MRVS log is showing error like below

 

find_real_file.png

(function executeRule(current, previous /*null when async*/) {

var value = current.variables.items_list; //  MRVS variable name here
	gs.log('Inside :', value);

var parser = JSON.parse(value);
gs.log(parser);
var addtable = new GlideRecord('x_pl4_move4u_item');

for(var i=0;i<parser.length;i++){

addtable.name = parser[i].name;
addtable.move_request = parser[i].move_request;
addtable.is_fragile = parser[i].is_fragile;
addtable.category = parser[i].category;
addtable.short_description = parser[i].short_description;
addtable.volume = parser[i].volume;
addtable.insert();

}

})(current, previous);
1 ACCEPTED SOLUTION

are you using correct variable name within mrvs here?

var parserList = JSON.parse(producer.items_list);

current.name = parserList[0].name;
current.move_request = parserList[0].move_request;
current.is_fragile = parserList[0].is_fragile;
current.category = parserList[0].category;
current.short_description = parserList[0].short_description;
current.volume = parserList[0].volume;

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

27 REPLIES 27

RaghavSh
Mega Patron

Try this in Record producer script, instead of using a before insert BR.

Also try to log "parser[i].name" and check if this is returning correct value.


Raghav
MVP 2023
LinkedIn

where can i find record producer script?

 

Record producer script in present in record producer section "what it will contain".

 

also make below change to your script:

 

addtable.name = parser[i].name.toString();


Raghav
MVP 2023
LinkedIn

Hi Raghav,

Please find my below record producer script. Actually my record producer is in "x_pl4_move4u_item" table and i am gliding the same table "x_pl4_move4u_item" to map the MRVS variables in to the same table "x_pl4_move4u_item".

 

As per your request i am doing this but the problems are

creating duplicate records and all fields are not mapping any suggestions as per my below script?

/** This script is executed before the Record is generated
* `current`- GlideRecord produced by Record Producer
* Don't use `current.update()` or `current.insert()` as the record is generated by Record Producer
* Don't use `current.setValue('sys_class_name', 'xxx')` as this will trigger reparent flow and can cause data loss
* Avoid `current.setAbortAction()` and generate a separate record
* Use `producer.var1` to access variables
*/

var parserList = JSON.parse(producer.items_list);
gs.info('move information MRVS---'+parserList);
var addtable = new GlideRecord('x_pl4_move4u_item');

for(var i=0;i<parserList.length;i++){

addtable.name = parserList[i].name;
addtable.move_request = parserList[i].move_request;
addtable.is_fragile = parserList[i].is_fragile;
addtable.category = parserList[i].category;
addtable.short_description = parserList[i].short_description;
addtable.volume = parserList[i].volume;
addtable.insert();

}