Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

How to do data binding for one-to-many in Adaptive Forms

Avatar

Level 2

I am using REST based FDM with one to many association. In FDM, swagger was able to set up one to many association. However, I am not sure how to do data binding in the Adaptive Forms.

 

Let says I have Entity called Person which has one-to-many association with another entity called Address. Lets assume that there 3 addresses (Permanent, Current and Office) per person.

I thought I can have 3 panels for each of the addresses. However, I am not able to set up the data binding.

Any suggestion how to set up data binding for one-to-many association in Adaptive Forms?

 

Thanks in advance.

[Reposting my question in the AEM Forms forum]

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies

Avatar

Employee Advisor

@naan_raja If you have created an association then in the test fdm you should be seeing a person with objects of addresses, Let's first check if you have the data, and fetch correctly setup.

 

Send the screenshot of the FDM test UI and a copy of the response obj here

Avatar

Level 2

Hi @Mayank_Gandhi 

 

Please see below FDM. There is no prefill so only Write Service is enabled. Request and Response looks identical as the underlying service, persists and return same entity.

 

naan_raja_0-1669617791669.png

 

POST /employee

Request:

 

{
    "Employee": {
     
        "name": "easit",
        "empId": 32,
        "addresses": [
            {
  
                "doorNo": "voluptate culpa sed no",
                "streetName": "tempor sed fugiat",
                "city": "molli",
                "state": "amet exercitatio"
            },
            {
  
                "doorNo": "consequ",
                "streetName": "culpa ex",
                "city": "pariatur",
                "state": "nisi cillum"
            },
            {
     
                "doorNo": "fugiat",
                "streetName": "offici",
                "city": "irure aliqu",
                "state": "ut amet aliqua"
            },
            {

                "doorNo": "conse",
                "streetName": "eiusmod commodo dolor",
                "city": "nulla",
                "state": "sint ex Ut"
            },
            {
  
                "doorNo": "tempor",
                "streetName": "incididunt fugi",
                "city": "venia",
                "state": "aute irure dolor"
            }
        ]
    }
}

 

Response:

{
    "empId": 32,
    "addresses": [
        {
            "streetName": "tempor sed fugiat",
            "city": "molli",
            "id": 8,
            "doorNo": "voluptate culpa sed no",
            "state": "amet exercitatio"
        },
        {
            "streetName": "culpa ex",
            "city": "pariatur",
            "id": 9,
            "doorNo": "consequ",
            "state": "nisi cillum"
        },
        {
            "streetName": "offici",
            "city": "irure aliqu",
            "id": 10,
            "doorNo": "fugiat",
            "state": "ut amet aliqua"
        },
        {
            "streetName": "eiusmod commodo dolor",
            "city": "nulla",
            "id": 11,
            "doorNo": "conse",
            "state": "sint ex Ut"
        },
        {
            "streetName": "incididunt fugi",
            "city": "venia",
            "id": 12,
            "doorNo": "tempor",
            "state": "aute irure dolor"
        }
    ],
    "name": "easit",
    "id": 3
}

 

 

 

Avatar

Community Advisor

How did you map currently?

try using the below with each panel

addresses[0].city

addresses[1].city

addresses[2].city

Avatar

Level 2

Already tried and it didn't work. No child associations were getting passed in REST API calls.