Display reference field value into string fields

Kishore8
Kilo Guru

My script is not working:

var one = current.u_group.getDisplayValue();

var gr=new GlideRecord('sysapproval_approver');

gr.addQuery('document_id', current.sys_id);

gr.query();

if(gr.next())

{

gr.u_kb_group=one;

gr.update();

}

find_real_file.png

25 REPLIES 25

Rajesh Mushke
Mega Sage
Mega Sage

try like this,



  1. var gr = new GlideRecord('sysapproval_approver');  
  2. gr.query();  
  3.  
  4. while (gr.next())    
  5. {  
  6. var kbgrp = gr.getDisplayValue('referencefieldname'); //Get the current Reference value /
  7. gr.setValue('stringfieldname', kbgrp); // Set the value of the string.  
  8. gr.update();   //Save it  
  9. }  


Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

Hi,



I think it is not working.



U_group(reference)   field is available in KB table record.



And u_kb_group (string) field is available in Approver table record....



As per your script-you   have taken two fields from approver table


dhasselquist
Mega Guru

D Kishore,



Can you provide more information about this (what I assume is a business rule) script?



Have you tried putting in some logging statements to see if your code is being fired, or where it is failing?


It is firing, but sometimes, Otis not




Means if we have 5approvers in one KB record, value it is reflected only to 2 or 3 approver records, in reaming 2 records group name is not reflected.



That is the issue.