Initialize process variable used by process startup form

Hi Community,

I created a simple record type and generated record actions (create, update) using Appian "Generate Record Actions" button.

As result I got a "shared" process model "Create or update ..." and a single user interface that is assigned to the process as the startup form.

I created a second interface with a read-only grid where I should add two buttons - the first one should create a new record (insert action) and the second one should let user edit an existing record.

As both actions starts the same process model, the same startup form is presented to the user - empty on new record and prepopulated with existing data on edit - that's expected and works fine.

Now, I have a requirement to prepopulate some values when user wishes to create a new record (not all, only some).

I tried to initialize the "record" rule input on process model (Process model properties -> Process start form -> list of interface rule inputs), by using following construction
(please note that record type field 1 & 2 are here only for demonstrating purposes and in my code I use proper syntax to reference record type fields)

=if (a!isNullOrEmpty(pv!record),
a!update(
pv!record,
{"record type field1","record type field 2"},
{"Dummy", null}
),
pv!record
)

Unfortunately, this don't work as the UI pops-up error stating: 

Expression evaluation error: The save target must be a local variable that does not refresh on every evaluation or on an interval, a process variable, or a node input (or a rule input passed one of those three), but instead was: [CSR_XX_SAFET_TEST name=Dummy, description=]

when I try to create record (the field 1 was indeed prepopulated, but as I was not able to save the record the solution is not acceptable). I suppose this is due the fact that a!update() creates a new object and Appian expects that a variable is passed as a rule input value.

The second idea was to set a default value for the pv (Edit process variable -> Value), but Appian doesn't allow referencing other variables when you try to set the initial value for a pv (makes sense as it obviously could lead to a loop).

Finally, I decided to split the process model into two - one responsible for creating new records and the second one responsible for the update of existing records.

In the first process model (record creation) I initialized the pv (as the pm is used only in one case, there is no need to check if pv has already value) and this helped.

As this now implies that I have two process models (which needs to be maintained and kept an eye on), I'm wondering if there is any means to achieve the same with only one process model.

Regards,

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Dear Stefan.

    I must admit I didn't understand what you are pointing on.

    In the meantime, I figured out that when I define a value for a process variable (Process properties -> Edit process variable -> Value) it behaves as a default value - if no value is provided on process start (for example on new record action), the default value is used - if it is provided (for example for edit record action) it is ignored.

    I was not aware of this (the description for value in Appian doc is a little bit confusing) and as there is no need to check if variable is null or populated I can use it to initialize the record.

    If you (by your comment) meant the same, thank You very much for your effort. If you are referring to another approach, kindly asking for clarification as alternative options are always welcome.

    Regards,