What does [object GlideRecord] mean when i am using gs.info to see the output ?

SK41
Giga Guru

Hi,

I have a  requirement where i have  to display message  based on the value(0-9) that user gives in a survey. There is out of   the box script include SPSurveyAPI which is used.           

find_real_file.png 

in line 683 getMessages(gr) what  value comes in (gr)? I used  gs.info()    it gives output as [object GlideRecord].

What  does this  output  mean?   

Also , how can i get  to display different msgs based on the ratin users give in survey?

Suppose,user rate us 4 which is a low value so i need to display a message and if user give say 8 which is high then a different msg to be displayed. These values that users give for surveys taken are stored in   asmt_assessment_instance_question table.                 

Please help me in this regard.

Thanks                           

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

it is a gliderecord object of some table

if you directly print it it would show you object

but you can print the fields within that record using gr.fieldName

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

asifnoor
Kilo Patron

Hi

gr is a gliderecord object which is referring to a specific table and passed that object to your function getMessages.

To access values in your table and to know the table name, try liek this

gs.info("Table name is "+gr.getTableName());

gs.info("Field value is "+gr.your_field_name); //put right field name based on the table.

hi, 

used  gs.info("Table name is "+gr.getTableName()); and  got  asmt_assessment_instance as  table here.  I  want  to  display  different msgs  based  on  the  rating u ser  gives.So,   i  added below  code for  that but  i  am  getting  nps  value(user rating)  as 0      everytime. The  user's responses  for  the survey are stored  in  asmt_assessment_instance_question table.

function getMessages(gr) {
gs.info("gr is" +gr);
gs.info("Table name is "+gr.getTableName());
var instanceDueDate = gr.getDisplayValue('due_date');
var messagesMap = {};
var evaluationMethodDisplay = gr.getDisplayValue('metric_type.evaluation_method');
gs.info("evaluation" +evaluationMethodDisplay);
var title = surveyGR.getDisplayValue('metric_type') + '';
gs.info("metric"+gr.metric_type);
gs.info("title"+title);
var ar = new GlideRecord('asmt_assessment_instance_question');
gs.info("in table");
var c=ar.addEncodedQuery('metric.name=NPS');                                   //getting undefined in logs
gs.info("encoded query"+c);
var a= ar.addQuery('instance.number', gr.number);                              //getting undefined in logs
gs.info("instance"+a);
ar.query();
gs.info("in query");
if (ar.next()) {
var nps = ar.value;
gs.info("nps value"+nps);
}
gs.info("outside if");
if(nps>5)
{
messagesMap.submitted_msg = gs.getMessage('We really appreciate you taking the time to provide us with your feedback. Thank you!',evaluationMethodDisplay);
}

else{

messagesMap.submitted_msg = gs.getMessage('We  hope  to  get better. Thank you!',evaluationMethodDisplay);

}

 

PLease  help  me in  achieving  this  requirement.

Thnanks.

Hi,

Why are you checking the output of addQuery logs?

put this log

gs.info("in table "+gr.number); //fetch the number and then go to to asmt_assessment_instance_question and filter by this number and check the value of nPS.