Unable to call Groovy script class in Process variable

I have make a Groovy script to set the default data for the widgets in the form. The code is as below:

package com.company.setting

public class DefaultValue {

public static String mail = ""
public static String phone = ""


public DefaultValue (){
}


public static Initiate() {

this.mail = "abc@def.com"
this.phone = "123456789"

}

}

Then I make a process variable with the below script:

def setting = new com.company.setting.DefaultValue ()
setting.Initiate()
return setting.mail

 

When I start the process, and submit the initiate form, I have an error:

BScript9.groovy: 1: unable to resolve class com.company.setting.SettingValue
 @ line 1, column 15.
   def setting = new com.company.setting.SettingValue();

Then, in one of my form, I setup a form variabe to get this value:

../API/bpm/caseVariable/{{task.caseId}}/defaultMail

What did I do wrong?

Hi,

Please make sure that the script is added to the process configuration.
Select your process and click on the configure button in the toolbar (wrench icon), in the process dependencies your scripts and its dependencies must be selected to be added to the built Business Archive.

HTH
Romain

Thanks. Somehow I miss this part.

Another question: Is there any way to get this variable in the Initiation form? As I understand, in the Initiation form, the task is not created yet, so the form cannot get the task and caseId. is there any way around this issue?

I suggest using the a business variable (BDM) for storing referential data, their lifecycle is not tightly coupled to the process instance.

You can then access them using the /API/bdm/businessData/.. rest api in your process instantiation forms.

HTH