a!localVariables( local!principalAmount:ri!loanAmount, local!totalMonths: ri!tenure * 12, local!interestForOneMonth: round(ri!interest / 12, 2), local!interest: ( local!interestForOneMonth * local!remainingAmount, ) / 100, local!remainingAmount:local!principalAmount-local!interest, a!forEach( items: enumerate(local!totalMonths) + 1, expression: { local!interest, local!principalAmount, local!remainingAmount,
a!save(local!remainingAmount,local!principalAmount-local!interest,), a!save(local!principalAmount, local!remainingAmount), } ), )
For each iteration of the for loop i want to update the value of local!principalAmount and local!remainingAmount as shown above. Kindly let me know how we do this in Appian.
Discussion posts and replies are publicly visible
Nope. They'll change with every iteration. This is a recursion. Create an expression rule with the name as 'LoanCalculator' and paste the above definition. Then save it. Should work!
Awesummmmmm! It worked. Thanks Harshit!!!
Hi! I want to use the same practice as Anuradha C , but in a different context. The logic I am trying to achieve is "if my local variable equals 0, execute this code and make the variable equal to 1 so the next iteration of the forEach loop meets false in the if condition and executes the else code". Is there a way to achieve this with local variables? And if not, how can I make this logic happen?
appian.rocks/.../
I can't quite grasp how I am going to implement the Iterative Algorithm in my code. Am I going to use it to update a local variable? Or as an if condition? I don't quite understand its use.
Using reduce, you can pass data from one iteration to the next. While not the same as modifying a variable, you can use it to implement iterative algorithms.