1. Why This Is Useful
When you need to call another BeanShell helper dynamically, hash invocation keeps your main script small and reusable.
This pattern builds a hash string at runtime, executes it with AppUtil.processHashVariable, and captures the output for reuse.
2. Where to Use in Joget
- Workflow Tool scripts that need reusable helper logic.
- Form/Post-processing scripts that call another BeanShell utility.
- Notification-related scripts where output from another function is needed first.
3. Core Idea
- Build the hash string with required parameters.
- Execute it through
AppUtil.processHashVariable(...). - Use returned value in logs, payloads, or downstream logic.
Example hash format used:
#beanshell.captureResponseNotification[process_id=YOUR_PROCESS_ID]#
4. Full Working Code
import org.joget.apps.app.service.AppUtil;
import org.joget.commons.util.LogUtil;
import org.joget.apps.app.model.AppDefinition;
import javax.servlet.http.HttpServletRequest;
import org.joget.workflow.model.WorkflowAssignment;
import org.joget.apps.app.dao.UserReplacementDao;
import org.joget.apps.app.model.UserReplacement;
import org.joget.directory.model.User;
import org.joget.directory.model.service.DirectoryManager;
import org.joget.workflow.model.WorkflowProcess;
import org.joget.workflow.model.service.WorkflowManager;
import org.joget.workflow.util.WorkflowUtil;
import java.util.HashSet;
import java.util.Collection;
import org.json.JSONObject;
import org.json.JSONArray;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import org.joget.apps.form.service.FileUtil;
import java.util.Base64;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.joget.apps.app.service.AppUtil;
import org.joget.commons.util.LogUtil;
/*
// c_code #variable.branch_code# and locale
public String getBranchName(String locale){
String callHashToInsertResponse =
"#beanshell.getComplaintDetailsForEmail[c_code=" + "#variable.branch_code#" + "&locale="+ locale + "]#";
// Evaluate hash
String result = AppUtil.processHashVariable(callHashToInsertResponse, null, null, null);
return result;
}
*/
String ProcessID = "testing the process id";
// build valid hash format
String callHashToInsertResponse =
"#beanshell.captureResponseNotification[process_id=" + ProcessID + "]#";
// Evaluate hash
String result = AppUtil.processHashVariable(callHashToInsertResponse, null, null, null);
LogUtil.info("Email Integration - API", "Evaluated Hash = " + result);
5. Quick Validation Checklist
- Verify the target BeanShell function name is correct.
- Confirm all required parameters are included in the hash.
- Log output once to validate returned value.
- Test with safe sample process IDs before production use.
6. Security and Publishing Note
- Replace real process IDs, variable names, and function names with placeholders in public content.
- Avoid exposing internal workflow naming conventions.
7. Final Note
This is a strong pattern for reusable Joget scripting: one script orchestrates, another script handles details, and hash invocation connects both.
Follow-up topic: Building a shared BeanShell utility library for multi-process reuse.