Auto-Incremento

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kako
    Junior Member
    • Apr 2026
    • 4

    #1

    Auto-Incremento

    Ola,

    Estou querendo criar um campo no "Oportunidade" que fosse auto-incremento, tipo: AAA-000001

    Alguém sabe onde encontro aolguma informação? Já tentei hoock, mas não consegui.

    Alguma ajuda?

    Obrigado
    kako
  • Kharg
    Senior Member
    • Jun 2021
    • 493

    #2
    This extension by eymen-elkum does it:
    Espocrm, New field type named "Number Pro" Similar to Espocrm Number field (auto increment) but you can make it incremental in groups You can pull the prefix from a linked entity varchar field You can specify an int field on the linked entity to hold the counter indicator There is separator param, optional with pad length like in Number fieldUse CaseOn of the most use cases is the order and order items, so if the order has number field you can add number pro to the order item that prefixed by the number of the orderSo if Order number is: O-00046The Order item number will be: O-00046-0001 Read information about the extension . Release notes are available here.

    Comment


    • shalmaxb
      shalmaxb commented
      Editing a comment
      This extension is a bit more advanced as it provides the possibility to have as much incrementals as you like, e.g. for product numbering, where every product will have its own incremental. I use that extension to count graphic edition copies and succeded to have a solution, which would not be possible in any other way,
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9794

    #3
    Number field? https://docs.espocrm.com/administration/fields/#number

    Comment

    • kako
      Junior Member
      • Apr 2026
      • 4

      #4
      Hi, yuri

      Ok, I found it.

      In the prefix, I'd like to put XXX-YY (three letters - current year). How can I include the year?

      Comment

      • shalmaxb
        Senior Member
        • Mar 2015
        • 1864

        #5
        you can have your increment number and use a second field for any prefix or suffix, for example year. Then you create a third field (Varchar) and by formula you concatenate the two former fields. So you can have 0001-2026, 0002-2026 and so on.
        You could even put the year changing every year by formula. Only if you would like to start every year again at number 1, you have to reset the incremental number to 1. Maybe there would be a programmatic solution for that as well, but I did not try yet.

        Comment

        • kako
          Junior Member
          • Apr 2026
          • 4

          #6
          Hi, shalmaxb
          I've tried several methods, formulas, hooks, scripts, and nothing works.
          I've already created two fields, one varchar and the other auto-increment, and concatenated them, but the varchar doesn't load the other field (auto-increment).
          But this new number field (auto-increment) works; I just want to put the current year in the prefix.

          Comment

          • shalmaxb
            Senior Member
            • Mar 2015
            • 1864

            #7
            aqui o meu procedimento

            PHP Code:
            //pega o ano
            invoiceYear = datetime\year(rechnungsdatum);
            
            //concatenate numero incremento com o ano
            invoiceNumber=string\concatenate(rechnungsnummer,'-', invoiceYear);
            
            invoceNumber1 = o campo de incremento, que ja vem com o prefixo 
            
            Resultado:
            campo varchar concatenado = prefixo-numero incremento-invoiceYear
            RE-0001-2026

            (rechnungsdatum = dataDaFatura, rechnungsnummer = numéro da fatura)
            o rechnungsdatum e um campo dateTime, de onde eu pego o ano.

            Comment

            • kako
              Junior Member
              • Apr 2026
              • 4

              #8
              oi, shalmaxb
              Obrigado
              Onde está implementando (Fórmula? Workflow? Hook?)

              Comment


              • shalmaxb
                shalmaxb commented
                Editing a comment
                apenas formula
            Working...