Hi, I am new to appian, how to duplicate this Java loop into Sail Expression?

positionCollect[] = {1,2,3,4,5,6,7,8,9,10};

for (int i = 0; i < positionCollect.size(); i=i+2) {

polygon[i/2] = new Point(positionCollect.get(i), positionCollect.get(i+1));

}

polygon is a Point Class type list, the Point class has two value x and y.

So basically I am using 10 numbers from List, create 5 object point (CDT) , and put into list polygon.

I am pretty new to appian I don't know expression rule can do the same thing? And unfortunately I can't use java plug-in to finished this so I have to write expression rules...

  Discussion posts and replies are publicly visible

Parents
  • a!localVariables(
        local!positionCollect: {1,2,3,4,5,6,7,8,9,10},
        local!polygonList: a!forEach(
            enumerate(length(local!positionCollect)/2)+1,
            type!Point(
                x: local!positionCollect[(fv!index*2)-1],
                y: local!positionCollect[(fv!index*2)]
            )
        ),
        local!polygonList
    )

    In Appian all functions and rules will return a value. In the code above, I have a list of positions defined as a list and then a polygonList which calls a!forEach() which will return a list. Also, the code above will only work if your positionCollect list is even.

Reply
  • a!localVariables(
        local!positionCollect: {1,2,3,4,5,6,7,8,9,10},
        local!polygonList: a!forEach(
            enumerate(length(local!positionCollect)/2)+1,
            type!Point(
                x: local!positionCollect[(fv!index*2)-1],
                y: local!positionCollect[(fv!index*2)]
            )
        ),
        local!polygonList
    )

    In Appian all functions and rules will return a value. In the code above, I have a list of positions defined as a list and then a polygonList which calls a!forEach() which will return a list. Also, the code above will only work if your positionCollect list is even.

Children