Using Auto-increment value in before save script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MrLue
    Junior Member
    • Jul 2024
    • 2

    Using Auto-increment value in before save script

    Hi,

    I have a question regaring auto increment fields...
    I am giving my leads an ID (auto increment variable called cId) and I giving them a string name that is used for several purpose containing that cId.

    I set up this cId as auto increment which works fine.
    Then I try a dummy test:
    $idstr = cId;

    $idstr is always empty or zero, tried with number format and so on.

    What am I doing wrong here?

    Best regards
    Lukas
    Last edited by MrLue; 07-08-2024, 08:23 AM.
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1606

    #2
    as far as I know, you can`t calculate increment fields by formula, as it is a database based value. If you could calculate it, it would cause problems with duplicates, regarding deleted records and so on.

    Comment

    • MrLue
      Junior Member
      • Jul 2024
      • 2

      #3
      Hi.
      I don't want to calculate the incement field, i just want to use it in calculation of other variables, e.g. a text field.
      However, the auto increment field value is always zero or empty when i use it in the script - could it be that auto increment fields are calculated after the save process is finished?

      Comment

      • rabii
        Active Community Member
        • Jun 2016
        • 1250

        #4
        You need an afterSave hook as it won't work with beforeSave formula.
        Rabii
        Web Dev

        Comment

        Working...