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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Fetch dialog property value in js in AEM

Avatar

Community Advisor

Hi,

I've a dialog selection box. What I need to check if the default value I've provided using  the property defaultValue and value I'll get from the selection box are equal or not!

So, to get selected value, we can get like this : 

function(dialog){ var selection = dialog.getField("<property name>"); var selectedValue = selection.value; }

Now, how can I get value in java script using the defaultValue property as name?

 

Thanks,

Himanshu

2 Replies

Avatar

Level 9

Try using function getValue(). you should be able to get that.

  1. var selValue = dialog.getField("<property name>").getValue();
  2.  

Avatar

Community Advisor

get path till your dialog nodes
i.e. path = /apps/../items/<property name>/defaultValue.infinity.json
and from this Json you can get the default value.
sample snippet
 

var infinityjson = CQ.HTTP.noCaching(CQ.HTTP.getPath()+<property name>+'/defaultValue.infinity.json'); var infinityjsonObject = CQ.HTTP.eval(infinityjson); var defValue = infinityjsonObject.defaultValue;