Reference field value not visible in form and showing 'No preview available' when clicked on info icon

Preethiga1
Tera Contributor

Hi,

Assignment group field is updated in background script (PFB) , but value is not displaying in form as well as in list view. But if I tried to update assigned to field using similar script(d.assigned_to='XXXX') it works fine. I can use setDisplayValue() in below script to make it work for group, but I just need to know why assigned to filed got updated correctly and not group field? what is the difference between these fields referencing to user/group table? Note: Even I checked both dictionary override fields, there is no much difference. Also, no field in user/group table is marked as display true and value we are trying to update in group field is available in instance.

find_real_file.png

find_real_file.png

Background Script Used:

var d= new GlideRecord('incident');
d.addEncodedQuery('numberSTARTSWITHXXXXXXXXXX');
d.query();
gs.print(d.getRowCount());
if(d.next()){
d.assignment_group='cross platform';
d.update();
}

18 REPLIES 18

Mahesh Kumar3
Giga Guru
Giga Guru

It mean you are trying to set a value to reference field which is invalid.

Modify your code like mentioned below and then test:

var d= new GlideRecord('incident');
d.addEncodedQuery('numberSTARTSWITHXXXXXXXXXX');
d.query();
gs.print(d.getRowCount());
if(d.next()){
d.setDisplayValue('assignment_group','cross platform');
d.update();
}

 

This should work.

The difference is than any reference field will take sys_id if you are setting the value directly.

setDisplayValue works fine when you provide correct display value.

the line which you have written in code:

d.assignment_group='cross platform';

will never work, because this format needs sys_id and not display value

d.assignment_group='sys_id of the group';

Thanks for your reply Mahesh. Above code works good.

I also like to know, how assigned to field got updated using 'assigned_to='XXXX' script this is also reference field. 

It works the same way:

'assigned_to='XXXX' might have worked because 'XXXX' must be the sys id.

if you put gr.assigned_to == 'not a sys id' then it will not work.

 

Please mark your response accordingly if it really helped you.

 

Regards,

Mahesh Kumar