1
0
-1

Help please,

I would like to concat the first and last name that a user enters in the CRM app when in add mode. In the Knowledge base, I have found this example:


  1. Choose Bean Shell Form Binder as the Form's Store Binder.


  2. Key in the following code.

    import org.joget.apps.app.service.AppUtil;
    import org.joget.apps.form.model.Element;
    import org.joget.apps.form.model.FormRowSet;
    import org.joget.apps.form.model.FormData;
    import org.joget.apps.form.lib.WorkflowFormBinder;
    import org.joget.commons.util.LogUtil;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.sql.DataSource;
     
    rows.get(0).setProperty("field2", rows.get(0).getProperty("field1"));
     
    new WorkflowFormBinder().store(element, rows, formData);

    In the code above, it will copy the value from form element with id "field1" into "field2".

  3. Save the form.


Will this work? if so, how do I use this option? Is there a better way to do this? And where do I find the "Form's Store Binder?

"Choose Bean Shell Form Binder as the Form's Store Binder."  (I am using the enterprise version)

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      To find the Form's Store Binder:

      On DX7 - 
      Go to your Form Properties > Edit Form > Go to Advanced > Set Load/Store Binder to Bean Shell Form Binder

      On DX8 - 
      Go to Form Settings > Configure Form > Go to Advanced > Set Load/Save Data to/from Beanshell


      The code mentioned seems to only set "field2" with the value of "field1", it would not add into the existing text if I understand it correctly. Maybe you can try get both of the fields of first and last name like:

      String firstName = rows.get(0).getProperty("field1");
      String lastName = rows.get(0).getProperty("field2");
      String fullName = firstName + " " + lastName;
      rows.get(0).setProperty("field3", fullName);


      Let me know if this works. Thanks!

      1. Ellen Earl

        nnd - 

        Thanks!

        I'm on DX8 and your instructions specific and helpful.

        And now I think that this may not be the best option for what I am trying to do here. 'cause I don't know how changing from the "> Set Load/Save Data to/from Beanshell" from the "default" option will affect the rest of the functionality of the CRM apps other fields - i.e. . Does changing to the Beanshell option mean I have to handle all the files fields manually?

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi,

      You can refer this first : > Text Field





      Or

      You could add a custom HTML form element in your form and add something like the following in it:

      <script type='text/javascript'>
      $(function(){
          $(document).on('change', 'input', function() {
              $('#fullname').val($('#firstname').val() + $('#secondname').val());
          });
      });
      </script>

      Let me know if this works.

      Thanks.

      1. Ellen Earl

        Thank you, Ginger!

        The custom HTML worked perfectly for the "Account Details" Tab subform.

        But, the info I wanted to load is a field in the "Account Parent" (Multiform) from the "Account Details" (Subform) TAB add mode. I wasn't able to get it to load correctly in the "Parent" field when in add mode. I'm pretty sure it's because of the function of the multiform function during add mode. (I should have been more clear on what forms I was trying to alter)

        I did get it to work on the Account Details Subform, the data is in the file once saved, and the Account List view and Account Detail edit view show it, so I am fine with that.



      CommentAdd your comment...