mike4aday / SwiftlySalesforce

The Swift-est way to build native mobile apps that connect to Salesforce.
MIT License
136 stars 43 forks source link

MyRecords() func assumes object has 'ownerId' column #128

Closed perbrondum closed 3 years ago

perbrondum commented 3 years ago

If the new MyRecords is to be used across objects it should not use 'ownerid' in predicate.

mike4aday commented 3 years ago

Hi @perbrondum not sure I understand your objection. myRecords is meant to be a convenience method: callers don't have to know the logged-in user's ID, and the OwnerId field is present on most objects. If myRecords were to be called with a type that doesn't have an OwnerId field, the publisher will fail with an error. In such cases, it's always possible to write a custom SOQL query for a particular object using the query method instead.

mike4aday commented 3 years ago

@perbrondum I'll add a note to the documentation so it's more explicit that the type argument has to be for an SObject type that does have the ownerId field.

perbrondum commented 3 years ago

Good points. We always use createdById (unless in object sharing mode) as all objects have them and it has no ambiguity. OwnerId has implications for delegation and makes assumptions on account model that are more complex and as such most implementations have ownerId = createdById.

Per B Jakobsen CEO Tap2Sales.com @.***

On Jun 7, 2021 at 2:09:52 AM, Michael Epstein @.***> wrote:

@perbrondum https://github.com/perbrondum I'll add a note to the documentation so it's more explicit that the type argument has to be for an SObject type that does have the ownerId field.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mike4aday/SwiftlySalesforce/issues/128#issuecomment-855487181, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALCYWDCS6QSWBRN7OSD3G63TRQE5BANCNFSM46GK6QSA .

mike4aday commented 3 years ago

@perbrondum Cases and Accounts, for example, are routinely reassigned after creation and then would have CreatedById != OwnerId no?

perbrondum commented 3 years ago

Exactly.

Per

On Jun 7, 2021, at 5:23 PM, Michael Epstein @.***> wrote:

 @perbrondum Cases and Accounts, for example, are routinely reassigned after creation and then would have CreatedById != OwnerId no?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

mike4aday commented 3 years ago

@perbrondum I don't understand - if I'm interested in querying records I own, e.g. cases or accounts for which I'm responsible, and regardless of who or what process originally created the records, then querying for records where my user ID equals the records' CreatedById wouldn't work, no?

perbrondum commented 3 years ago

Correct. OwnerId was added to denote assignment or delegation. So, in account sharing mode, the owner creates events with createdById != ownerId. No disagreement here.

My original objection was that ownerId was added to a func that accepts all object types.

Per B Jakobsen CEO Tap2Sales.com @.***

On Jun 7, 2021 at 6:48:09 PM, Michael Epstein @.***> wrote:

@perbrondum https://github.com/perbrondum I don't understand - if I'm interested in querying records I own, e.g. cases or accounts for which I'm responsible, and regardless of who or what process originally created the records, then querying for records where my user ID equals the records' CreatedById wouldn't work, no?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mike4aday/SwiftlySalesforce/issues/128#issuecomment-856097867, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALCYWDBOVXL5OGW7KL2PIJ3TRTZ4TANCNFSM46GK6QSA .

mike4aday commented 3 years ago

@perbrondum thanks. I added a note to the documentation that the method is for types with OwnerId field and reference to docs.