0

I am working on a flow to generate a grant contract number when each time a grant contract is created. For each record type there is a different starting number

Grant Record Type   starting Number Ending Number
WTFPG                 2300010   2301999
SAT                   2304011   2306999
Exp                   2330001   2333999
YW                    2370105   2370999
DYSC                  2371000   2371999
Exec                  2396101   2396199

Here I have stored the value 23 into a formula variable in a flow.I have to concatenate this 23 with the remaining part of the number and each time a record is created a counter is to be provided to increment the value ie for first record of WTFPG the number is 2300010 next it will become 2300011 and so on...

I have used a flow to get the grant contract record each time it is created and added a decision box after this for each record type.. I am planning to use update records after this so that for each decision outcome(ie for each RT outcome)the corresponding formula can be used in the update record to update the grant contract.

But I am confused about how to implement this using formulas and how to set counters.And also if in between a record is deleted then how this number chain will continue(how can i fix that)

As of now I have created a flow like this:

enter image description here Also text is not editable in the object to autonumber so that way isnt possible.

1 Answer 1

1

The first part of the number is easy presuming you can hardcode that as a value in the FLOW. In the solution I built in my org I called the variable startingNumber and it is of type Text with a default value of 23

startingNumber

For the WTFPG example where it then starts with 00010 I would create a AutoNumber field on the "Grant Contract" object which you may or may not put on the page layout associated to the WTFPG record type page layout.

The format for this AutoNumber field would be {00000} and the starting number would be 10

The benefit of an AutoNumber field is you never need to be worried about what the next number is. Salesforce handles it for you.

Create a FLOW that is a Record Triggered Flow of type Actions and Related Records. You need this type for the AutoNumber field to work correctly.

For the creation of the Grant Contract Number I used an assignment block like this

createGrantContractNumber

Notice the first assignment is Equals but the second assignment is Add This concatenates the values of 23 and 00010 together to give you a Grant Contract Number of 2300010 as per your requirements.

To then record 2300010 on your new Grant Contract record I did an Update Record updateRecord

I placed the result in the Name field but you'll probably want to place it into a different field.

My entire flow looks like this Flow

You'll need to expand on my work to allow for Record Types but if it works for one, which it does in my org, then it will work for all Record Types.

EDIT As per your comment here's a screenshot of how I setup the AutoNumber field autonumber format As you can see it is not necessary to have the A- at the start. Delete it and leave just {00000}

3
  • @Mathew Harris Thanks so much I tried for one record type and it is working.But is there any way to change the autonumber display format from A-{0000} to just {0000}
    – JK123
    Jun 21 at 14:25
  • 1
    Just remove the A- in your example and have {000} by itself. This is how my field looks Jun 22 at 0:12
  • @Mathew Harris Thanks it worked.Is there any alternate way to work on this without using autonumber in a flow.Or is it better to use trigger for this.
    – JK123
    Jun 23 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.