douglascayers / sfdc-convert-notes-to-chatter-notes

📓 Easily migrate your Notes to Enhanced Notes.
https://douglascayers.com/2017/05/08/convert-notes-to-enhanced-notes/
BSD 3-Clause "New" or "Revised" License
26 stars 11 forks source link

Inactive owners #3

Closed NimaNotes closed 7 years ago

NimaNotes commented 7 years ago

HI Doug,

As you have mentioned on your posts I have updated all the inactive owners of the notes to an active owner as a pre step but still am receiving 'This user is inactive' error message.

I was looking at the 'ConvertNotesToContentNotesService' class and noticed below lines(#79,#80) of code where we are setting the owner of the contentNote to be same as whoever has created the Note.

ownerId = note.createdById, // system requirement, owner and creator must be the same createdById = note.createdById,

In this case should not we change the code to below lines of code?( if we dont then createdByid is still an inactive user as we just updated the owner to be active)

ownerId = note.OwnerId, // system requirement, owner and creator must be the same createdById = note.OwnerId,

I have updated the code in the class manually myself but am still receiving the same error message. I have also given the user permission to 'Update Records with Inactive Owners'.

I would appreciate if you could please check those two lines of code and let me know if I am missing something.

douglascayers commented 7 years ago

Hi @NimaNotes,

Good catch on the createdById vs. ownerId. I'll make the change to use the ownerId instead.

If you've made the code change and still getting error, can you confirm you're in an org that's on Summer '17 (API 40.0) release? It's in the Summer release where Salesforce updated their API to respect the Create Audit Fields on ContentNote object.

Thanks,

Doug

NimaNotes commented 7 years ago

Hi Doug,

Thanks for getting back to me on this. Yes, its summer 17 (API 40.0) release and I was getting the same error after using ownerId instead of createdById but then I realized the new active owner that I used to update the existing notes had the password expired. Once I reset the password and logged in from UI tried the code again and it worked this time.

We have the same issue for attachments too and since thats a managed package I dont know if you are using the createdById or ownerId, is that something you can please check from your end?!

Thanks a lot for all your helps on these two apps!!!

Nima

douglascayers commented 7 years ago

Thanks for the update @NimaNotes.

Yes, the Attachment's conversion uses the same logic so I'll update it too to use the OwnerId instead of CreatedById.

Thanks!

douglascayers commented 7 years ago

Fixed per https://github.com/DouglasCAyers/sfdc-convert-notes-to-chatter-notes/pull/5