How to define variables to Process Scope and Task Local Scope

Here,How to define Form Field Variables as Process Variables and Task Local Variables using Script(Javascript) in modeler.

im trying like this in Create Task Listener.

task.setVariableLocal(“Name”, “”);
task.setVariableLocal(“Email”, “”);
task.setVariableLocal(“DOB”, “”);
task.setVariableLocal(“PWD”, “”);

and created Task Listener on complete.

var name= task.getVariable(“Name”);
if (name!= null){
task.setVariableLocal(“Name”, name);
}
var dob= task.getVariable(“DOB”);
if (dob != null){
task.setVariableLocal(“DOB”, dob);
}
var email = task.getVariable(“Email”);
if (email != null){
task.setVariableLocal(“Email”, email);
}
var pwd = task.getVariable(“PWD”);
if (pwd != null){
task.setVariableLocal(“PWD”, pwd );
}

The Form Fileds(Process variables ) are

But here when im trying above approach i can not see the Form Field(Process Varibles) in process scope after complete task on cockpit.

I want to define the all Form Field Varibales for Both Scopes Process Scope and Task Local Scope. please suggest

Hello @aredd119 ,

it looks like the behaviour described is what you wanted to achieve? First, you set the variables in local scope and then fill them in the form. In the end, you set the variables again in the local scope.

If you want the variables in both scopes, your second snippet should use the method

 task.setVariable("varName", varValue);

Also, the get method above only works because it cascades through the scopes to search for your variable.
Hope this helps

Jonathan