I have a Repeat Block Template in the Form with the below fields inside the Repeated Content:
textfield: userName (id)
textfield: userAge (id)
How do I map the above to the properties in the Model (already created) below?
<applicant>
...
I have a Repeat Block Template in the Form with the below fields inside the Repeated Content:
textfield: userName (id)
textfield: userAge (id)
How do I map the above to the properties in the Model (already created) below?
<applicant>
<repeatingFields>
<individual>
name <--- property (it has a circle on the left in the Form editor)
age <--- property (it has a circle on the left in the Form editor)
</individual>
</repeatingFields>
</applicant>
And the expected outcome in the submitted xml is:
(I have trouble achieving this)
<applicant>
<repeatingFields>
<individual>
<name>John</name>
<age>33</age>
</individual>
</repeatingFields>
<repeatingFields>
<individual>
<name>Peter</name>
<age>44</age>
</individual>
</repeatingFields>
</applicant>
I have tried mapping the fields (userName, userAge) to the Model's name and age (e.g. select field userName, then double click name on the Model). But only the last repeat (Peter, 44) appeared and is inside the <TrackingCode> (which is not what I want)
If I use Repeat instead of Repeat Block Template, it still only returns the last repeat (Peter,44), however, it is in the proper structure (ie. <applicant> ...)
Thoughts
I have a Repeat Block Template in the Form with the below fields inside the Repeated Content:
textfield: userName (id)
textfield: userAge (id)
How do I map the above to the properties in the Model (already created) below?
<applicant>
...
I have a Repeat Block Template in the Form with the below fields inside the Repeated Content:
textfield: userName (id)
textfield: userAge (id)
How do I map the above to the properties in the Model (already created) below?
<applicant>
<repeatingFields>
<individual>
name <--- property (it has a circle on the left in the Form editor)
age <--- property (it has a circle on the left in the Form editor)
</individual>
</repeatingFields>
</applicant>
And the expected outcome in the submitted xml is:
(I have trouble achieving this)
<applicant>
<repeatingFields>
<individual>
<name>John</name>
<age>33</age>
</individual>
</repeatingFields>
<repeatingFields>
<individual>
<name>Peter</name>
<age>44</age>
</individual>
</repeatingFields>
</applicant>
I have tried mapping the fields (userName, userAge) to the Model's name and age (e.g. select field userName, then double click name on the Model). But only the last repeat (Peter, 44) appeared and is inside the <TrackingCode> (which is not what I want)
If I use Repeat instead of Repeat Block Template, it still only returns the last repeat (Peter,44), however, it is in the proper structure (ie. <applicant> ...)
Thoughts
To solve this problem I needed to add a 'sleep' function to the page load rule.
If I delay the code it seems that the repeat block has time to be configured properly (with the functions), and so the Util.addRepeatContent function works correctly.
...To solve this problem I needed to add a 'sleep' function to the page load rule.
If I delay the code it seems that the repeat block has time to be configured properly (with the functions), and so the Util.addRepeatContent function works correctly.
See code below:
// hack to overcome Repeat Block issues
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// cards
var cardsData = Form.prefill.Cards.CardsData;
if (cardsData) {
data.$cards = JSON.parse(cardsData);
data.cards_cardsCount = data.$cards.length;
if (data.$cards.length > 0) {
Form.setInstanceCount(Form.items.cards_card_, data.cards_card_, data.$cards.length);
}
//console.log("sleep start");
sleep(1000).then(() => {
//console.log("sleep end");
Util.addRepeatContent(Form.items.cards_card_, data.$cards);
});
}
Hope this helps someone.
Thanks
Mark
Register to ask a question and access to more content.