You need to sign in to do that
Don't have an account?
Any way to create ID field for new SObject before insert
Is there a way you can create/set the Id field of a new SObject before performing an insert DML statement?
I know you can set it to an existing Id like this:
SObject s = Database.query('Select Id from account limit 1')[0].getSObjectType().newSObject([SELECT Id FROM Account LIMIT 1][0].id);
But is there a way to set it for a newly created SObject?
I need to create a few objects, retrieve their Ids and then send them to another system via a web service callout. I cannot issue a web service callout after the DML statement (without using @future call), so I'm trying to get the Ids and send them before actually making the insert DML statements
Any help would be appreciated, even it if it's "You can't do that."
Thanks,
Steven
You can't do that. Depending on what the external system is doing, you may want to look into externalId fields, which would allow you to control the value of the externalId before insert, and the external system can do most operations using the externalId instead of the salesforce Id.
All Answers
You can't do that. Depending on what the external system is doing, you may want to look into externalId fields, which would allow you to control the value of the externalId before insert, and the external system can do most operations using the externalId instead of the salesforce Id.
Thanks for the quick response.