Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
11 replies
Subscribers
7 subscribers
Views
4248 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hello all, I have an expression rule which looks up (via query) and then re
Mike Schmitt
Certified Lead Developer
over 11 years ago
Hello all,
I have an expression rule which looks up (via query) and then returns a single member of a CDT array. My issue is that there is one corner case in which I would like to override one specific element in that CDT as it's returned, but for the life of me I can't figure out any workable way to do this. Any suggestions, or is it even possible?...
OriginalPostID-72086
OriginalPostID-72086
Discussion posts and replies are publicly visible
0
shelzle
over 11 years ago
Have you tried the plugin "Set CDT properties"? I am not shure but it might match your needs.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 11 years ago
I'm primarily using a cloud installation, so it's not easy for me to install new plugins for testing purposes, but i'll look into it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Cichy
Appian Employee
over 11 years ago
You will have to use two nodes for this operation, one to save the pv from query rule, and the other one that overwrites one of the attributes.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 11 years ago
@Mike: that's what I usually do, however in this case I am using a single expression rule to return a CDT which is used to pre-populate about 40 fields on a single user input task form (each field has slightly different parameters passed into the same rule to get different results), and there's a corner case where I would really like to override the value of the returned CDT to Zero... yep, a head-scratcher...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Cichy
Appian Employee
over 11 years ago
If you are on 7.2, you could try using the with() (
forum.appian.com/.../Evaluation_Functions
function and cast the result into your CDT. I cannot say I have done this before but theoretically you should make it work in a single expression.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 11 years ago
Thanks - I've started getting familiar with the with() function, but I'm less sure on how to manually cast - any hints?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Andrew P Gramann
Certified Lead Developer
over 11 years ago
Hi Mike,
I think you can use load() and dictionary syntax to accomplish this. Try something like:
load(
mycdt:<expression to initialize mycdt>,
if(
not(<corner case expression>),
local!mycdt,
{field1:local!mycdt.field1, field2:local!mycdt.field2, field3:0}
)
)
It will be a bit tedious to type out all 40 fields, but this should get your desired result in 1 expression.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
revat.anandsongkit
Appian Employee
over 11 years ago
A minor adjustment to Andrew's response. Firstly, in this case it wouldn't make a difference if you use with() or load() -
forum.appian.com/.../Evaluation_Functions
. What I would do is with( mycdt: <expression to initialize>, if(not(<corner case exp>), mycdt, type!CDT_NAME(field1: mycdt.field1, field2:mycdt.field2 ..... ) ) You need the type! constructor to cast your results to the CDT type. If you have never used a type constructor, I would recommend going to the expression editor and seeing what happens when you write type!CDT_Name(). Then play around with that...do type!CDT_Name(field1: "test") etc. Hope this helps.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 11 years ago
@Andrew and Revat - thanks a bunch, your combined suggestions helped me do what i needed. To clarify, I was calling this one expression rule in about 30 different places, but luckily i didn't need to modify those at all, just the rule itself, so it worked out pretty well.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 11 years ago
Revat, if I can call you in for one further piece of advice here: I'm using the type! constructor (successfully) as you recommended, with the following issue: the expression rule fully evaluates the CDT with the URL of our dev environment, any time the rule is saved. The rule is now generating an error when we try to import it into our test environment, and I believe this is the reason for the error (mismatched URLs). I have tried stripping out the URL but it always reverts back to how it was. Is there anything I can do to force it to save ONLY by the name of the CDT (since the same CDT will be imported to the other environment anyway)? Otherwise this functionality isn't of much use to me, since it isn't cooperating with the environment port.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>