1
0
-1

I have Total 2 Application 

In application 1 i am using a post Processing Tool From that Application i am inserting Data to Application 2

But application 2 also contains Id Generator counter I have to Update that id Generator Counter of Application 2 using Application 1 

i have tried  EnvironmentVariableDao and 

getAppDefinition
public org.joget.apps.app.model.AppDefinition getAppDefinition(java.lang.String appId, java.lang.String version)

Finds the app definition based on the appId and version, cached where possible.

If version is null, empty or equals to AppDefinition.VERSION_LATEST, the latest version is returned.

but it is giving the App Definition of the Current Application only Not Working when i am passing the ID of other application.


I have Achieved How to Update the Current Application Environment Variable But not able to Update, Application2 Environment variable From Application1 

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.commons.util.LogUtil;
  
public void load() {
    AppDefinition appDef = AppUtil.getCurrentAppDefinition();
    if (appDef != null) {
        EnvironmentVariableDao environmentVariableDao = (EnvironmentVariableDao) AppUtil.getApplicationContext().getBean("environmentVariableDao");
        String envId = (String) "counter";
        EnvironmentVariable e = environmentVariableDao.loadById(envId, appDef);
        LogUtil.info("", e.getValue());
        e.setValue("100");
        environmentVariableDao.update(e);
    }

}
  
load();

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      I have found out other way to do that. 

      //Update Environment variable counter
                  String updateQuery = "UPDATE app_env_variable SET value = ? WHERE appId = 'your_app_id' AND id = 'counter'";
                  PreparedStatement updateStatement = con.prepareStatement(updateQuery);
                  updateStatement.setString(1, yourSetValue);
                  updateStatement.executeUpdate();
                  updateStatement.close();

        CommentAdd your comment...