How to display a field of type Image on a widget?

Jordan Dehneh
Tera Expert

Hello,

I have a field of type 'Image' which can take an image. I want to display this image on a widget I have. I tried showing it on the widget but it gives me a sys_id instead. How can I show it ?

Thanks

1 ACCEPTED SOLUTION

Hello Anil,

 

No worries, I got it solved now. it should be

 

<img ng-src="{{::data.picture + '.iix'}}"/>

 

and in server script:

 

data.picture = grRec.getValue('u_image');

 

Thank you for the help Anil 🙂

View solution in original post

8 REPLIES 8

Ujjawal Vishnoi
Mega Sage

Hello Ujjawal,

I am trying to implement a list in the service portal. This list contains the list of all articles of category News. I want to show an image for each article. So in the list there will be rows and each row has an image. But when I display it, it gives me just the sys id even though the field Thumbnail has the image inserted/uploaded.

Thanks

Hi Jordan,

You can take a help of OOB widget 'SC Category Page'.

find_real_file.png

 

find_real_file.png

 

This widget has a logic to get All items details and display as list/card. You can implement same logic to display data and images as per your requirement.

 

 

Thanks,
Anil Lande

Also, You can take reference from below widget.

https://instanceName.service-now.com/sp_config?id=widget_editor&sys_id=6e6ac664d710120023c84f80de610...

 

They are using  below code

 <div class="sub-avatar mia" ng-style="avatarPicture">

and ng-style is being set in client script using below code.

$scope.avatarPicture = {
				'background-image': "url('" + response.sys_id + ".iix')",
				'color': 'transparent'
			};

 

Hope it helps.

Regards,

Ujjawal