Want to iterate CDT (list) and copy to the new CDT as MAP (like key(i.e. text),value (i.e. list of CDT)pair)

Hi,

 

List 1 (input list) - multiple wells per each AMU (PFA screen shots 3 for Big gully , 5 for Rush Lake etc)

     

I want loop each item in the list and group the wells associated to each well and each amu has different groups/users created in Appian . For each AMU , an email notification needs to send to all the associated distinct users along with the well details in a table format.

So I have created a CDT as below or the result CDT should contain distinct  AMU with Well list and its user details

 

Can some one help me to achieve this logic.

 

 

Thanks

Soujanya

  Discussion posts and replies are publicly visible

  • Hi Soujanya,
    By analysing your cdt and data i am assuming that you want to set the details of WellList with associate AMU's
    to do so first get the distinct AMUNames from the dictionary by using
    distinct(index(cdt,"AMU",{}),index(cdt,"AMU",{})) by this you will get the distinct AMUNames
    after getting distinct AMUNames do forEach,
    follow the example code :
    load(
    local!distinctAMUNames: distinct(index(cdt,"AMU",{}),index(cdt,"AMU",{}))
    forEach(
    items: local!distinctAMUNames,
    expression: with(
    local!currentAMUs: fv!item,
    type!RTRR_HOG_LEG_BY_AMU(
    AMUNames :local!currentAMUs,
    wellList: forEach(
    items:index(yourCDT, wherecontains( local!currentAMUs,index(yourCDT,"AMU",{})),{}),
    expression: type!WellList(
    WellName : index(fv!item,"wellName",null),
    UWI : index(fv!item,"wellName",null),
    userList : /* Your code */
    )
    )
    )
    )

    )
    )
  • 0
    A Score Level 1
    in reply to Sachin
    Try union function in place of distinct
  • Thanks for you response!
    I am in 16.3 apian version.I don't think we have foreach function is available in 16.3.
  • 0
    A Score Level 1
    in reply to Soujanya B
    You can use apply function instead of forEach,
    but the code may bit change, you need to create separate rules for constructing the CDT and iterate on that.
    rule1
    -------
    load(
    local!distinctAMUNames: union(index(cdt,"AMU",{}),index(cdt,"AMU",{}))
    apply(
    rule!construct_RTRR_HOG_LEG_BY_AMU_CDT(
    AMU: _,
    yourCDT : yourCDT ( pass whole data )
    ),
    list : local!distinctAMUNames
    )
    )
    rule2 (construct_RTRR_HOG_LEG_BY_AMU_CDT)
    -------
    type!RTRR_HOG_LEG_BY_AMU(
    AMUNames :ri!AMU,
    wellList:apply(
    rule!constructWellList(
    cdt:_
    ),
    index(yourCDT, wherecontains( ri!AMU,index(yourCDT,"AMU",{})),{})
    )
    )
    rule3 (rule!constructWellList)
    ---------
    type!WellList(
    WellName : index(ri!cdt,"wellName",null),
    UWI : index(ri!cdt,"wellName",null),
    userList : /* Your code */
    )
  • Hi Soujanya,

    Please try the below code:

    /*Main Rule*/
    with(
    local!data: {
    WellList1:{
    {WellBoreID:"",AMU : "Rush Lake", AMUCode:"",LicensedUWI:""},
    {WellBoreID:"",AMU : "Rush Lake", AMUCode:"",LicensedUWI:""},
    {WellBoreID:"",AMU : "Big Gully", AMUCode:"",LicensedUWI:""},
    {WellBoreID:"",AMU : "Rush Lake", AMUCode:"",LicensedUWI:""},
    {WellBoreID:"",AMU : "Big Gully", AMUCode:"",LicensedUWI:""},
    {WellBoreID:"",AMU : "Alley", AMUCode:"",LicensedUWI:""},
    {WellBoreID:"",AMU : "Big Gully", AMUCode:"",LicensedUWI:""}
    }
    },
    local!wellList: index(local!data, "WellList1",{}),
    local!listofAMUs: index(local!wellList,"AMU",{}),
    local!distinctListofAMUs : union(local!listofAMUs,local!listofAMUs),
    local!listOfdataByAMU: apply(
    rule!Test_SubRule(
    allData : local!wellList,
    singleAMU: _
    ),
    {local!distinctListofAMUs}
    )
    )
    )

    /*Sub Rule(Name: Test_SubRule): Parameters: 1. allData(List of data), 2. singleAMU(Single AMU) */

    with(
    local!amuIndex: wherecontains(
    touniformstring(ri!singleAMU),
    touniformstring(index(ri!allData,"AMU",{}))
    ),
    local!selectedData: index(
    ri!allData,
    local!amuIndex,
    {}
    ),
    local!selectedData
    )
  • Hi Tried with the same approach..
    Child CDT (WellList) is not getting populated with the data.Getting empty results.Attached the rules.

    Rule 1:
    =========
    load(
    local!distinctAMUNames: union(
    index(ri!totalwelllist,"AMU",{}),index(ri!totalwelllist,"AMU",{})),
    apply(
    rule!rtrr_construct_lge_by_amu(
    "AMU": _,
    "totallist" : ri!totalwelllist
    ),
    local!distinctAMUNames
    )
    )

    Rule 2
    ======

    'type!{urn:com:appian:types}RTRR_HOG_LGE_BY_AMU'(
    AMUName :ri!AMU,
    wellList:apply(
    rule!Rtrr_ConstructWellList(
    cdt:_
    ),
    index(ri!welllist, wherecontains(ri!AMU,index(ri!welllist,"AMU","")),{})
    ),
    LGE : union(index(rule!get_RTRRHOBBusinessUsersbyAMU(index(ri!welllist,"AMU",null)),
    "UserName",null),"")
    )


    Rule 3
    ====

    'type!{urn:com:appian:types}WellList'(
    WellName : index(ri!welllist,"WellName",null),
    UWI : index(ri!welllist,"LicensedUWI",null)
    )


    OutPut which it results : Well List is not pupulating
    ======================================
    [AMUName=Atmore, WellList=[WellName=, UWI=], LGE=Wesley Blake; Andy Olajide; Wesley Blake] :
  • In your third rule, ri!welllist has value?, if Yes try as below:

    'type!{urn:com:appian:types}WellList'(
    WellName : apply(index(_,"WellName",{}),{ri!welllist}),
    UWI : apply(index(_,"LicensedUWI",{}),{ri!welllist})
    )

    I know apply is use for multiple however sometimes index function does not respond if CDT structure is not proper.
  • 0
    A Score Level 1
    in reply to Soujanya B
    just confirm that below code
    index(ri!welllist, wherecontains(ri!AMU,index(ri!welllist,"AMU",{})),{})
    is returning you the correct result.