Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

Generating random number for a dialog field

Avatar

Level 3

Hi,

I am trying to have a hidden field in my dialog so that whenever i open the dialog in edit mode, a random number gets assigned to that hidden field.

Does anyone has any idea about generating random number for a dialog field?

Thanks,

Priya

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

You can write javascript [clientLibs (cq.authoring.dialog)] which will be called when dialog loads and assign value to hidden field.

JavaScript random() Method

You can use JQuery to handle events. For example, the following code represents the event handler that is invoked when the Touch UI dialog is opened:

$document.on("dialog-ready", function() {

        $(window).adaptTo("foundation-ui").alert("Open", "Dialog now open, event [dialog-ready]");

});

Thanks

Arun

Arun Patidar

AEM LinksLinkedIn

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi,

You can write javascript [clientLibs (cq.authoring.dialog)] which will be called when dialog loads and assign value to hidden field.

JavaScript random() Method

You can use JQuery to handle events. For example, the following code represents the event handler that is invoked when the Touch UI dialog is opened:

$document.on("dialog-ready", function() {

        $(window).adaptTo("foundation-ui").alert("Open", "Dialog now open, event [dialog-ready]");

});

Thanks

Arun

Arun Patidar

AEM LinksLinkedIn

Avatar

Level 10

Great response!

Avatar

Level 3

Thanks for your quick response. I'll try generating it using javascript.