Tag field migration issue | Community
Skip to main content
Level 3
August 12, 2024

Tag field migration issue

  • August 12, 2024
  • 3 replies
  • 806 views

we have tag cq/gui/components/coral/common/form/tagfield.
it was created to select only one field. now its a requirement to change to select multi.

Issue is already existing selected tags.

how to migrate crx content which is stored as single field as string to string array (string[]) ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Harwinder-singh
Community Advisor
Community Advisor
August 12, 2024

@sudarshanv1 No need to change the resourcetype TYPE to String[].

Just add this property in the node.

propertyName - multiple

PropertyType - Boolean

PropertyValue - True.

 

This will allow the tags field to accept multiple tag values.

Level 3
August 13, 2024

The issue is, how to migrate already stored values? we are not worried about conversion from single to multi.

Level 4
August 13, 2024

Hi Sudarshan,

If i understood correctly, you need to update already created content.

you shall use AEM fiddle script. Please refer below post - 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/update-the-tags-in-component-when-tags-are-moved-in-aem-content/m-p/694391#M172593

 

Thanks,

Raju. 

narendiran_ravi
Level 6
August 13, 2024

You can create a Groovy script to update the existing property type to string[]. 

 

if (property.isMultiple()) { println "Property already a String[] at ${node.path}" } else { def value = property.getString() def newValues = [value] as String[] // Convert the single value to a String array node.setProperty(propertyName, newValues) println "Updated property at ${node.path} from String to String[]" }

 You may need to remove the property first after reading the value and set again as we are updating the type from String to String[]