- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2022 08:54 PM
In my record producer , I load values from a previously created record based on user selection so they can use the record producer to update those values . I have an attachment field called u_assigned_lead, on submit I would like to update this field on the record to whatever the user attached . Every other field is updated correctly , except the file attachment . This is the script that I'm currently using:
var record = current.u_select_review_1_strategic_alignment;
var review = new GlideRecord('u_earb');
review.addQuery('sys_id', record);
review.query();
//if we find a record update it
if (review.next()) {
review.u_intake_demand_number = current.u_intake_demand_number;
review.u_assigned_lead = current.u_assigned_lead;
review.update();
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2022 03:27 AM
It's necessary to query the sys_attachment table to get the sys_id of the attached file.
var grAttach = new GlideRecord('sys_attachment');
grAttach.addQuery('table_name', '<u_table name>'); // table name is producer. 'ZZ_YY' prefix implies attachment field name so don't use to get attachment to the form
grAttach.addQuery('table_sys_id', current.sys_id);
grAttach.query();
if(grAttach.next()){
review.u_intake_demand_number = current.u_intake_demand_number;
review.u_assigned_lead = grAttach.sys_id; // set attachment field to attachment to form
review.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2022 01:04 AM
Hi Mike,
Attachments are tracked in different way when we attach to a field in ServiceNow.
Say for example i have an attachment field in ServiceNow Incident table called "attach_here" it will be stored in ServiceNow Attachment table with table name as "ZZ_YYattach_here" and the sys_id of the record you are submitting.
Before you do any sort of linkage just visit the sys_attachment table and see how it was stored, and kindly update the reference in "sys_attachment" table by writing a business rule on the table your Record Producer is used for.
Thanks
Sreeharsha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2022 03:27 AM
It's necessary to query the sys_attachment table to get the sys_id of the attached file.
var grAttach = new GlideRecord('sys_attachment');
grAttach.addQuery('table_name', '<u_table name>'); // table name is producer. 'ZZ_YY' prefix implies attachment field name so don't use to get attachment to the form
grAttach.addQuery('table_sys_id', current.sys_id);
grAttach.query();
if(grAttach.next()){
review.u_intake_demand_number = current.u_intake_demand_number;
review.u_assigned_lead = grAttach.sys_id; // set attachment field to attachment to form
review.update();
}