Get picture from picture field on a form though a script

xif1
Mega Expert

Hello,

I added a field type : image

like this :

Capture d

It's available on some other part of service now, like to upload the logo.

I would like to get this value.

My need:

I built a widget show some data, and I want to retrieve the picture attached to the record to show it on service portal

Anyone i've done this before ?

8 REPLIES 8

amadosierra
Kilo Guru

Hi xif,



I had the same question and just found out the solution. In your widget's server-side script you need to grab the image name by using getDisplayValue. Here's an example:



var gr = new GlideRecord('sc_cat_item');


if (gr.get('04b7e94b4f7b4200086eeed18110c7fd')) {


        data.name = gr.getValue('name');


        data.picture = gr.getDisplayValue('picture');


}



Then in your widget's HTML:


<img class="img-responsive catalog-item-image" alt="{{::data.name}}" style="display: inline" ng-src="{{::data.picture}}" />



Calling getValue returns nothing, getDisplayValue returns the image file name (e.g. b28db9444f889200086eeed18110c724.iix )



Regards,



Amado


Thanks for posting this.  Saved me a lot of time!

 

Mike

That should be marked as the correct answer. Thanks!

Hello Amado,

How can I fetch the image from custom table to Multi row variable set(MRVS) form?

Let me explain the scenario. I have created custom table which stores Stationery items with images.

And have created MRVS which fetch data from custom table here I want to show respective Image when we select stationery item.

Can you please help?

Thanks in Advance

Monika

 

find_real_file.png