- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 08:43 AM
I would like to update a reference field but the value is not getting saved. Here md5hash is a reference field. And the value which I m assigning is not a sysid but it's the actual MD5hash value of sample file. Reference is not getting added to the table. I tried updating other columns inside the while loop and it works fine.
I tried few other things but nothing worked
- macFileNameRec.md5hash='sysid'
- macFileNameRec.md5hash.setDisplayValue(''4E93C1EA01B65497AEB9BA0C7F7457AA');
var macFileNameRec=new GlideRecord('x_opt_macro_govern_macro_file_names');
macFileNameRec.addQuery('file_name',fileName);
macFileNameRec.query();
if(macFileNameRec.hasNext()){
while(macFileNameRec.next()){
macFileNameRec.md5hash='4E93C1EA01B65497AEB9BA0C7F7457AA';
macFileNameRec.update();
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 08:22 PM
Is md5hash field referencing a table?
If yes, you can query the table and then assign the sys_id to the reference field. Something like this.
var macFileNameRec=new GlideRecord('x_opt_macro_govern_macro_file_names');
macFileNameRec.addQuery('file_name',fileName);
macFileNameRec.query();
if(macFileNameRec.hasNext()){
while(macFileNameRec.next()){
var md = new GlideRecord('md5 table name');
md.addQuery('field value','4E93C1EA01B65497AEB9BA0C7F7457AA');
md.query();
if (md.next())
{
macFileNameRec.md5hash=md.sys_id;
macFileNameRec.update();
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 08:52 AM
Hello Kailash,
Try with macFileNameRec.setDisplayValue('md5hash', '4E93C1EA01B65497AEB9BA0C7F7457AA'); //Assuming 4E93C1EA01B65497AEB9BA0C7F7457AA refers to the field display value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 09:36 AM
It sounds like setDisplayValue s not allowed in custom scope. its not working
Function setDisplayValue is not allowed in scope x_opt_macro_govern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 10:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2018 02:00 PM
Any help?