Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Skip inside the for each loop

Hi All,

Consider a scenario where  ,I am looping on an array of 100 values.

I got the value which i was looking at the index of 20 . then i need set 2 variables with predefined values and skip rest of the looping in for each.

Could you please let me know if it is possible ? sample code is really appreciated .

Thanks in advance

Raj

  Discussion posts and replies are publicly visible

Parents
  • If I understand the question properly, Im assuming that you want to update an array where a particular value has been set.

    If thats the case then you can do something like:

    updatearray(
      ri!myArray,
      wherecontains(
        ri!valueToUpdate,
        ri!myArray
      ),
      ri!myNewValue
    )

    Else, if you are just trying to update at index 20, then you can do:

    updatearray(
      ri!myArray,
      20,
      ri!myNewValue
    )

  • Hi Benjamin , Thanks for the reply .
    I am not trying to update the array itself . I need to update a cdt or a local variable which is defined in load or with if if the condition defined in expression of for each met and skip the loop. Any other loops will it help ?

    Ex:

    local!a : {"1","2","3","4","5","6","7","8","9","10"}
    local!toset,
    local!sampleJsonObj: "{ 1:null,2:null,3:null, 4:India, 5:australia, 6:null,7:spain,8:null,9:yyyy,0:jjjjj}" /*this array holds json objects with more than 100 */

    For ex: a!forEach(
    items:local!a,
    expression: if ( not (isnull ( index (samplejsonObj, fv!item )) , set the first index value / json object of not null to a local toset or cdt , else skip the next values)
    )

    hope it is clear with pseudo code.

    Thanks
    Rajesh
Reply
  • Hi Benjamin , Thanks for the reply .
    I am not trying to update the array itself . I need to update a cdt or a local variable which is defined in load or with if if the condition defined in expression of for each met and skip the loop. Any other loops will it help ?

    Ex:

    local!a : {"1","2","3","4","5","6","7","8","9","10"}
    local!toset,
    local!sampleJsonObj: "{ 1:null,2:null,3:null, 4:India, 5:australia, 6:null,7:spain,8:null,9:yyyy,0:jjjjj}" /*this array holds json objects with more than 100 */

    For ex: a!forEach(
    items:local!a,
    expression: if ( not (isnull ( index (samplejsonObj, fv!item )) , set the first index value / json object of not null to a local toset or cdt , else skip the next values)
    )

    hope it is clear with pseudo code.

    Thanks
    Rajesh
Children
No Data