Confirm Dialog with for Cycle


#1

Is it possible to add a for cycle inside the message of a confirm Dialog?

I need to display to a user information regarding products. And there can be more than 1 product so therefore the need of a for cycle inside the message of a confirm Dialog.

var dialogs = require("ui/dialogs");
        dialogs.confirm({
            title: "Payment Notification",
            message:
            "DocumentID: " + string1 + "\n" +
            "Total Value: " + string2 + " € \n\n" +
            "Details:" + "\n\n" + 
            
            "\t\t\t\tDescription: " + string6 + "\n" +
            "\t\t\t\tQuantity: " + string5 + "\n" +
            "\t\t\t\tPrice: " + string4 + " € \n" +
            "\t\t\t\t" + string7 + "\n",
            okButtonText: "Confirm",
            cancelButtonText: "Cancel"
        }).then(result => {
            console.log("Dialog result: " + result);
});

Inside this code snippet where you see this part:

            "Details:" + "\n\n" + 
            
            "\t\t\t\tDescription: " + string6 + "\n" +
            "\t\t\t\tQuantity: " + string5 + "\n" +
            "\t\t\t\tPrice: " + string4 + " € \n" +
            "\t\t\t\t" + string7 + "\n",

This is only for one product. What i want is to include this into a for cycle and have something like this:

            "Details:" + "\n\n" + 
             for (var i = 0; i < array.length; i++) {
            "\t\t\t\tDescription: " + array[i].string6 + "\n" +
            "\t\t\t\tQuantity: " + array[i].string5 + "\n" +
            "\t\t\t\tPrice: " + array[i].string4 + " € \n" +
            "\t\t\t\t" +  array[i].string7 + "\n",

So therefore my question is, is it possible? to add a for cycle inside the Message of the Confirm Dialog?
I am currently trying and i can’t achieve anything.


#2

It appears to me that the message property is of type string. You could build the string before bringing up the dialog.


#3

Yea i also realized that and did exactly what you sayed. It works.

I built it before bringing up the dialog
Thanks :stuck_out_tongue: