I have a repeat block having field fname, lastname, middle name, address line1, address line2, city, zipcode, state. I want to pass the values to an service for each repeated values. How can I handle this requirement?
a sample example please how to push repeat data to service via action script and iterate over the array inside service?
You can achieve this as follows:
Add a data field (called 'Repeat JSON') that converts the repeat data to JSON format with a calculation rule:
Add a Dynamic Data Button that calls your service and passes through the data field above as an input parameter.You should see data being passed to the service in the format:
Code your groovy service to parse the repeatJson input parameter using the Path class as described here:Interrogating Structured Data Paths
I tried to access data of repeat block on click action of delete button. Its giving errors: "Form.convertToFieldDataMap required array input...".
When i tried to debug in console log. the repeat content is giving value 'undefined'.
console.log("repeatedContent: "+ data.repeatedContent ); //repeatedContent is ID ref of repeat block.
Please help with sample code for:
1) how to fire an action on each delete/add button. So if i click on delete of a repeat item(say repeat item 2)the data of that particular repeat item should be saved via service to backend and the repeat would be deleted
2) on click of continue button data should be saved via service to backend for all repeat items
my sample form looks like below:
Repeated Content is a standard container (block) so it makes sense that this has no value of its own. You should be referring to the Repeat Data element which is the actual repeat and has the repeat icon.
If you are ever unsure about this, the type of the element is shown at the very top of the Properties panel:
Thanks Ben, i was pointing to the content block, my wrong.
I tried as you suggested for repeat data
console.log("repeatedContent: "+data.content1 ); still getting values 'undefined'.
can you please help on below:
1) I would add a hidden dynamic data button to the repeat content and fire the click rule of this button in the click script of the delete button.
2) You could add your logic to the click script of the Continue button but probably better to add a Page Change rule to the Page Controller to handle this.
Umakanta Dalai did this work for you?
sorry Ben.. I am a beginner to maestro. I am not clear how to implement both of your suggestions at this point. Will try and let you know. If there is any sample example for quick reference will be a great help.
For repeating data there is a tutorial video here: All about repeating data
It depends in what format the service requires the data. Let's say your repeat has ID "myRepeat", you could pass "data.myRepeat" and you would get an array of objects, each of which had the field names with their original IDs, something like:
You can then pass the resulting data in a call to DynamicData.call() or you can use a datafield (or a reference to the original repeat data if it doesn't need any modification) within the field ref map of a Dynamic Data Button.