Transferring a local variable in an interface into a process variable

Hi all,

I have a pickerFieldUsers field in my interface that I use to store a username into a local variable "local!userToTransferTo" which looks like this:

a!pickerFieldUsers(
label: "New Owner",
labelPosition: "ABOVE",
saveInto: local!userToTransferTo,
value: local!userToTransferTo,
required: true,
validations: {},
placeholder: "--Start typing officer name--"
),

The interface that contains this field is a Process Start form for a process model.  The process model [also] has a process variable of type "User" which is called "PVUserToTransferTo".

Back in my interface, I have a buttonWidget inside a buttonArrayLayout that looks like this:

a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Transfer",
style: "NORMAL",
saveInto: {
a!forEach(
local!dataGridSelection,
a!save(
target: null,
value: local!dataGridSelection
)
) /*,
a!save(
pv!PVUserToTransferTo,
local!userToTransferTo
)*/
}
)
},
align: "START"
)

There's actually two problems I'm trying to solve here.  The first problem - the one that I am asking at this time - is how to get the value that gets stored in local!userToTransferTo from the pickerFieldUsers object into the process variable PVUserToTransferTo where I can subsequently use the data in the rest of my process model.  When I un-comment out the code:

a!save(
pv!PVUserToTransferTo,
local!userToTransferTo
)

The form fails to render/compile, so this code is clearly wrong in some way.

Can someone advise how I get the value that is entered into the pickerFieldUsers object into a process variable that I can use in my process model?

thanks heaps,

David

In my process model properties

  Discussion posts and replies are publicly visible

  • Hello David,

    It is important to understand the execution context, when you are in the process context(domain) you have access to the process variables pv!. When you are in a smart service or process node you are on the activity class context ac!  (domain) and when you are on a rule ( expression, interface, or so) you are on the rule context (domain) where you have rule inputs so you have ri!.

    You should map the values between the context  you create a node data input variable ac! That you will map and set up the value that comes from the process and later you have a rule input (the same type always, that will receive the activity class variable.

    pv! -> ac! -> ri!

    And you have to do the same when you want to receive a value from the interface.

    ri! -> ac! -> pv!

    The rrror you are experiencing is that you are trying to access a process variable that is not visible on the interface just because you are not in the context.

    Here you can find a discussion about the same

    Hi, I am using 18.1 and trying records tutorial by following https://docs.appian.com/suite/help/18.1/Records_Tutorial.html I was stuck at Add a Related Action point 4 where we need to pass process…
    By in Discussions > Process
    8 replies

    Hope this helps

    Jose

  • +1
    Certified Associate Developer

    Hi David, 

    You cannot save any value into process variable as part of saveInto in an Interface. As Jose mentioned above, the values should be transferred to a variable based on the variable context.

    In your case, it is a start form and in order to save the users value in the process variable, create a rule input in the interface and save the value in that rule input. While configuring interface, map the rule input with the process variable you would like to save the values in the 'Process Start Form' as shown in the below snapshot. Please note the process variables should be selected as parameter in order to appear in the mappings in Process Start Form. 

    Hope this helps. Cheers!

  • Thanks heaps - that's got it....

    created a rule input for the form "RIUserToTransferTo" and changed my save code to:

    a!save(
    ri!RIUserToTransferTo,
    local!userToTransferTo
    )

    which seems to be accepted.  

    cheers :-)

  • Unless you're intending to use the local!userToTransferTo for something else you could simply point your a!pickerFieldUsers component directly at the rule input:

    a!pickerFieldUsers(
    label: "New Owner",
    labelPosition: "ABOVE",
    saveInto: ri!userToTransferTo,
    value: ri!userToTransferTo,
    required: true,
    validations: {},
    placeholder: "--Start typing officer name--"
    ),