Change image dynamically

I have the requirement where i need to change the image in card layout dynamically.

Can someone help

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to Som

    Hope the below code works for your requirement. This code also changes the image randomly on every 30 seconds without user interaction.

    a!localVariables(
      local!images: {
        "BOOK",
        "BUILDING",
        "BRIEFCASE",
        "AIRPLANE"
      },
      local!index: a!refreshVariable(
        value: charat(rand(1), 3),
        refreshInterval: 0.5
      ),
      local!selectedImage: local!images[if(local!index > 4, 1, local!index)],
      a!cardLayout(
        contents: {
          a!billboardLayout(
            backgroundMedia: a!documentImage(
              document: a!iconNewsEvent(icon: local!selectedImage)
            ),
            backgroundColor: "#f0f0f0",
            marginBelow: "NONE",
            overlay: a!barOverlay(
              contents: {
                a!imageField(
                  align: "CENTER",
                  images: {
                    a!forEach(
                      items: local!images,
                      expression: a!documentImage(
                        document: if(
                          local!selectedImage = fv!item,
                          a!iconIndicator("HARVEY_100"),
                          a!iconIndicator("HARVEY_0")
                        ),
                        link: a!dynamicLink(
                          saveInto: {
                            a!save(
                              local!selectedImage,
                              local!images[fv!index]
                            )
                          }
                        )
                      )
                    )
                  },
                  size: "ICON"
                )
              }
            )
          )
        }
      )
    )

Children