How to fetch line details/for loop in JSON mapping (ION API connection)

Hi,

 

I have scenario where XML is transferred to JSON and sending a request, before I'm sending mapping API request and I'm able to sucessfully fetch header data.

But how could we fetch line details/for loop.

 

MY XML DATA

---------------

<SyncWS_PACKCONF releaseID="9.2">
    <ApplicationArea>
        <Sender>
            <LogicalID>infor.database.mk_ws_iontest_db</LogicalID>
            <ComponentID>External</ComponentID>
            <ConfirmationCode>OnError</ConfirmationCode>
        </Sender>
        <CreationDateTime>2019-05-23T10:53:00.123Z</CreationDateTime>
        <BODID>infor.database.mk_ws_iontest_db:1558608780122:5340:0</BODID>
    </ApplicationArea>
    <DataArea>
        <Sync>
            <TenantID>INFOR</TenantID>
            <AccountingEntityID/>
            <LocationID/>
            <ActionCriteria>
                <ActionExpression actionCode="Replace"/>
            </ActionCriteria>
        </Sync>
        <WS_PACKCONF>
            <Doc_Type>01   </Doc_Type>
            <Doc_Code>29809</Doc_Code>
            <Doc_Prefix>ECOM</Doc_Prefix>
            <Doc_Number>3</Doc_Number>
            <LstItems>
                <AddlItemCode/>
                <LogicUser_Code>998899843993</LogicUser_Code>
                <Packing_Box_No>MKFSC34572</Packing_Box_No>
                <Quantity>1</Quantity>
                <Lot_MRP>899</Lot_MRP>
            </LstItems>

<LstItems>
                <AddlItemCode/>
                <LogicUser_Code>998899843993</LogicUser_Code>
                <Packing_Box_No>MKFSC34572</Packing_Box_No>
                <Quantity>1</Quantity>
                <Lot_MRP>899</Lot_MRP>
            </LstItems>
        </WS_PACKCONF>
    </DataArea>
</SyncWS_PACKCONF>

 

MY Mapping code
-----------------

{
 "Doc_Code": {"IonApiRef":"//DataArea/WS_PICKSLIP/Doc_Code"},
 "Doc_Prefix": {"IonApiRef":"//DataArea/WS_PICKSLIP/Doc_Prefix"},
 "DO_Date": {"IonApiRef":"//DataArea/WS_PICKSLIP/DO_Date"}
}

How do we get LstItems line data here?

 

How to fetch line details/for loop in JSON mapping (ION API connection)?

 

Regards,

Somashekhar

  • <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/.../Transform">
    <xsl:template match="SyncWS_PACKCONF">
    <SyncWS_PACKCONF>
    <xsl:apply-templates select="ApplicationArea"/>
    <xsl:apply-templates select="DataArea"/>
    </SyncWS_PACKCONF>
    </xsl:template>
    <xsl:template match="ApplicationArea">
    <ApplicationArea>
    <xsl:copy-of select="*"/>
    </ApplicationArea>
    </xsl:template>
    <xsl:template match="DataArea">
    <DataArea>
    <xsl:apply-templates select="Sync"/>
    <xsl:apply-templates select="WS_PACKCONF"/>
    </DataArea>
    </xsl:template>
    <xsl:template match="Sync">
    <Sync>
    <xsl:copy-of select="*"/>
    </Sync>
    </xsl:template>
    <xsl:template match="WS_PACKCONF">
    <xsl:for-each select="./LstItems">
    <AddlItemCode><xsl:value-of select="./Packing_Box_No"/></AddlItemCode>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
  • In reply to 1753258:

    Please apply above logic and let me know whether you are able to proceed or not
  • In reply to 1753258:

    Hello Satish,

    I apologize if I intervene here but I just happen to have the same problem as Godrej.
    But I didn't get your answer: how can I use xslt code inside the manuel mapping of an ION API connection point? I don't think it's possible.
    Is there a way to use a loop inside that manual mapping?

    Thank you very much
    Mattia
  • In reply to 1284038:

    Hi Mattia,

    Give me sometime, let me check the possibilities, as this is first time im working on API integration.

    Regards
    Satish
  • In reply to 1284038:

    It is correct that there are no manual XSLT mapping capabilities within an ION API connection point. Your best bet is to execute this in two steps -
    Step 1: Produce a BOD XML output out of your JSON from the ION API connection point step.. (The discussion on this thread may help you to do that: community.inforxtreme.com/.../how-to-convert-json-format-into-the-xml-format );
    Step 2: Once you have the BOD output, you can send it through a mapping step where you can write your XSLT to do the looping etc.

    In the near future, you will have a scripting engine (CE only) which will allow you to manage this directly and also to produce a JSON output.
  • In reply to Vignesh:

    HI ,
    We can use request policy transformations to change the input XML to a different format.
    Following is the snippet that can be used in the request policy.

    {{#each S:Envelope.S:Body.OrderDetailsRequestParams.ArrayOfOrderLines as |orderLines|}}
    <OrderLine>
    <ItemID>{{orderLines.ItemID}}</ItemID>
    <CustomerItemID/>
    <ShipFromPartyWarehouseLocationID>{{orderLines.ShipFromPartyWarehouseLocationID}}</ShipFromPartyWarehouseLocationID>
    <Quantity>{{orderLines.Quantity}}</Quantity>
    </OrderLine>
    {{/each}}

    Thanks,
    Ravikiran S
  • In reply to RaviKiran:

    Thanks Ravikiran,

    Can you please elaborate it more.
    I mean where to use it, how to use it the request policy.

    Regards
    Satish
  • In reply to 1753258:

    HI Satis,

    While defining the ION API, we have something called 'Endpoint Policies' as shown below.

    If we click on   on request policies, then a pop up will be opened. Select the Policy Type as Transformation. 

    Add your transformation snippet in the policy definition. FYI, it uses handle bars to fetch details from the input XML.

     

    Thanks,

    Ravikiran S

  • In reply to RaviKiran:

    Thank you Ravikiran.

    For me it is not enabled, i was using Salesforce  API suite in ION Gateway. Not sure the reason why it is not enabled.

    Please find the below response.

     

  • In reply to 1753258:

    Click on the Details section and see if you have Endpoint Policies there.

    Thanks,

    Ravikiran S

  • In reply to RaviKiran:

    Still not getting.

    Please find the below references.

     Can any one suggest the reason why the Salesforce suite in ION Gateway not able to display Endpoint Policies.

     

     

  • In reply to 1753258:

    Satish,

    Probably you are creating the api suite from template. Please create it as new and non-infor/non-provisioned.then you should be able to edit the policies.
  • In reply to Sarada:

    Yes you are correct.

    Thank you for your info.

    I have configured for non-infor/non-provisioned one and able to see the policies.

    Can i please let me know bit more info.

    After i configured the suggested one, i was not able to see the documentation for it. What are configurations needed to get the Swagger documentation in the Gateway for non-infor/non-provisioned APIs.

    Please find the below reference.

     

  • In reply to 1753258:

    Hi Satish, I see you had used Salesforce APi in ION gateway. Can you tell me how you upload the API in the Gateway? I mean i would need the full path where to do that.

    Will be thankful for your answer.

    Ilyas
  • In reply to 1364083:

    Hi Ilyas,

    I didn't upload the Sales force API in ION Gateway, i just used the Infor provided Salesforce API template.
    Go to ION API --> Add -->in the search box type Salesforce and configure the authentication details there. That's it.

    Regards
    Satish