function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tarun J.Tarun J. 

Order of execution of Auto Number field and WF.

Hi,

 

I am having a scenario where I have to populate the value of a field through WF.

There a two fields on the Contact: Contact ID Auto (an Auto Number field) and Contact ID(Text field).

The scenario is:

If 'Contact ID' field is Null, populate it with the value of 'Contact ID Auto' field.

I have created a WF (Evaluation Criteria: Only when a record is created) which checks for the 'Contact ID =Null' and populate its value with 'Contact ID Auto'.

 

 

Issue: Sometimes the WF works fine and populate the correct value while sometimes 'Contact ID' field remains blank.

Is there any time difference in 'value getting updated in auto Number field' and 'the Execution of WF'?

 

Please suggest.

 

Thanks in advance.

 

 

 

AmitSahuAmitSahu

Hi, Are you sure the records are not old ?

Also you can use the everytime a record is created /edited  WF.

 

Regards,

 

J

Tarun J.Tarun J.

Hi J,

 

Thanks for the reply.

The WF is pretty old and the records are new.

The main issue is that this WF works for some records while for other records the field remains blank.

Is it something like: Order of assigning value to the Auto Number field is not in sync with the execution of WF.

SachiiSachii

why dont you try changing Contact Id as a formula field copying value from Contact Id Auto field?

 

The workflow <referring to an auto-number 'Name' field> sometimes gets affected when a number of records are created simultaneously and population of auto-number takes few extra micro/milliseconds.

 

 

Tarun J.Tarun J.

Hi Sachii,

 

As per Business requirement, we have to keep that field editable. That's why we can't go for formula field.

There might be some delay in population of auto-number task coz of which the WF left the 'Contact Id' as blank. But these things are not documented anywhere in salesforce help.

SachiiSachii

First of all, requirement of this nature is very very rare to copy the value from auto-number field to a text field by a workflow. Probably, Salesforce must have missed to test this scenario. The other point here, the email notification<referring the auto-number field> by a workflow never showed up a blank value (atleast as of my experience).

 

And I can think of 2 solutions for this kind of requirement.

 

1. Writing an 'after insert' trigger to copy the value from auto-number 'Name' field to the custom text field. This should work 99.9% I believe.

 

2. Create a new formula field [Dummy Field] to calculate "CreatedDate-59 minutes". Create a time-based workflow to trigger 1 hour after [Dummy Field] to copy the value from auto-number field to the custom field. This should ideally update the custom text field 1 minute after creation of the record. But please note that the time-based action depend on the queue load. And you can't refer this field with 100% confidence in the other Triggers or workflows. I have experienced that a time-based action triggered around 5 minutes later than the expected time because of the queue load.

 

<I would never recommend the 2nd solution as this would be the worst possible solution and also I never really have tried this before writing here ;-). Just wanted to mention this could also be a possible way>

 

Good Luck!!!