Dynamically get image into the page

kavyahv
Kilo Contributor

Hi Everyone,

Im unable to   get the image dynamically onto the page.How can I do it in servcienow?

your suggestions will be helful

Regards,

1 ACCEPTED SOLUTION

Hi Kavya,



see below example..


i have one field of type of Image in one table.


find_real_file.png




now i want to display those images to the dynamic block.



so i have added a dynamic block to one page. and wrote below content.


<g:evaluate>    
  var images=[];
var gr = new GlideRecord('x_11777_crappy_app_crappy_appppp_table');  
gr.query();  
while(gr.next()){

images.push(gr.photo.getDisplayValue());


}

      </g:evaluate>  


   


      <j:forEach items="${images}" var="jvar_color">  


              <g:breakpoint/>  


              <img id="${jvar_color}" src="${jvar_color}"></img>


      </j:forEach>



so it will display images like shown below. and they will have different Id so u can use Jquery and reference them in your script.



Capture.JPG



Let me know if u have Questions.




(please mark helpful/correct/like if it helps)




Regards,


Rushit Patel


View solution in original post

8 REPLIES 8

Hi Kavya,



are these images stored in some table? like on field type image?


Hi Rushit,



Yes I have stored the image in table.


Hi Kavya,



see below example..


i have one field of type of Image in one table.


find_real_file.png




now i want to display those images to the dynamic block.



so i have added a dynamic block to one page. and wrote below content.


<g:evaluate>    
  var images=[];
var gr = new GlideRecord('x_11777_crappy_app_crappy_appppp_table');  
gr.query();  
while(gr.next()){

images.push(gr.photo.getDisplayValue());


}

      </g:evaluate>  


   


      <j:forEach items="${images}" var="jvar_color">  


              <g:breakpoint/>  


              <img id="${jvar_color}" src="${jvar_color}"></img>


      </j:forEach>



so it will display images like shown below. and they will have different Id so u can use Jquery and reference them in your script.



Capture.JPG



Let me know if u have Questions.




(please mark helpful/correct/like if it helps)




Regards,


Rushit Patel


Thanks Rushit and it works!