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
12 replies
Subscribers
10 subscribers
Views
12173 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Hi. I have a dropdown list that fails when selecting one of the values. Here i
bjartek
over 9 years ago
Hi. I have a dropdown list that fails when selecting one of the values. Here is the SAIL:
a!dropdownField(
label: "Regulation",
labelPosition: "ABOVE",
placeholderLabel: "--- Select a Value ---",
choiceLabels: rule!PMA_GetAllRegulations().name,
choiceValues: rule!PMA_GetAllRegulations().id,
value: ri!property.regulationId,
saveInto: ri!property.regulationId,
validations: {}
),
This is the error message:
Expression evaluation error at function a!dropdownField [line 136]: A dropdown component [label=“Regulation”] has an invalid value for “value”. All selected values must be present in the choiceValues array, but value was 1 and choiceValues was 1; 2.
The value 1 is correct and it exists in the choiceValues, so I do not understand why it fails.
Thanks
Bjarte
OriginalPostID-208351
OriginalPostID-208351
Discussion posts and replies are publicly visible
0
Sathya Srinivasan
Appian Employee
over 9 years ago
Try to load the rule!PMA_GetAllRegulations() and then use the load variable inside the drop down.
Just making sure that the delay in rule execution (between the same rule invoked twice) is not causing any issues.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinay Kumar Rai
over 9 years ago
Use:
a!dropdownField(
label: "Regulation",
labelPosition: "ABOVE",
placeholderLabel: "--- Select a Value ---",
choiceLabels: {rule!PMA_GetAllRegulations().name},
choiceValues: {rule!PMA_GetAllRegulations().id},
value: ri!property.regulationId,
saveInto: ri!property.regulationId,
validations: {}
)
hope this help
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
I would stronly advise not to do the above. Sathya's solution is the correct one - load rule!PMA_GetAllRegulations() into a local and reference the values as local!regulations.name etc
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
@vinayr What you suggest will result in an array containing an array of items, as a query rule called on a SAIL form always returns an array and so .name and .id are already arrays.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
bjartek
over 9 years ago
Thanks. I did the following:
a!dropdownField(
label: "Regulation",
labelPosition: "ABOVE",
placeholderLabel: "--- Select a Value ---",
choiceLabels: local!AllRegulations.name,
choiceValues: local!AllRegulations.id,
value: ri!property.regulationId,
saveInto: ri!property.regulationId,
validations: {}
),
and defined the local variable as
local!AllRegulations: rule!PMA_GetAllRegulations(),
I am still getting the following error:
Expression evaluation error at function a!dropdownField [line 138]: A dropdown component [label=“Regulation”] has an invalid value for “value”. All selected values must be present in the choiceValues array, but value was 1 and choiceValues was 1; 2.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
Is ri!property.regulationId the same type as returned from the query rule? They could be text rather than integer, I guess? Also, is the form wrapped in a with()? If you could post the whole form someone might be able to find the problem easier.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
@Bjartek: at this point I usually like to view the base value of the local variable, removing the dropdown from the equation altogether (unitl you find the issue).
This is what I'd do:
1) comment out the dropdown field
2) add a new Paragraph field, label: "DEBUG", value: local!allRegulations
3) try and identify whether there might be something wrong with the local value explaining why the dropdown is acting this way.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 9 years ago
Have you checked what value ri!property.regulationId has? For this to work it has to be NULL or some integer. Anything else will fail. Mschmitts last suggestion is what I do in general. First load some data, then check it and then use it.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Vinay Kumar Rai
over 9 years ago
May it work try this convert the value to integer
value: tointeger(ri!property.regulationId)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
bjartek
over 9 years ago
Hi all. Thank you for all your good suggestion. A check through all the fields showed that the property.regulationId was defined as Text, thereby creating the error. Thanks
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>