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
+1
person also asked this
people also asked this
Replies
11 replies
Subscribers
8 subscribers
Views
4349 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi, I would like to ask the community three questions. Prior to asking the quest
sikhivahans
over 8 years ago
Hi, I would like to ask the community three questions. Prior to asking the questions, I would like to give some context and please do let me know if you have questions here:
I am trying to construct a reusable editable grid and trying to make the 'rows' attribute as much generic as possible. In this attempt I have made the rule reference as input, which means that anyone who uses this reusable grid would be able to use their own rule which renders grid row layout.
So simply speaking, the reusable grid rule looks like below:
editableGrid
-----------------
a!gridLayout(
/*Other attributes of gridLayout removed to make it look simple*/
rows: a!applyComponents(
ri!nameOfItemsRowEachRule(
ri!items,
_,
ri!itemsToken
),
if(or(isnull(ri!items), count(ri!items) < 1), {}, 1+enumerate(count(ri!items))),
ri!itemsToken
)
/* where ri!name...
OriginalPostID-169115
OriginalPostID-169115
Discussion posts and replies are publicly visible
0
sikhivahans
over 8 years ago
...OfItemsRowEachRule is of 'Any Type' */
)
Anyone who integrates the above rule would use it as follows:
Example1:
a!formLayout(
label:"Customers",
firstColumnContents:{
rule!editableGrid(
/* other attributes of editableGrid to make it look simple */
nameOfItemsRowEachRule: rule!ucCustomersItemRowEach
/*where ucCustomersItemRowEach will actually render the row lay out*/
)
}
)
Example2:
a!formLayout(
label:"Employees",
firstColumnContents:{
rule!editableGrid(
/* other attributes of editableGrid to make it look simple */
nameOfItemsRowEachRule: rule!ucEmployeesItemRowEach
/*where ucCustomersItemRowEach will actually render the row lay out*/
)
}
)
So the problems I faced while opting for the above approach is:
1. I am unable to pass the arguments by keywords for a rule which is invoked because of being passed by reference via rule inputs.
Actually I would like to configure the rows parameter as follows:
rows: a!applyComponents(
...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
... array:ri!nameOfItemsRowEachRule(
items:ri!items,
index:_,
itemsToken:ri!itemsToken
),
array: if(or(isnull(ri!items), count(ri!items) < 1), {}, 1+enumerate(count(ri!items))),
arrayVariable: ri!itemsToken
)
But I am not able to do as above as I am experiencing an error where Appian says that passing the arguments by keywords isn't available. So I am doing as follows by passing the arguments without making use of keywords:
rows: a!applyComponents(
ri!nameOfItemsRowEachRule(
ri!items,
_,
ri!itemsToken
),
if(or(isnull(ri!items), count(ri!items) < 1), {}, 1+enumerate(count(ri!items))),
ri!itemsToken
)
2. I am unable to name the rule input as I wish, which I am making use of for receiving the reference of a rule (nameOfItemsRowEachRule).
Initially I did as follows:
a!gridLayout(
/*Other attributes of gridLayout removed*/
rows: a!applyComponents(
r...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
... i!rows(
ri!items,
_,
ri!itemsToken
),
if(or(isnull(ri!items), count(ri!items) < 1), {}, 1+enumerate(count(ri!items))),
ri!itemsToken
)
/* where ri!rows is of 'Any Type' */
)
But to my surprise, Appian hasn't allowed me to use the word 'rows' (Also to make a note, 'rows' is an attribute of the a!gridLayout()) and so I renamed it to 'nameOfItemsRowEachRule', which thereby resolved the issue. And the approach now opted by me is as follows:
a!gridLayout(
/*Other attributes of gridLayout removed*/
rows: a!applyComponents(
ri!nameOfItemsRowEachRule(
ri!items,
_,
ri!itemsToken
),
if(or(isnull(ri!items), count(ri!items) < 1), {}, 1+enumerate(count(ri!items))),
ri!itemsToken
)
/* where ri!nameOfItemsRowEachRule is of 'Any Type' */
)
So, finally my questions are as follows:
1. Won't Appian allow the rules (Rule...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
... s that were passed by reference via the rule inputs, ex: nameOfItemsRowEachRule as stated above) to be invoked by passing argiments making use of keywords?
2. Is there any constraint in naming the rule input, that has the ability to reference a rule? (As stated above, I am unable to name the input as 'rows' and has given another name called 'nameOfItemsRowEachRule')
3. Are there any other things that one should keep in mind when invoking the rules with the help of reference via rule inputs?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
For convenience, attached the same post as a text document.
Forum post.txt
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eliot Gerson
Appian Employee
over 8 years ago
In the documentation, you can find a SAIL recipe for an editable grid that may meet your needs. You can find the recipe here:
forum.appian.com/.../SAIL_Recipes.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 8 years ago
@Eliot Gerson Hi, thanks for your comment. But I would like to request you to go through the post clearly, because the post is neither targeting the usage of editable grid nor its recipes. Its about the usage and behavior of the rules received via the reference of rule inputs, in-fact the same can be inferred from the questions in the post.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 8 years ago
A few bits of info that I hope might help:
#1 - I have seen that error before but only where certain functions don't allow keyword syntax; apply() being one example. I've also used multiple nested a!applyComponents before and it's worked fine.
I guess the error you're seeing is because you're defining the array attribute using a rule that's also using keyword syntax...? It might also be because the keywoard overlap - maybe try renaming the array rule input in rule!nameOfItemsRowEachRule to something other than array?
#2 - I believe there are some reserved words for rule inputs - I haven't found a list available but I've seen the same error you've seen and had to rename the rule input.
#3 If what I suspect about #1 is the case, and given the limitation on rule input names, I guess it would make sense to avoid using generic names like array, rows and so on - maybe anything that's an input to a system function? That said, I've never seen a best practice recommending that.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 8 years ago
Apologies I just reread the code for #1 and i think the two attributes named "array" are duplicate? So I guess it's not what I said!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jennifer Durina
Appian Employee
over 8 years ago
In reference to #2 it's not reserved words. If a rule input is named the same thing as a parameter for a component function (ie label, required, value), a race condition runs between the rule input and the parameter. The parameter wins. For instance,
ri!label
a!textField(
label: "My field",
value: ri!label,
saveInto: ri!label,
required: true
)
will always show and save "My field".
This has already been reported as a defect with reference number AN-63037
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>