Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Widget Data Object Not Displaying Results

Ashley
Mega Sage

Good Evening,

 

I have a really odd problem, assigning some text to a data object but it won't display correctly on the html template.

Server Side:

 

var config = new GlideRecord(gs.getProperty('table'));
config.addQuery('number', 'LIKE', data.parent_configuration);
config.query();
if(config.next()) {
	data.desc2 = config.description;	
}

 

 Html:

 

 <div ng-if="data.show_desc == 'true'">{{data.desc2}}</div>

 

Result:

Ashley_0-1666896804523.png

Result is an empty Object but when I check the logs, I can see its being picked up correctly:

Ashley_1-1666896878350.png

Not sure what I am doing wrong... sigh

Any Ideas?

Kind Regards

Ashley

1 ACCEPTED SOLUTION

Ashley
Mega Sage

Good Afternoon,

Thank you all for the replies, I managed to resolve it, a few hours lost and all I needed to do was add .toString() on the end.... doh

 

End Result:

data.desc2 = config2.description.toString();

Kind Regards

 

Ashley

View solution in original post

5 REPLIES 5

Jan Cernocky
Tera Guru

Try one of these

{{::data.desc2}}
{{::c.data.desc2}}

 

Good Morning,

Thank you for the reply, gave it a go and didn't work for me.

Ashley_0-1666942295544.png

This is a scoped application as a side note, shouldn't make a difference.

Kind Regards

Ashley

Not applicable

Try JSON.stringify() on return from server.

Good Morning,

I think this is what you meant: 

data.desc2 = JSON.stringify(config2.description);

I gave it a go and the gs.logs were empty afterwards so I didn't get any results.

Kind Regards

Ashley