Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. 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.

how to increment local variable in for each loop in appian expression rule?

i written code : 

with(
local!prioritylist:{1,2,3,4,5,6,7,8,9,10},
local!missinglist{}:{},
local!newmissing,
local!count:0,
local!temp: a!forEach(
items:local!prioritylist,
expression:
if(fv!item <ri!priority,if(rule!CRP_Checkdepartmentwisepriority(fv!item,ri!department)=0,append(local!missinglist{},fv!item),local!missinglist{}),local!missinglist{}),

local!newmissing:if(count(local!missinglist{})>0,count(local!missinglist{}),local!newmissing)
),


local!temp

)

i got the output like this:

List of Variant - 10 items

    • List of Variant - 0 items
      • List of Variant - 0 items
        • List of Number (Integer) - 1 item
            • 3(Number (Integer))
            • List of Variant - 0 items
              • List of Variant - 0 items
                • List of Variant - 0 items
                  • List of Variant - 0 items
                    • List of Variant - 0 items
                      • List of Variant - 0 items
                        • List of Variant - 0 items

                        Here i want sum of count of each list of this list . Answer should be 1

                        So, How to add the count of each list in one variable??

                          Discussion posts and replies are publicly visible

                        Parents
                        • +1
                          Certified Lead Developer

                          I'm pretty confused as to what you're trying to do here, and/or what you expect the outcome to be.

                          You ask "how to increment a local variable in a for each loop" and the short answer is, really, "you don't", because that's not how the Appian expression language, or the a!forEach() function, work.

                          Also I'm confused by what you're doing with the local!newmissing variable that seems to be inside the a!forEach() expression section - this is not syntactically valid.  And again I'm unclear what it's intended to accomplish.

                          The expected output of the a!forEach() function is an array.  If, for example, you want the total result of the sum of all items in that array, you simply need to pass the result through the sum() function afterwards.  Like, sum(local!temp) etc.

                        • Thanks Mike. through sum(local!temp) I resolved my issue.

                        Reply Children
                        No Data