Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

String[] type for Multivalued Properties - AEM

MeenakshiP
Level 3
Level 3

[Thread Edited By Adobe]

/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here

Go ahead and to it now: https://adobe.ly/3eDnB4v */

 

Actual Post:

Hi,

I have a question regarding multivalued property of type granite/ui/components/foundation/form/multifield in AEM.
My understanding is that it will always be stored in AEM with String[] Multi Array type for a given node's property, no matter if user provides 1 or greater than 1 property values.

But I have observed that some values are getting stored with Single String data type if I provide one value And stored as String[] multi value type in crxde, if I enter more than 1 values.

Why AEM does not store all values in unique way? i.e. By setting data type as; String[] multi value, if it's sling:resourceType is defined as multifield.

Is it a defect?

Thanks.

desktop_exl_promo_600x100_weempoweryou.png

24 Replies
kautuk_sahni
Employee
Employee

Let me check this with internal team.

~kautuk

Nupur_Jain
Community Advisor
Community Advisor

I Don't know whether it is a defect or implementation but have observed the same.

Thanks,

Nupur

kautuk_sahni
Employee
Employee

I would request you to please share your observation with daycare till i get response from internal team.

~kautuk

Veena_Vikraman
Level 2
Level 2

Hi Meenakshi

     For xtype like multifield, if you are saving only 1 value in property, it will get saved as String. This behavior is there from the beginning itself, (I have started from  5.4  )

Thanks

Veena

leeasling
Level 8
Level 8

You need to set the typeHint in the dialog

typeHint="String"

This will save the value as a String[] regardless of 1 or multiple values.

MeenakshiP
Level 3
Level 3

Thanks. Is there any property key to define directly at node level in crxde to set it as always String and overriding default current behavior?

I tried typeHint as property key but that did not work.

leeasling
Level 8
Level 8

Delete the property that is currently just a "String" and then try again (this my answer was for classic UI).  For Touch UI, use this:

<myFieldString jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden" name="./myField@TypeHint" value="String"/>
MeenakshiP
Level 3
Level 3

I did not get you. I need to show this as one of the metadata for asset.

This is my current property configuration:

<keywords jcr:primaryType="nt:unstructured"
                                    sling:resourceType="granite/ui/components/foundation/form/multifield"
                                    fieldLabel="Keywords"
                                    metaType="mvtext"
                                    name="./jcr:content/metadata/dc:subject"
                                    renderReadOnly="true">
                                    <field
                                        jcr:primaryType="nt:unstructured"
                                        sling:resourceType="granite/ui/components/foundation/form/textfield"
                                        name="./jcr:content/metadata/dc:subject"/>
                                </keywords>

leeasling
Level 8
Level 8

Try adding this to the dialog as a new field:

<keywordsString jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden" name="./jcr:content/metadata/dc:subject@TypeHint" value="String"/>
MeenakshiP
Level 3
Level 3

It does not work. I have been trying to add it to schemaeditor under /apps/dam/content/schemaeditors/forms/x/items/tabs/items/tab1/items/col1/items

tc94524330
Level 4
Level 4

Did you got solution for this?

I am facing similar issue.

Any help would be great.

Thanks

MeenakshiP
Level 3
Level 3

I used my own logic to handle single and multi-value string in the code. Can you please give more details about your problem?

Thanks,

Meenakshi

leeasling
Level 8
Level 8

Easiest way to handle it is as follows:

String[] value = properties.get("propertyName", new String[] {});

This will create a string array regardless of 1 or multiple string values, regardless of String or String[] type.

230486sr
Level 1
Level 1

Can you tell me which approach are you referring here ?

viveksachdeva
Level 7
Level 7

String[] value = properties.get("propertyName", new String[] {});

230486sr
Level 1
Level 1

I need to achieve this in metadata schema . So i doubt if this can be used.

viveksachdeva
Level 7
Level 7

I believe this will help you get values in an array in all cases.. If you want to save it in JCR as an array(in case of single value as well), this is not the one..

230486sr
Level 1
Level 1

I am not sure whether you got the issue right.

I have the dc:subject value coming in as Array , but i want to save the values in the textfield as a single string. I don't want to use the multi value field , but instead convert the string[] as a string and save it .