- 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 03:38 AM
@vidhya_mouli you can try below code
current.u_employee=employeeGR.getDisplayValue('u_display_value');
Mark this as Helpful / Accept the Solution if this clears your issue.
Regards,
RJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 05:33 AM
Hi vidhya mouli,
Use current.u_employee for assigning that value with the display value of the record retrieved from glideRecord, however getDisplayValue with argument I believe is recommended for widget scripting, instead of that try this code below:
/** 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.getDisplayValue();
}
☆ Community Rising Star 22, 23 & 24 ☆
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 05:56 AM - edited 04-10-2023 06:50 AM
When I use current.u_employee, i get this warning:
ErrorUnique Key violation detected by database ((conn=3328) Duplicate entry '9508509c1b3121105a7f6464604bcb6b' for key 'PRIMARY')
However u_employee is neither unique not primary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 06:45 AM
Are you doing any update on any table? Is there any BR triggered in the same table where you are inserting record?
☆ Community Rising Star 22, 23 & 24 ☆