- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 03:28 AM - edited 04-10-2023 03:31 AM
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');
}
u_employee is blank when I submit the form. What am I doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 06:56 AM
I was able to solve this issue by using sysid instead of display value in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 09:45 AM - edited 04-10-2023 09:46 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 06:46 AM
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?
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 06:56 AM
I was able to solve this issue by using sysid instead of display value in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2023 03:01 AM
Any update?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:09 AM
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;
}
☆ Community Rising Star 22, 23 & 24 ☆