Skip to main content
New Participant
June 14, 2023
Solved

Setting an initial user for pickerFieldUser

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.

    mikes0011
    mikes0011Answer
    Brainy
    June 14, 2023
    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
        )
      }
    )

    The Expression Guru

    8 replies

    mikes0011
    Brainy
    June 14, 2023

    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).

    The Expression Guru
    New Participant
    June 14, 2023

    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

    mikes0011
    mikes0011Answer
    Brainy
    June 14, 2023
    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
        )
      }
    )

    The Expression Guru
    harshitb6843
    Brainy
    June 14, 2023

    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.