Hi Team,
I had 2 simple questions which I wanted to post here. Please help me if anyone has the answers :
Context :
You are given a list of CDT / Dictionary / Map with a few fields, eg :
{ { key: 12, val: "ABC" }, { key: 20, val: "DEF" }, { key: 30, val: "GHI" } }
Problem statement :
Get those CDTs which have key bw 10 & 25
My approaches :
I had 2 approaches, both of which I have a roadblock
Questions :
Now for the approach 1, I had a question : how do I filter this custom data subset ? because I only see queryEntity and queryRecord but nothing to query this custom dataset
For approach 2 : is there a way we can eliminate the need of creating a different rule in the env and somehow use some function .. is it possible to create local functions in appian ? something like :
a!localVariables( local!a: (var){ } )
Discussion posts and replies are publicly visible
Approach 1 doesnt make much sense according for me. For approach 2 whatever you will do in the expression you can do in the main rule itself by using a foreach(). Can you try something like this?
a!localVariables( local!map: { a!map(key: 12, val: "ABC"), a!map(key: 20, val: "DEF"), a!map(key: 30, val: "GHI") }, a!foreach( local!map, if( and(fv!item.key > 10, fv!item.key < 25), fv!item, {} ) ) )
Why doesn't approach 1 make sense ? Think in terms of DB, if I could have a simple queryFilter return the dataset why not ?
For the solution you provided in foreach : I didnt want to use this solution, hence was looking for alternatives
Thanks though
Given its a dictionary/map then you would need to write it to database so that filtering can be done for approach 1. Personally as per my understanding of the usecase its too much hassle so simpler way is foreach. If you are expecting a large dataset (which is not mentioned in description) then I would go for involving database and approach 1.
Anyway to answer your questions:
1.
GautamShenoy said: how do I filter this custom data subset ? because I only see queryEntity and queryRecord but nothing to query this custom dataset
To filter you need to store data into database using CDT or records. Then you can query the dataset.
2.
GautamShenoy said:is there a way we can eliminate the need of creating a different rule in the env and somehow use some function .. is it possible to create local functions in appian ? something like
filter() needs a predicate so you need to have a rule/function which can be called here. We cannot create local functions as you are expecting!