Update List of Lists based on condition

Hi All,

I have the following scenario: 

which basically says:

List of Dictionary: 3 items

  Dictionary

    class: "1"

    sections: List of Text String: 4 items

      "a"

      "b"

      "c"

      "d"

  Dictionary

    class: "2"

    sections: List of Text String: 3 items

      "a"

      "b"

      "c"

  Dictionary

    class: "3"

    sections: List of Text String: 5 items

      "a"

      "b"

      "c"

      "d"

      "e"

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

I want to update and return this list of classes such that the sections ("d", "e") are removed from the sections list for each class. How can we implement it? And what could be the optimum algorithm for Appian to implement. 

Note: I want to implement similar logic to a list of CDTs (datasubset) which has nested CDTs list based on condition.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi soumyab243 you can use following logic to achieve your requirements as mentioned below:

    load(
      local!data: {
        {
      		class: "1",
      		sections: {"a", "b", "c", "d"}
      	},
      	{
      		class: "2",
      		sections: {"a", "b", "c"}
      	},
      	{
      		class: "3",
      		sections: {"a", "b", "c", "d", "e"}
      	}
      },
      a!forEach(
        local!data,
        {
          class: fv!item.class,
          sections: difference(trim(split(touniformstring(fv!item.sections), ";")), {"d", "e"})
          
        }
      )
    )

    Hope this will help you.

Reply
  • 0
    Certified Lead Developer

    Hi soumyab243 you can use following logic to achieve your requirements as mentioned below:

    load(
      local!data: {
        {
      		class: "1",
      		sections: {"a", "b", "c", "d"}
      	},
      	{
      		class: "2",
      		sections: {"a", "b", "c"}
      	},
      	{
      		class: "3",
      		sections: {"a", "b", "c", "d", "e"}
      	}
      },
      a!forEach(
        local!data,
        {
          class: fv!item.class,
          sections: difference(trim(split(touniformstring(fv!item.sections), ";")), {"d", "e"})
          
        }
      )
    )

    Hope this will help you.

Children
No Data