Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hi!
I just set up joget workflow on my computer and I need to copy the selection from select box to a read only textfield. I'm new to beanshell. How can I do this?
thanks in advance
EDIT1.:So if I am right this code stores the value from the selectbox in the variable "sbvalue":
import java.util.Collection;
import org.joget.workflow.model.*;
import org.joget.workflow.model.service.*;
WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");
String sbvalue ="#formName.fieldName#";
I suppose i only need to add the value of "firstname" to the read only text field but i did not find anything that helped me. Also I dont know where toput this code in the form.
5 Comments
Pete
Here's one way you might be able to do it.
Create a form with 2 sections; one has your select box and the other has your read-only text field.
Edit the section with the text field and under 'Choose Load Binder' (at the top), pick the Bean Shell Form Binder.
Click the 'Configure Bean Shell Form Binder' and add your Beanshell code into the Script textarea.
To get your form variable (for your select box value) you want to use the hash variable #form.formDataTableName.fieldName#. More on Hash Variables here.
Here's some code that might help you out.
sz.e.
I have only one question. To what do "clientFirstname" and "appService" refer?
Pete
"clientFirstname" is the Id of the form field you want to modify.
"appService" is how the code internally knows how to look up the AppService reference object (so you can use it later in the Bean Shell script.) Behind the scenes, Joget uses the Spring Framework, for among other things, controlling and injecting reference objects. Long story short, you don't need to change that value.
I haven't tried this, but you might be able to just add the #form.formDataTableName.fieldName# into the value of your read-only field. (I'm not sure when the form fields get saved.) If that works it might be much simpler than writing Bean shell code.
The third thing you could try which most definitely will work is include some Custom HTML/Javascript into your form to pull the data from the form select box and put it in your read-only field. That might be your best option.
sz.e.
Thank you! You helped me a lot! <3
sz.e.
<form>
<input type="button"
value="Kitöltés!"
onClick='myFunction()'
/>
</form>
<script type="text/javascript">
function myFunction()
</script>
this ustom html code copies the current value of the field with the id hrsz_cim to a field with an id asd.