The CreatorCon Call for Content is officially open! Get started here.

Record Producer

vidhya_mouli
Giga Sage

I have a record procedure with some variables. I have added this record producer to my service portal using a widget. When i submit this form, all the fields gets updates as expected except for one field u_employee.

 

This is the  my script in the record producer:

 

/** 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 userID = gs.getUserID();
var employeeGR = new GlideRecord("u_employee_sv");
employeeGR.addQuery('u_reference_1',userID);
employeeGR.query();


if(employeeGR.next()){
	gs.addInfoMessage('INSIDE0: '+employeeGR.getDisplayValue('u_display_value'));
	gs.addInfoMessage('INSIDE1: '+employeeGR.getValue('u_display_value'));
	u_employee = employeeGR.getDisplayValue('u_display_value');

}

 

 

SN.png

u_employee is blank when I submit the form. What am I doing wrong?

1 ACCEPTED SOLUTION

I was able to solve this issue by using sysid instead of display value in the script. 

View solution in original post

9 REPLIES 9

Yes, I am trying to insert a new record in the table u_manager_activities_sv. It has a filed u_employee (which is not unique in this table), which is a reference filed to u_employee_sv table (where this value is unique). When I try to create a record in u_manager_activities_sv table it shows me the warning. It does enter values in all the other file but leaves u_employee field empty. 

I assume that the RP is creating that record in 'u_manager_activies_sv'. I don't understand what you mean when you say 'which is not unique in this table', do you refer that you have more than one field referring to that employee table, don't you?

Please, check the logs if the script is going inside of that if branch, and apart from that, if you assign directly an id for that fields, does this warning still appearing?

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

I was able to solve this issue by using sysid instead of display value in the script. 

BonnieBurgos
Giga Contributor

Any update?

Hi Bonnie, 
The solution was marked for using sys_id instead of getDisplayValue in the code that it's at the top of the page, should be something like this: 

/** 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 userID = gs.getUserID();
var employeeGR = new GlideRecord("u_employee_sv");
employeeGR.addQuery('u_reference_1',userID);
employeeGR.query();

if(employeeGR.next()){
	current.u_employee = employeeGR.sys_id;
}
If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆