REST childAddress

4 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    08 Jun
    Link to this post
    In order to update a child record do you need to implement the links and point to a different BE?

    I have the following REST annotation and I can see the child records returned in the json response. I can update the Item record but not the child records.

    @RestAddress (type="record", address="/Item/~{ItemNum}/~{PackNum}", tables="eItem,eTotals,eActiveBatch", id="ItemNum,PackNum",
                  fields="eItem.*,eTotals.*,eActiveBatch.*", canRead="true", canUpdate="true", canDelete="false",
                  childAddress="eTotals:/Totals/~{ItemNum}/~{PackNum},eActiveBatch:/ActiveBatch/~{ItemNum}/~{PackNum}"
                  ).

  2. Mike Fechner
    Mike Fechner avatar
    263 posts
    Registered:
    14 Sep 2016
    Answered
    09 Jun in reply to Roger Blanchard
    Link to this post
    RESTful is a single table interface. 

    So when you want to address multiple tables in the same Business Entity via RESTful you need to add annotations for multiple endpoints. The can be done in a single Business Entity.

    @RestAddress (type="collection", address="/Orders", tables="eOrder", id="OrderNum",
                  fields="OrderNum,CustNum,OrderDate,ShipDate,OrderStatus", canCreate="true").


    @RestAddress (type="record", address="/Orders/~{OrderNum}", tables="eOrder,eCustomer,eOrderLine,eItem", id="OrderNum",
                  fields="eOrder.*,eCustomer.Name,eCustomer.City,eCustomer.Country,eOrderLine.*,eItem.ItemName,eItem.Price", canRead="true", canUpdate="true", canCreate="true", canDelete="true",
                  childAddresses="eCustomer:/Customers/~{CustNum},eOrderLine:/Orders/~{OrderNum}/OrderLines/~{LineNum},eItem:/Items/~{ItemNum}",
                  links="orderlines:/Orders/~{OrderNum}/OrderLines").


    @RestAddress (type="collection", address="/Orders/~{OrderNum}/OrderLines", tables="eOrderLine", id="LineNum",
                  fields="ItemNum,Qty,Price", canDelete="true", canCreate="true") .


    @RestAddress (type="record", address="/Orders/~{OrderNum}/OrderLines/~{LineNum}", tables="eOrderLine,eItem", id="LineNum",
                  fields="*", canRead="true", canUpdate="true", canDelete="true",
                  childAddresses="eItem:/Items/~{ItemNum}").


    @RestAddress (type="collection", address="/Customers/~{CustNum}/Orders", tables="eOrder", id="OrderNum",
                  fields="OrderDate,ShipDate,OrderStatus", canCreate="true").


    @RestAddress (type="collection", address="/Customers/~{CustNum}/Orders/~{OrderNum}/OrderLines", tables="eOrderLine", id="LineNum",
                  fields="ItemNum,Qty,Price", canDelete="true", canCreate="true") .


    @RestAddress (type="record", address="/Customers/~{CustNum}/Orders/~{OrderNum}", tables="eOrder", id="OrderNum",
                  fields="eOrder.*", canRead="true", canUpdate="true", canCreate="true", canDelete="true",
                  links="orderlines:/Customers/~{CustNum}/Orders/~{OrderNum}/OrderLines").


    @RestAddress (type="record", address="/Customers/~{CustNum}/Orders/~{OrderNum}/OrderLines/~{LineNum}", tables="eOrderLine,eItem", id="LineNum",
                  fields="*", canRead="true", canUpdate="true", canDelete="true").

  3. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    09 Jun in reply to Mike Fechner
    Link to this post
    Thanks Mike.
  4. Roger Blanchard
    Roger Blanchard avatar
    343 posts
    Registered:
    29 Jun 2018
    09 Jun in reply to Mike Fechner
    Link to this post
    Works great...thanks again.
4 posts, 1 answered