I’m trying to create a dynamic list of a custom control that will have x number of blank entries presented on the page based on a number the journey user gave me on a previous page. Here’s the real world example:
I’m trying to get someone to RSVP to an event and they’re first going to confirm they’re going, then if they are, they’ll tell me how many guests are coming with them. Then, I have to ask them all what dining menu selections they want for each person. I’ve been following this link on CCs/Dynamic Lists but I’m stuck on how I set the initial set of CC objects based on the # of guests the user told me.
Then I have a list summary CC, but I’m a little confused on how I’m telling the list summary the number of items that are needed in that list, especially if I’m starting with just a number (the number of guests the user told me) and I need to parse that into a list of indexes.
it keeps resolving to null, even when testing in Connection Builder with sample data that I’m plugging in. I’m not quite sure I understand the query here and what it’s doing, especially with “number_of_guests” being of type number. Can you elaborate on the query?
Oh yeah, I see the bit I missed including in my first reply (my bad!). Adding that here
I’ve broken this down into the tiny steps so that it’s easier to follow exactly what I’m doing in each, feel free to scroll to the bottom for the final expression (can be used in a UDF’s body)
Transforming the number_of_guests integer into a list of things with LENGTH(list) = number_of_guests
First we’ll need to grab that integer and cast it as a string: FORMAT_NUMBER(number_of_guests)
Take that string and transform it into anything lengthy (this can be done in a number of ways, this is just my quick hack): MD5(FORMAT_NUMBER(number_of_guests))
Now that we have a long string, let’s get a substring of length=number_of_guests: SUBSTRING(MD5(FORMAT_NUMBER(number_of_guests)),0, number_of_guests)
Great! We are ready to take that substring and turn it into a list we can use for creating your empty guest list: SPLIT(SUBSTRING(MD5(FORMAT_NUMBER(number_of_guests)),0, number_of_guests),"")
Using number_of_guests=5 as an example, the output of this bit will be:
[
"e",
"4",
"d",
"a",
"3"
]
Finally, use the expression above inside that SELECT clause :
FROM
guest
IN
SPLIT(SUBSTRING(MD5(FORMAT_NUMBER(number_of_guests)),0, number_of_guests),"")
SELECT
{
"guestName":NULL,
"vegan":NULL,
"allergies":NULL,
"firstCourse":NULL,
"mainCourse":NULL,
"dessert":NULL
}
Now the solution might be complete. Just test it out and lmk if it works as you need @davidpairkit !