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
BedrockMission!

Learn More

View all

Sign in to view all badges

ID for a field in multified

Avatar

Avatar
Applaud 25
Level 2
Shaheena_Sheikh
Level 2

Likes

2 likes

Total Posts

96 posts

Correct Reply

1 solution
Top badges earned
Applaud 25
Applaud 5
Affirm 1
Validate 10
Validate 1
View profile

Avatar
Applaud 25
Level 2
Shaheena_Sheikh
Level 2

Likes

2 likes

Total Posts

96 posts

Correct Reply

1 solution
Top badges earned
Applaud 25
Applaud 5
Affirm 1
Validate 10
Validate 1
View profile
Shaheena_Sheikh
Level 2

16-03-2021

I have a textfield within a multified. I need to fetch the ID for the textfield each item a new multified item is added. Since the textfield is within the multified I am not sure how can i set the granite:id to it. Any suggestion?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
Level 4
Rohit_Utreja
Level 4

Likes

44 likes

Total Posts

45 posts

Correct Reply

15 solutions
Top badges earned
Establish
Give Back 3
Give Back
Boost 5
Boost 3
View profile

Avatar
Establish
Level 4
Rohit_Utreja
Level 4

Likes

44 likes

Total Posts

45 posts

Correct Reply

15 solutions
Top badges earned
Establish
Give Back 3
Give Back
Boost 5
Boost 3
View profile
Rohit_Utreja
Level 4

16-03-2021

@Shaheena_Sheikh ,

 

You can try to iterate the textfield inside the multifield using clientlibs javascript.

These Ids will be generated by granite UI and can be iterated through the code.

 

Adding a sample code to fetch values from dialogs using JS.

 

https://github.com/viji13/aemlearnings/blob/master/clientlibs/script.js

 

Answers (2)

Answers (2)

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

274 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

274 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

16-03-2021

@Shaheena_Sheikh 

ID must be unique, if you have text field with id(granite:id) in side multifield, there will be multiple elements with same id. You will always get the first element.

So use class(granite:class) instead and get the last element(selector text-field-class:last) of that class when new item is added. 

Example:

Add class(granite:class) to id text field (here I am using id-text-field). Try below code to get each text field value inside multifield.

$(".coral3-Multifield-item").each(function( index ) {
	console.log($(this).find(".id-text-field").val());
});

 

Avatar

Avatar
Springboard
Level 7
KiranVedantam1992
Level 7

Likes

169 likes

Total Posts

175 posts

Correct Reply

54 solutions
Top badges earned
Springboard
Give Back 5
Ignite 1
Affirm 50
Validate 1
View profile

Avatar
Springboard
Level 7
KiranVedantam1992
Level 7

Likes

169 likes

Total Posts

175 posts

Correct Reply

54 solutions
Top badges earned
Springboard
Give Back 5
Ignite 1
Affirm 50
Validate 1
View profile
KiranVedantam1992
Level 7

16-03-2021

Hi @Shaheena_Sheikh,

 

You can achieve this in two ways

  1. Writing BE event listeners who listen to the JCR level events and dynamically add an ID [property] as per your prescribed format to the node
  2. Write FE javascript code on the dialog level to dynamically add the ID whenever the text field is authored.

For more details on event listeners check my blog here

 

Hope this helps.

 

Thanks,

Kiran Vedantam.