Visual Builder

Get Involved. Join the Conversation.

Topic

    Ameur Baccoucha
    How to add an array to a POST Service Data Provider?
    Topic posted June 28, 2019 by Ameur BaccouchaGold Medal: 3,500+ Points, tagged Custom Code, REST, UI 
    44 Views, 3 Comments
    Title:
    How to add an array to a POST Service Data Provider?
    Summary:
    I need to POST multiple contact of the same customer using a post form
    Content:

    Hi there, 

    I have a list of customer that are displayed in a table. I did create a Create POST page to create a new ones.

    but in every customer i can have one or multiple contact.

    so i think to create a + button to push the variable into the contact array every time there is a contact but ididn't know how to increment the 0 in the field data value which is {{$page.variables.postCustomer.contact[0].name }} .

    in the image how it looks my form.

    and this is a post body example.

     

    Image:
    Code Snippet:

    Comment

     

    • Shay Shmeltzer

      The fields in the Contact section shouldn't be based on the expression you have, rather you would want them to be in a separate object and when you click the + button you add them to a row in the contacts array. In that action chain you'll use an assign variable to assign the object to which the fields are mapped to the array.

      Another approach would be to have that section as an editable table based on an array and have the + button add a row to that array. Then assign that array to your contact array when you post the data.

       

      • Ameur Baccoucha

        Ok if i wanna use the second approach wich is a table with an array variable. how can i do it ? 

        sorry but i am new with vbcs 

        let's say that i will use a create form page or a in the same page a form how i will push the value in the table ? 

        • Shay Shmeltzer

          Start with this blog that shows you how to base a table on an arrayDataProvider:

          https://blogs.oracle.com/vbcs/editable-tables-in-visual-builder-the-oracle-jet-6-way