Skip to main content
akshays0003
June 17, 2021
Question

How to convert CDT list into List of Varient

  • June 17, 2021
  • 18 replies
  • 0 views

I have a List of Data of type CDT, i wanted to convert that into List of varient to use that data in A!forEach() ??? 

    18 replies

    mikes0011
    Brainy
    June 17, 2021

    Considering that a!forEach() can act on any list type (including list of CDT), i'm not sure why you would want to do this - can you explain a bit more about your use case?

    The Expression Guru
    akshays0003
    June 17, 2021

    1.      In my process model I have a process variable of type 

    type!MB_Medicine__Cost_Data_fromExcel (urn:com:appian:types:mb) id, name, perCost, quantity, totalCost

    id (Number (Integer))

    name (Text)

    perCost (Number (Integer))

    quantity (Number (Integer))

    totalCost (Number (Integer))

    2.     Inside this I already have data stored. Assume a list of 5.

            Now what I need to do is I need to find the name: "Cipla" and wanted to change its perCost. 

           So, I have created a rule expression and passed my variable into that rule using rule input.

    3.     a!localVariables(
            local!dataInput:ri!oldData,
            local!finalUpdate:a!forEach(
            items: local!dataInput,
            expression: a!localVariables(
            local!checking:"cipla",
           'type!{urn:com:appian:types:mb}MB_Medicine__Cost_Data_fromExcel'(
           name: if(fv!item[1]=local!checking,"ciplex",fv!item[1]),
           perCost: fv!item[2],
           quantity: fv!item[3],
           totalCost: fv!item[4],
         )
         )
         ),
         local!finalUpdate
        )

    4. In my rule Exp . ri!oldData contains the data of type!MB_Medicine__Cost_Data_fromExcel

    5. So , it is not parsing in foreach and gives error

    6. I also used tojson() and fromjson() but it is also converting into dictionary

    I need to convert ri!OldData into List of varient so i can parse it and change the data of cipla only ??

    akshays0003
    June 17, 2021

    you can also suggest some other ways or shortcut to make it done