Evaluate Nested Logic Exercise
Evaluate Nested Logic Exercise
Advanced Expressions
Introduction 2
How to Complete the Exercises in this Tutorial 2
How Can I Practice? 2
Appian Version 2
Naming Conventions 2
Save Often 3
Additional Resources 3
Practice 1 Set Up: Use Nested if() Functions to Return Mapped Values 4
Practice 2 Set Up: Use the a!match() Functions to Return Mapped Values 7
Practice 1 Help and Resources: Use Nested if() Functions to Return Mapped Values 10
Additional Resources 11
Practice 2 Help and Resources: Use the a!match() Functions to Return Mapped Values 11
Additional Resources 13
Notice of Rights
This document was created by Appian Corporation, 7950 Jones Branch Dr, Tysons, Virginia 22102.
Copyright 2024 by Appian Corporation. All rights reserved. Information in this document is subject to
change. No part of this document may be reproduced or transmitted in any form by any means, without
prior written permission of Appian Corporation. For more information on obtaining permission for
reprints or excerpts, contact Appian Training at [email protected].
Keep in mind that this is a community environment not suitable for production workloads or
sensitive information.
Appian Version
Appian Community Edition is on the latest Appian version. If you are following the exercises
from a previous Appian version, go to academy.appian.com to download the latest version.
Naming Conventions
When you register for Appian Community Edition, you gain access to a workspace, which is
your personal area within the community environment. When your workspace has been
assigned, you will receive a confirmation email with a workspace ID.
Use this workspace ID when creating new applications and objects. Otherwise, you could run
into naming conflicts with objects created by other users. Pre-loaded apps in your workspace
also include the workspace ID. In the example below, the application prefix for the Acme
Auto Solution app is W0000AS. So, the workspace identifier is W0000, which would be
included in any new app’s prefix.
24.3
Additional Resources
Appian provides a number of training resources for Appian developers. The following
resources are particularly popular with our learners:
● Academy Online - Appian’s online courses provide useful survey courses, step-by-step
tutorials, and practice exercises. Explore these resources at your own pace. Survey
courses will help you develop a better grasp of the topics you need to learn. Video
and print tutorials will help you with getting hands-on experience with Appian.
● Community Discussions for New Users - Check out the New to Appian thread in
Community. Join our community of experts to ask questions and find answers from
past discussions.
24.3
In this lesson you’ll use the expression editor to create some data arrays, view their data
structures, and determine whether or not you should convert them.
/*
ID Name Icon
-- ---- ----
24.3
*/
If(
If(
Help
For a given rule input, the expression returns the name and icon associated with
the document type. The nested if() functions are configured to return the proper
map for the name: and icon: value pairs, according to the following mapping.
● The Test Output should be of type Map. The value should be:
5. Continue testing with values 2 through 6 as your input value for the Expression. You’ll
notice that any value above 2 returns an error value for both name and icon.
6. Complete the expression rule, such that it returns a map value pair for the other input
values listed in the following table.
Tip
Add three more nested if() functions to handle conditions where the input value
is 3, 4,or 5.
7. Test input values 1-6 and confirm the test output values match the table above.
8. To better understand why nested If() functions are not performant, enter: 5 as your
input value and click Test Rule.
10. Scroll down to view Descendent Functions. Notice that the expression evaluates five
consecutive nested if() functions before reaching a conclusion about the value it
returns.
The first if() function evaluates a single condition: ri!typeId=1. If this condition
evaluates to true, the first parameter, which is defined as a!map(name: "Purchase
Order", icon: "money") is returned, and the rest of the parameters are not evaluated.
If the condition evaluates to false, the second parameter, which itself is another if()
function, needs to be evaluated. This continues until the last condition is evaluated.
24.3
/*
ID Name Icon
-- ---- ----
24.3
a!match(
value: ri!typeId,
whenTrue: ri!typeId=1,
whenTrue: ri!typeId=2,
Help
For a given rule input, the expression returns the name and icon associated with
a document type ID. The a!match() function is configured to return the proper
map for the name: and icon: value pairs according to the following mapping.
● The Test Output should be of type Map. The value should be:
24.3
6. Complete the expression rule, such that it returns a map value pair for the other input
values listed in the following table.
7. Test input values 1-6 and confirm the test output values match the table above.
8. To better understand why the a!match() function is more performant than nested if()
functions, enter: 5 as your input value and click Test Rule.
Tip
Unlike most functions, a!match() does not always evaluate all of its
parameters.The function will only evaluate equals and whenTrue parameters until
it finds a match to the value parameter. After it finds a match, the following then
parameter will be evaluated and any remaining parameters will be ignored.
24.3
24.3
1.
Add the match() function
For the value parameter, enter: ri!typeId
2.
3.
For the first whenTrue parameter, enter: ri!typeId=1
4.
For the first then parameter, enter: a!map(name: "Purchase Order", icon:
"money)
5. Add additional whenTrue and then parameters for input ids 2-5.
24.3
24.3
24.3