This is a question about the
isSet function on SObjects.
Even though the documentation says it has a void type, it really is a boolean.
The sample in documentation provided is quite simple and works fine:
Contact c = new Contact(LastName = 'Joyce'); System.assertEquals(true, c.isSet('LastName')); System.assertEquals(true, c.isSet(Contact.LastName));
isSet function doesn't seem to work for
OwnerId only when using the
Schema.SObjectField parameter version
Contact c = new Contact(OwnerId = UserInfo.getUserId()); System.assertEquals(true, c.isSet('OwnerId')); // works fine System.assertEquals(true, c.isSet(Contact.OwnerId)); // Fails
isSet with other polymorphic lookup fields like
Task.WhatId and this behaviour appears to be the same for those as well.
Is this expected? what am I missing