Hi, I think it is not possible for the beanshell to be passed on the client-side(Frontend UI) of the application.
BeanShell is a server-side scripting language used in Joget. It runs on the server, not on the client side. Therefore, you cannot directly pass JavaScript variables to BeanShell since JavaScript runs on the client side (in the browser), and BeanShell runs on the server.
However, you can pass data from JavaScript to BeanShell indirectly by using form fields as intermediaries
Add Hidden Field to Your Form:
html
<input type="hidden" id="hiddenField" name="hiddenField" />
Set Hidden Field Value Using JavaScript:
javascript
<script>
function setHiddenFieldValue() {
var jsVariable = "someValue";
document.getElementById("hiddenField").value = jsVariable;
}
setHiddenFieldValue();
</script>
Access Hidden Field Value in BeanShell:
java
import org.joget.workflow.model.service.WorkflowManager;
import org.joget.apps.app.service.AppUtil;
String hiddenValue = request.getParameter("hiddenField");
WorkflowManager wm = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
wm.activityVariable(workflowAssignment.getActivityId(), "procOutput", hiddenValue);
By following these steps, you can check whether you can pass data from JavaScript (client-side) to BeanShell(server-side) using a hidden form field in Joget.
You can try on your end. Let me know if it works.