Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hi Mike M
Do try copying the beanshell from the Settings form of the free Service Helpdesk app in Joget Marketplace. It has a working code you can easily emulate.
Thanks Matthew ...
Actually this is exactly what I did - copy and pasted from the following article: Manage Environment Variable using Form
the load works fine by itself and the store works fine by itself - but not together when both load and store binder exist in the form - is it a bug? or, most probably, am I missing a simple step?
Hi Mike M
The free Service Helpdesk app in Joget Marketplace has working code to retrieve and store the env variables in the Settings forms. You can copy and paste the code for Load and Store Beanshell codes into your form to try.
The free Simple Leave app in Joget Marketplace also has similar Load and Store Beanshell codes you can learn from. I encourage you to download and explore all the free apps and plugins in Joget Marketplace to help you in your journey in Joget development.
Cheers.
I am trying to modify environment variables via a form.
I am getting "Undefined argument: rows" following steps described in: Manage Environment Variable using Form
ERROR 28 Jul 2016 11:21:06 org.joget.apps.form.lib.BeanShellFormBinder - Error executing script
Sourced file: inline evaluation of: ``import java.util.Collection; import org.joget.apps.app.dao.EnvironmentVariableD . . . '' : Undefined argument: Rows : at Line: 49 : in file: inline evaluation of: ``import java.util.Collection; import org.joget.apps.app.dao.EnvironmentVariableD . . . '' : ( element , Rows , formData )
The load Binder works but not the store binder in the userview - how can i correctly define "rows"? what is the wrong with the provided code? here is the code:
import java.util.Collection;
import org.joget.apps.app.dao.EnvironmentVariableDao;
import org.joget.apps.app.model.AppDefinition;
import org.joget.apps.app.model.EnvironmentVariable;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.apps.form.model.FormStoreBinder;
import org.joget.commons.util.LogUtil;
import org.joget.plugin.base.PluginManager;
public FormRowSet store(Element element, FormRowSet rows, FormData formData) {
//check the rows is not empty before store it
if (rows != null && !rows.isEmpty()) {
AppDefinition appDef = AppUtil.getCurrentAppDefinition();
EnvironmentVariableDao environmentVariableDao = (EnvironmentVariableDao) AppUtil.getApplicationContext().getBean("environmentVariableDao");
//Get the submitted data
FormRow row = rows.get(0);
//Add / Update each Environment Variable
for (Object key : row.keySet()) {
String envId = (String) key;
String value = row.getProperty(envId);
if (!envId.isEmpty()){
EnvironmentVariable e = environmentVariableDao.loadById(envId, appDef);
if (e != null) {
e.setValue(value);
environmentVariableDao.update(e);
} else {
EnvironmentVariable e = new EnvironmentVariable();
e.setAppDefinition(appDef);
e.setId(envId);
e.setValue(value);
environmentVariableDao.add(e);
}
}
}
}
return rows;
}
//call store method with injected variable
return store(element, rows, formData);