How to set a value in a field from sc_item_option_mtom table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 06:39 AM
Hi,
Im trying to populated the field 'Return Date' from specific catalog item variable but the field is not populated.
What am I doing wrong?
var dt = new GlideRecord('sc_item_option_mtom');
dt.addEncodedQuery('request_item.number=' + current.request_item + '^sc_item_option.item_option_new=4a5677081b8a5510aeb37739cd4bcbeb')
dt.query();
if (dt.next()) {
dt.setValue('u_return_date', dt.getValue('Value'));
dt.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:16 AM
The condition
request_item.number=' + current.request_item
is wrong; that is the same as saying "where requested item number is the same as requested item sys_id".
It should be
request_item=' + current.request_item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:18 AM
but i did show matching and then copy query and this is what i got
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:20 AM
Well, truth be told, without knowing what "current" is, I'm really just guessing around. So just ignore me 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 07:25 AM - edited 01-09-2023 10:18 AM
Also the requirements are not clear: you state that
Im trying to populated the field 'Return Date' from specific catalog item variable but the field is not populated.
but where is field Return Date defined?
Is it really added to table sc_item_option_mtom (which makes no sense to me), or do you in fact mean
if (dt.next()) {
current.setValue('u_return_date', dt.getValue('value'));
current.update();
}
in which case the question is: where is this run, why current.update()?