how to get display value?

Kiddy1
Tera Contributor

explorenow srinivasthelu Developer Community

var fake=current.u_fake;

var fake2='op'+fake.getDisplayValue();

is this correct?

19 REPLIES 19

Try this



      var fake = current.u_fake.getDisplayValue()


Sharique Azim
Mega Sage

Hi,



The code would not work if its used in client script,



then use:



g_form.getDisplayBox('field_name').value ; //the field needs to be a reference field..


Shamma Negi
Kilo Sage
Kilo Sage

In Server side script as current can only be used in Server Side Script:



var fake2='op'+current,u_fake.getDisplayValue();



Try to use gs.log(current,u_fake.getDisplayValue()) and see what value it is returning in order to proceed further.



Regards,


Shamma


Regards,Shamma Negi

Harsh Vardhan
Giga Patron

there are multiple ways to get the reference field value.



  • var fake2 = 'op' + ' ' +current.getDisplayValue('u_fake');
  • var fake2 = 'op' + ' ' +current.u_fake.getDisplayValue();


both will work



9.4 getDisplayValue

public String getDisplayValue()


Retrieves the display value for the current record.
Returns:
String - a string display value for the current record.
Example:
// list will contain a series of display values separated by a comma // array will be a javascript array of display values 
var list = current.watch_list.getDisplayValue();
var array = list.split(",");
for (var i=0; i < array.length; i++)
{
gs.print("Display value is: " + array[i]);
}


jiu
Kilo Contributor

Hi, 

I just wanted to print the incident number value by using UI action (server side)

var gr = new GlideRecord('incident');
gr.get('74e44b57db6c23009cf817803996191e'); // sys_id

current.getDisplayValue('number');

 

can any one help me in display the same 

 

thanks in advance