text - Field value to Prefix Value of number field (next Number) with JS or PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tm8
    Junior Member
    • Aug 2016
    • 6

    text - Field value to Prefix Value of number field (next Number) with JS or PHP?

    Hello,
    how can I implement the following:

    Create New Account -> Here I have a text (type) - field as I type as DE
    a second field "type number (next number)". When save the new account should the value "DE00001" save to the number field.

    In the field manager is the number field configured to the parameters of the prefix is empty for default.

    How can I use Javascript to insert a value in the file account.json in the number field to the parameter prefix.

    So I always have to set the parameter prefix in the field number newly, from the entry in the text field by creating new account.

    I hope I have made myself clear.

    How can I write a value for the parameter "prefix" in the number field with javascript write to the account.json?

    Thank you.
  • grzegorzgie
    Member
    • Jun 2016
    • 31

    #2

    Do not quite understand , you want to make it one box , which automatically increases its value? Or 2 fields that you want to connect ? For example XXX 123456 ?

    Comment

    • tm8
      Junior Member
      • Aug 2016
      • 6

      #3
      Hello,
      I want to combine two fields. The Number of the field function is not sufficient. I need a variable prefix before the Counter.

      This should work like this:

      Field one is a text field.
      Field two is a number field, without the default prefix (which is not variable in the account form)

      In one field is made by the user input (eg. DE for Germany). When saveing ​​the account in field two (Number field) entry composed to as "DE0001". "DE" from field one.

      User created a new account in Input Field one example "EN" for England. When saveing ​​the account in field two (Number field) entry composed to as "EN0002". "EN" from field one.

      I hope this is understandable.

      I need a variable prefix for each new account from the input in field one. field two is then of field one and the Counter (field two) composed.

      It is a customer number be generated which includes an abbreviation of the buyer's country.

      Thanks, I'm glad for any tip.

      I sit now already three days before this problem.

      Comment

      • grzegorzgie
        Member
        • Jun 2016
        • 31

        #4
        n my opinion, you need to create a field Enum and auto-increment.
        Enum this example: EN, DE allowing to choose one box per customer.

        The combination of these fields is done in such a way:

        application\Espo\Modules\Crm\Resources\metadata\en ityDefs\XXX.json
        "XXX": {
        "type": "Person",
        "view": "crm:views/XXX/fields/controller"
        }



        And in the file controller.js

        Espo.define('Crm:Views.XXX.Fields.Person', 'Views.Fields.Person', function (Dep) {

        return Dep.extend({

        afterRender: function () {
        Dep.prototype.afterRender.call(this);

        copy: function (fieldFrom) {
        var attrList = Object.keys(this.getMetadata().get('fields.address .fields')).forEach(function (attr) {
        destField = this.name + Espo.Utils.upperCaseFirst(attr);
        sourceField = fieldFrom + Espo.Utils.upperCaseFirst(attr);

        this.model.set(destField, this.model.get(sourceField));
        }, this);

        },

        });
        });





        I have not tested but I think it should work.
        If you can not then I'm sorry but I do not know very well Espo.

        Comment

        • yuri
          Member
          • Mar 2014
          • 8442

          #5
          I think you can change prefix only in backend.

          file
          application/Espo/Hooks/Common/NextNumber.php
          function
          composeNumberAttribute
          Last edited by yuri; 08-22-2016, 07:26 AM.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          Working...