How can I update multi valued property using groovy | Community
Skip to main content
Level 6
January 9, 2023
Solved

How can I update multi valued property using groovy

  • January 9, 2023
  • 1 reply
  • 1692 views

How can I update multi valued property using groovy, ex: cq:rolloutConfig is of String[] and i want to add values to this field using groovy.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

Hi @shaheena_sheikh,

In groovy you can use code like this:

Property property = node.getProperty("cq:rolloutConfig") if (property?.isMultiple()) { String [] values = property?.getValues() as String [] if(values) { values += "new value" node?.setProperty("cq:rolloutConfig", values) save() } }

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
January 9, 2023

Hi @shaheena_sheikh,

In groovy you can use code like this:

Property property = node.getProperty("cq:rolloutConfig") if (property?.isMultiple()) { String [] values = property?.getValues() as String [] if(values) { values += "new value" node?.setProperty("cq:rolloutConfig", values) save() } }