Integration

Get Involved. Join the Conversation.

Topic

    Prasath Chandra Sekaran
    modify existing attributes in file of records in OICAnswered
    Topic posted November 14, 2019 by Prasath Chandra SekaranRed Ribbon: 250+ Points 
    20 Views, 9 Comments
    Title:
    modify existing attributes in file of records in OIC
    Content:

    We are reading a response from a Webservice call  which returns array of json element structures and writing into a file in OIC as new record.

    How ever some attributes in each record are null and need to populate them by calling a webservice .

    How to address this sceneario ? If we use write file again with append option it will only append from the end of file but not modify the existing records / attributes..

    Or Can we access 2 collections / arrays in a single for each when writing a new file.

    Best Comment

    Hemanth Lakkaraju

    This is not an *append* but *overwrite* scenario which can only be possible if you have all required information before hand to write into file. So get the data first, then use multiple collections as params to XSLT that sends request to write file.

    Comment

     

    • Hemanth Lakkaraju

      This is not an *append* but *overwrite* scenario which can only be possible if you have all required information before hand to write into file. So get the data first, then use multiple collections as params to XSLT that sends request to write file.

    • Prasath Chandra Sekaran

      Thank you Hemanth.. so how to pass multiple collections as param to XSLT in OIC mapping ? do you mean, we need to export the archive and edit the xsl in jdeveloper? in OIC mapping, if any way to pass multiple collections, kindly let me know..

    • Prasath Chandra Sekaran

      Hi Hemanth

      Can you please bit clear... I can map only one element in for each collection <xsl:for-each select = '/nssrcmpr:execute/nsmpr1:request-wrapper/nsmpr1:topLevelArray'>  which iterates over the first collection and map the fields in the file.. But how do i introduce a second collection here and map the other fields from this collection? 

    • Prasath Chandra Sekaran

      I dont knw where you are suggesting to map multiple for-each 

      If you see the attached image, the file in OIC is getting written by mapping to for-each records of first collection .. How ever we would like to populate certain fields like event type, description and completion date from a second collection. How to map the second collection here.. because the top level iteration accepts only one for-each and one collection only. Please suggest. Many thanks

    • Prasath Chandra Sekaran

      Hi Hemanth 

      Can you please help with the above issue? if yo have any link for accessing multiple collections in the same iteration ..kindly let me know

      • Hemanth Lakkaraju

        On the invoice element on right side, you can have 2 for-each elements corresponding to 2 collections. For sample steps on how to build multiple conditions in xslt refer this 

        Sample snippet that looks like

        <xsl:for-each select="$Collection1/Repeating_Element">
          <xsl:variable name="$CollectionNode1" select="."/>
          <xsl:for-each select="$Collection2/Repeating_Element">
            <xsl:variable name="$CollectionNode2" select="."/>
            <xsl:if test="$CollectionNode1/UNIQUE_ID=$CollectionNode2/UNIQUE_ID">
            <invoice>
              <Field1><xsl:value-of select="$CollectionNode1/FIELD1"/></Field1>
              <Field2><xsl:value-of select="$CollectionNode2/FIELD2"/></Field2>
            <invoice>
            </xsl:if>
          </xsl:for-each>
        </xsl:for-each>

         The variables and if condition will make sure you don't have duplicate occurrences in response. You have to export the xsl for creating variables.

    • Prasath Chandra Sekaran

      Many Thanks Hemanth for the idea ... i was guessing closer to this when you said 2 for-each loops, but for each main iteration, then there will be n inner loop iteration ..so totally n*n iterations.. it will be a big performant hit, if there are 1000 records in collection 1 and collection 2.

      i was basically looking equivalent for this == 

      for(int i =0; int i < no of elements ; i++) {

      collection1[i].item1

      collection2[i].item2

      }

      when both collections are ordered.. like accessing both arrays in a single iteration through a loop counter (or like BPM sub process multi instance loop)...any way to access with a single iteration?