- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2017 05:50 PM
I have a requirement to display a description, image and clickable url for the selected ergonomic keyboard. I have a catalog client script that uses glideAjax to get the description, image and url from the u_ergonomic_equipment table and sets the value of the macro field that uses the widget to "Item Description:\n" + answer.description + "\n\n\nItem Image:\n" + answer.image + "\n\n\nItem URL:\n" + answer.url
Since a UI Macro isn't available through the portal I'm going the widget route. I have a working rough draft using this code
Body HTML template:
<div>
{{ c.data.message }}
</div>
Client controller:
function($scope) {
var c = this;
//Watch for changes in the name variable
$scope.$watch(function () {
return $scope.page.g_form.getValue('ergo_keyboard_choice');
}, function (value) {
//Update local data object with data from variable
c.data.message = value ? value : '';
});
}
Which produces this:
Can anyone help me populate this HTML template instead?
<div>
<p><b>Description: </b><br>{item description here}</p>
<p><b>Image: </b><br>{item image here}</p>
<p><b>Link: </b><br>{item url here}</p>
</div>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 04:16 PM
With nathanfirth's guide as a starting point, I managed to figure it out. Here's my code in case it helps someone else in the future.
HTML:
<div>
<strong>Item Description:</strong><br />{{c.data.description}}<br />
</div>
<div align="center"><img src="{{c.data.image}}" width="75%" height="75%">
<br />
<br />
</div>
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var gr = new GlideRecord("u_ergonomic_equipment");
gr.addQuery("sys_id", input.message);
gr.query();
if (gr.next()) {
data.url = gr.getDisplayValue('u_link');
data.image = gr.getDisplayValue('u_image');
data.description = gr.getDisplayValue('u_item_description');
}
})();
Client Controller:
function($scope) {
var c = this;
//Watch for changes in the name variable
$scope.$watch(function () {
return $scope.page.g_form.getValue('ergo_keyboard_choice');
}, function (value) {
//Update local data object with data from variable
c.data.message = value;
c.server.update().then(function(response){
});
});
}
Pics of the finished product.
Before selecting an Ergo Keyboard:
And after selecting a keyboard:
Hope this helps someone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2018 10:43 AM
I tried doing this as well but my images aren't stored locally, they are just a URL listed on the table form, so if the vendor updates the image our image updates as well. I have c.data.url set as the source in the HTML but all I get is blank space. I know if I do a background script query using
getCurrent();
var currentVar;
var value;
function getCurrent() {
var gr = new GlideRecord('u_accessory');
gr.addQuery('sys_id', '319f8397dbf8eb8093deea42ca961933');
gr.query();
while(gr.next()) {
currentVar = gr.getValue('u_name');
gs.print("The name is " +gr.u_name);
gs.print(currentVar);
value = gr.u_image_link;
gs.print(value);
}
}
and insert the sys ID of the entry manually, the print does show it successfully grabs the URL.
Not sure why this isn't working at this point. If a URL works in the widget as a src, and I know it does, and if this query grabs the URL, I believe the code you posted should also successfully grab it. So I'm drawing a blank as to why this isn't working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2021 09:49 AM
After countless hours of searching this solved my issue, thank you!