When creating a new record with a user field, I want the field the field to initially be set to the current logged in user. I need to be able to clear that field and select a different user if applicable.
In all of the functional variations I've tried, I can set a default value, but it will not allow me to change the selection. If I click the X to clear the selection, it just repopulates with the logged-in user.
I've tried variations of the following:
a!pickerFieldUsers(
label: "User", labelPosition: "ABOVE", maxSelections: 1, value: if (
isnull(ri!record['recordType!{...}BWTA Event.fields.{...}user']), loggedInUser(), ri!record['recordType!{...}BWTA Event.fields.{...}user']
), saveInto: ri!record['recordType!{...}BWTA Event.fields.{...}user'], required: true, validations: {}
),
I've reviewed many discussion threads, but either my available options do not match or they do not pertain to the create action.
I reviewed this recipe, linked in a number of posts, Set the Default Value of an Input on a Start Form - Appian 23.1, but under the Process Modeler I do not see a "process start form" mentioned in step 3, nor am I prompted import rule inputs as in step 4. All I see is the Start node and there are no relevant configuration options.
One thread mentioned the use of the statProcessLink, but I don't see how to configure the Create action button from the records list and thus I don't see any way to add context parameters to the Create action.
Any help appreciated...
Thanks.
Discussion posts and replies are publicly visible
The simpler approach here is to simply have the user picker field access, and save back into, the value of a local variable that you can declare to be the value of the loggedinuser upon form load - then at the time of submit click, use a single extra a!save() statement to save the current value of that local variable back into `ri!record['recordType!{...}BWTA Event.fields.{...}user']` (etc).
Thank you for the response. One variation I tried did include using local-variables, so I think I know the syntax for that part, but I'm not familiar the latter part "use a single extra a!save() statement to save the current value of that local variable".
Is this an example of what you're suggesting? https://docs.appian.com/suite/help/23.2/fnc_evaluation_save.html#upper-casing-and-appending-to-the-typed-text-in-one-variable,-saving-unchanged-to-another
You have to set the default values in the variable that you use as a value and saveInto. Not directly in the component as it will always keep it fixed.
brianw0006 said:Is this an example of what you're suggesting?
Not really - you would put it on your Submit button, not within the field itself.
a!buttonWidget( label: "Submit", value: "Submit", submit: true(), style: "PRIMARY", saveInto: { ri!buttonClicked, a!save( ri!record['recordType!{...}BWTA Event.fields.{...}user'], local!mySelectedUser ) } )
This is almost working! Now I can change the selected user, but when I submit I get an error that it could not find ri!buttonClicked.
Without ri!buttonClicked, when I change a different picker field (pickerFieldRecords) right beneath (focus, change value, then blur), the user field resets to the original value. This also happens when I change the value of a paragraph field on the same form.
I searched the docs for ri!buttonClicked, but I did not see anything.
Mike Schmitt Can you provide some insight on ri!buttonClicked? Thanks.
"buttonClicked" is just an example of a typical text-value Rule Input that carries the value of the clicked-on Submit button back to the process (when necessary). It's optional but I add one about 95% of the time.
I assumed the absence of buttonClicked was related to the aberrant behavior I described above.
Creating two localVariables, startUser and selectedUser, where the initial value of selectedUser is startUser seems to have corrected the issue.
For posterity...
a!localVariables( local!startUser: if ( isnull(ri!record['recordType!{...}BWTA Event.fields.{...}user']), loggedInUser(), ri!record['recordType!{...}BWTA Event.fields.{...}user'] ), local!selectedUser: local!startUser, a!formLayout( label: if( ri!isUpdate, "Update Event", "Create Event" ), contents: { a!columnsLayout( columns: { a!columnLayout( ... ), a!columnLayout( contents: { a!pickerFieldUsers( label: "User", labelPosition: "ABOVE", maxSelections: 1, value: local!selectedUser, saveInto: local!selectedUser, required: true, validations: {} ), ... } ) } ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: if(ri!isUpdate, "Save", "Create"), submit: true, style: "PRIMARY", validate: true, saveInto: { a!save( ri!record['recordType!{...}BWTA Event.fields.{...}user'], local!selectedUser ) } ) } ) ) )
Mike Schmitt THANKS!