Is there a OOTB way to fetch values of dialog fields in the same dialog xml? | Community
Skip to main content
pulkitvashisth
Community Advisor
Community Advisor
January 18, 2024
Solved

Is there a OOTB way to fetch values of dialog fields in the same dialog xml?

  • January 18, 2024
  • 2 replies
  • 1133 views

In the component cq:dialog, I want to fetch the value of a dropdown field and store it into another dialog field node.
For example : 

<content-type jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/select" fieldDescription="Content Type for content" name="./jcr:content/metadata/content-type" multiple="{Boolean}true" granite:id="seeAlso" fieldLabel="Content Type"> <datasource jcr:primaryType="nt:unstructured" sling:resourceType="project/utilities/dialog/datasource" dataType="content-type" sort="{Boolean}true" path="/content/project/global/reference-data/metadata/content-type"/> </content-type> <usedIn-container granite:id="seeAlso" jcr:primaryType="nt:unstructured" jcr:title="Select to include" sling:resourceType="granite/ui/components/coral/foundation/form/fieldset" bottomDescription="select as required"> <items jcr:primaryType="nt:unstructured"> <header jcr:primaryType="nt:unstructured" sling:resourceType="project/components/commons/see-also/note" note="Title|Content ID|Topic Path|Last Published Date"/> <used-in jcr:primaryType="nt:unstructured" sling:resourceType="dam/gui/components/admin/schemafield" fieldLabel="Used In" name="./jcr:content/metadata/usedIn" contentType=*here I want to store value of above content type dropdown* resourceType="project/components/commons/see-also/checkboxgroup"> <datasource jcr:primaryType="nt:unstructured" sling:resourceType="/bin/project/getTopicReferences"/> </used-in> </items> </usedIn-container>


In above component xml, I want to store value of dropdown content-type in used-in node.

I want to know if there exists an OOTB way to do this within the xml.

I am not looking for solutions via javascript.

 

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 arunpatidar

You need to try like below

 

Field from where the value needs to be copied


Field where the value needs to be copied

 

corresponding hidden field for @valueFrom

 

After saving the dialog

 


opening the dialog

 

 

2 replies

Kamal_Kishor
Community Advisor
Community Advisor
January 18, 2024
pulkitvashisth
Community Advisor
Community Advisor
January 18, 2024

@kamal_kishor  I checked with @ValueFrom
But it doesn't seem to work.
Below is the code for the same.

 

<used-in jcr:primaryType="nt:unstructured" sling:resourceType="dam/gui/components/admin/schemafield" fieldLabel="Used In" name="./jcr:content/metadata/usedIn" contentType="./jcr:content/metadata/contentType@ValueFrom" resourceType="project/components/commons/see-also/checkboxgroup"> <datasource jcr:primaryType="nt:unstructured" sling:resourceType="/bin/project/getTopicReferences"/> </used-in>

 


I also tried with 

contentType="jcr:content/metadata/contentType@ValueFrom"
But this doesn't work as well.
Can you tell if I am doing something wrong?

 

Kamal_Kishor
Community Advisor
Community Advisor
January 18, 2024

@pulkitvashisth : @ValueFrom has to be applied in name field.

 

Something like this for example: <field1 ..... fieldLabel="Field 1" name="./field1"/> <field2 ..... name="./field2@ValueFrom" value="./field1" defaultValue="./field1"/> This will store the value from 'field1' in 'field2' when you save the component dialog. You can try with simple textfield first to see that it works. Later you can try it with drop-down field values. Also, don't skip the defaultValue as that seems to be required (you can try with and without it to see quickly).

 

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 18, 2024

No, there is no out-of-the-box way to do that as far as i know (i might be wrong).

All the information from the dialog is only available in the FrontEnd until you submit it. After this, the information gets stored in nodes. So, if you need to use the data which is not yet stored in JCR, you need to use JavaScript to accommodate your other dialogs' components.

This approach is usually used to hide/show other elements or to populate other dropdowns. You can check references here:

Hope this helps.

Esteban Bustamante