You need to sign in to do that
Don't have an account?
Sol2012
Update owner in *custom* object (using a trigger)
Hello,
I have created a trigger that allows me to assign the proper owner to my opportunities.
I am willing to do the same on a *custom* object, but I cannot use the OwnerId: the (standard) API does not provide this field.
This is very rare for two reasons:
- The "OwnerId" field can be assigned by external tools such as "Apex Loader" and "Apatar connector".
- I can see all the other standard fields in my custom object, using the following code:
Map<String, Schema.SObjectField> m = Schema.SObjectType.MyCustomObject__c.fields.getMap();
Am I missing something here? Is there any workaround?
Thanks and regards
Is there any master detail relationship between your custom object, because in that case detail object do not have ownerId field.
Its implicit owner will be parent record's owner .
Thanks,
Lakhan
All Answers
Is there any master detail relationship between your custom object, because in that case detail object do not have ownerId field.
Its implicit owner will be parent record's owner .
Thanks,
Lakhan
Thank you Lakhan,
I figured out what had happened a couple of hours ago: I was using Apex Data Loader and Apatar against production, whereas I was testing a trigger in a Sandbox environment.
Exactly as you are pointing here, Sandbox environment had Master-Detail relationships, so those fields were hidden.
Thanks for your help anyway, and have a great day!