Search code examples
adobeaemjcr

how to dynamically change a image in AEM forms workflow step


I need to load a image for jcr node in a form for assigned step workflow task. The image was uploaded in previous step is in payload.

/var/fd/dashboard/payload/server0/2018-11-27/3G76W5ICECE6PISS6ADU4IH24M_6/Attach/fileupload/file.jpg

I prefilled text's fields with XmlData but I can't do it with an image. What is the correct form to prefill this image component?


Solution

  • After many hours of tests, and some help by Adobe forum guys, I resolved this issue.

    The solution is provide a css class name to the the image component using the properties editor (like imgCNH), and, use this class name to set its src attribute using jquery.

    But, it's a little more. AEM Forms give a name setted to a DIV tag, not the IMG tag. By that, to try change the src for imgCNH failed.

    The trick is access the IMG tag below named DIV. I used this:

    CSS Class attribute: imgCNH (give a name to field)

    jquery code: $(".imgCNH, img").attr("src","/content/dam/foxfly/jean CNH.jpg");

    Explanation:

    .imgCNH - Select DIV named in by CSS Class atribute

    , img - Selet tag IMG below the DV

    I hope this help you.