0

I know that those questions asked a few times here - but I saw that it little old (Greater than 3 years) and\or it doesn't have the "best answer" so I hope something changed about it.

1) Is there a way to upsert by externalId autonumber field type? (without copying that field to new field with workflow).

2) Is there a way to store values in a Map from soql query that the key will be externalId - without go through on a list and insert the key,value within the loop?

Thanks.

1

1) Is there a way to upsert by externalId autonumber field type? (without copying that field to new field with workflow).

In fact, this is very likely something we will never be able to do. Doing so would break database expectations (e.g. you insert a value of out sequence, and so later there are duplicate values). It could have a lot of unintended side effects. Salesforce can't control the generation of the auto-number values if it can be influenced by an outside system, thus defeating the purpose of an auto-number field. You would necessarily need to write a trigger to implement this functionality.

2) Is there a way to store values in a Map from soql query that the key will be externalId - without go through on a list and insert the key,value within the loop?

No. Again, this is also likely something that will never happen. It's simply too specialized. If you have a specific need, you can write your own utility methods to reuse this, but don't expect Apex to have this kind of built-in support.

  • Thanks @sfdcfox for the detailed answer. – Salvation Apr 15 at 11:21

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.