How to get field value from g_from.getValue() instead of sys_id?

mdrafi
Mega Expert

I need to set value to the field 'u_reserved_by'. Please help me how to get field value instead of sys_id for the below highlighted statement.

function onSubmit() {

  g_form.setValue('approval', "Approved");

  g_form.setValue('u_status', "Reserved");

  var seatGR = new GlideRecord("u_all_seats");

  seatGR.addQuery("sys_id", g_form.getValue('u_seat_number'));

  seatGR.query();

  while(seatGR.next())

  {

  seatGR.u_availability = "Reserved";

seatGR.u_reserved_by = g_form.getValue('u_name');

  seatGR.update();

  }

}

1 ACCEPTED SOLUTION

swati38
Tera Expert

You can use g_form.getDisplayValue('field name') or g_form.getDisplayBox('field name').value; to get the value of the field.



I prefer using g_form.getReference() method.


Kindly refer to the below code:


function onLoad() {


var b= g_form.getReference('requested_by',fan);


}


function fan(b)


{


var name=b.user_name;


alert(name);


  }


the name captures the value of the field


View solution in original post

11 REPLIES 11

Can you let me know how this can be achieved for Date type field.



seatGR.u_reserved_by = g_form.getDisplayBox('u_reservation_from').value;



'u_reserved_from'   and 'u_reservation_from'   are Date/Time type values.


This is very help full to me swatisai.. Thanks..

Harish Murikina
Tera Guru

Hi Rafi,



Here is the method.



alert(g_form.getDisplayBox('request').value); // Here request is your refernce variable name.



Regards,


Harish Murikinati.


Thanks Harish,



Can you let me know how this can be achieved for Date type field.



seatGR.u_reserved_by = g_form.getDisplayBox('u_reservation_from').value;



'u_reserved_from   and 'u_reservation_from'   are Date/Time type values.


Hi Rafi,



getDisplayBox for reference field to get display value instead of sys id.



To get other values g_form.getValue('ur variable name'),


Regards,


Harish Murikinati.