0

I have an object with a Unique External ID field. It works fine but have a good amount of already existing records with the same value in the field. And I have a Flow which needs to populate a field on these records via another object. It is unable to do this now because it is unable to save the records w/ the duplicate unique external field.

Is there any way to save these records ? I don't think you can just conditionally make the unique external ID field be enforced.

Thank you for any insight.

  • 4
    The uniqueness is enforced at the database level, so you can't override it. You're going to have to come up with a different solution. – sfdcfox May 17 '18 at 19:48
  • That's what I figured. I think I'm screwed. If I knew how to do it I would probably just write a pre-open trigger for the record which will attempt to populate the object w/ the unique field and if I found multiple records w/ that field I would know it's going to be impossible to save it and so populate two fields in the not yet saved record and have a validation rule which compared those two fields and upon seeing they were both the same it would say something like it can't be saved because the record it will attempt to populate upon saving is a duplicate of a unique field etc... – Zoom_v May 18 '18 at 0:21
1

This is the right time to go for long term solution in terms of data.

If Salesforce is source of truth then you can easily create a unique external Id values and update entire recordsets.

If other system is source of truth, then compare the duplicate external Ids with the external system and update those in Salesforce. You might need to de-duplicate the data.

This type of issue occurs during initial data load, where you may have created external id field and loaded the data as insert (instead of upsert) and then external id has been marked as unique field.

After cleaning up data you can perform work normally.

Better raise this concern upfront.

| improve this answer | |
  • The only thing I've got going for me is that the records don't become in violation of the unique ids until a workflow rule runs to populate the unique id field upon saving it. So, if I can think of the proper logic for the workflow rule to not run I can still save the record - because the unique id field will not be updated. There are specific fields which get updated by the external object which I'm mentioning. So, I could possibly put into the workflow rule criteria IF(IsChanged(field__c) - then don't run the workflow rule - because I would know that other object is initiating the save. – Zoom_v May 18 '18 at 3:42
  • That could be a good option and you know your use case better than me – Santanu Boral May 18 '18 at 3:44

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.