You need to sign in to do that
Don't have an account?
Ab
Does upsert works like update
Hello,
For a custom object i have around 100 custom fields.
I want to update some fields, i know that with Update my fucntion will work but i was wondering if the Upsert does the same work too.
I dont want to loose the earlier values.
Thank you for suggestions
For a custom object i have around 100 custom fields.
I want to update some fields, i know that with Update my fucntion will work but i was wondering if the Upsert does the same work too.
I dont want to loose the earlier values.
Thank you for suggestions
Using the upsert operation, you can either insert or update an existing record in one call. To determine whether a record already exists, the upsert statement or Database method uses the record’s ID as the key to match records, a custom external ID field, or a standard field with the idLookup attribute set to true.
If the key is not matched, then a new object record is created.
If the key is matched once, then the existing object record is updated.
Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_upsert.htm
Thanks,
Dhanya
All Answers
Using the upsert operation, you can either insert or update an existing record in one call. To determine whether a record already exists, the upsert statement or Database method uses the record’s ID as the key to match records, a custom external ID field, or a standard field with the idLookup attribute set to true.
If the key is not matched, then a new object record is created.
If the key is matched once, then the existing object record is updated.
Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_examples_upsert.htm
Thanks,
Dhanya