I have a proces model for updating employee data (not yet finished but it shouldn't matter):
This process starts with interface that looks like this:
It means that update process starts with choosing employee from the database through dropdown field.
I've created these process variables:
The problem is: If I try to run the process for debugging without initializing null values for these parameters I keep getting following error:
If I initialize them to nulls explicitly everything works fine. What could be the reason?
It seems that there is a problem with the initial employee dropdown field which is defined like this:
a!sectionLayout( label: "Employee Selection", contents: { a!dropdownField( label: "Employee", labelPosition: "ABOVE", placeholderLabel: "--- Select a Value ---", choiceLabels: a!forEach( items: local!employees, expression: fv!item.firstName & " " & fv!item.lastName ), choiceValues: a!forEach( items: local!employees, expression: fv!item.id ), value: ri!selectedEmployee, saveInto: ri!selectedEmployee, required: true, validations: {} ) }, showWhen: local!activeStep = 1 ),
Local variable used for populating dropdown (local!employees) is defined like this:
a!localVariables( local!activeStep: 1, local!steps: { "Select employee", "Personal Data", "Address Data", "Review" }, local!startAddressId, with( local!supervisors: rule!EEDM_GetAllSupervisors(), local!employees: rule!EEDM_GetAllEmployees(), local!allAddress: rule!EEDM_GetAllAddresses(), a!formLayout( label: "Update Employee" ...
There should be no problem with EEDM_GetAllEmployees which fetches all employees.
Discussion posts and replies are publicly visible
By default, integer PVs initialize with a value of 0 (zero), not null. That would explain the issue in your dropdown. Within your start form interface, fixing this would be as simple as wrapping the value in an if() statement, like value: if(ri!selectedEmployee = 0, null(), ri!selectedEmployee)
Ok, it means that my dropdown is trying to fetch employee with ID = 0 for it's default value and fails to do so as I don't have one with that ID?
Also, I'm not sure if I understood your solution correctly:
You mean to put your IF statement here?
Or somewhere in the interface code?
ivanm0004 said:it means that my dropdown is trying to fetch employee with ID = 0 for it's default value and fails to do so as I don't have one with that ID?
it means that my dropdown is trying to fetch employee with ID = 0 for it's default value and fails to do so as I don't have one with that ID?
Basically. Read the error message you put in your screenshot. In it, it says the value you're trying to pass is 0, while the choiceValues array is a list of non-zero values. This is a basic requirement of Dropdown Fields - the only exception they can handle is when the Value is "null()", and even then only if you have a placeholderlabel defined.
ivanm0004 said:Or somewhere in the interface code
To be fair, I believe i did say "on your start form interface ...the value..." above, though my wording may have been less clear than I imagined it was. So in other words, here:
This start form part confused me, because I understood it as this handling is only meant for this specific process and not for general "0 case" handling on my interface (which I can also reuse in other processes).
Thx for the clarification
Generally it would only be really relevant to your start form here due to the variable being initialized to Zero by Appian. In other places that wouldn't necessarily occur, though if there were a chance for a 0 value to be passed to a dropdown in a similar manner, a similar "zero check" in the code would also be beneficial.