Expand my Community achievements bar.

Tag field migration issue

Avatar

Level 2

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[]) ?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies

Avatar

Community Advisor

@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.

Avatar

Level 2

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

Avatar

Level 4

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-compone...

 

Thanks,

Raju. 

Avatar

Level 5

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[]