All,
Can someone explain to me if javascript for onLoad functions that write to an entity run under user context?
I have a few read-only users that get privWriteLead errors when opening up a lead. Left me a bit confused, but remember I have js that writes to Lead onLoad. I got rid of the error by giving the user read-write license level.
1)Can someone give me a low level explanation on why this happened?
2)How can I modify code to let this code write to entity for read-only user? -- I am confident this was root cause
Thanks and Regards.
*This post is locked for comments
I hope follwoing article will help you to understand the plugin article:
community.dynamics.com/.../how-to-change-a-plugin-run-in-user-s-context-programmatically
Hi,
In server-side plugins, we have InitiatingUserId and UserId in the IPluginExecutionContext.
UserId : Gets the GUID of the user for whom the plug-in invokes “on behalf of” (which can be given while registering Plugin step in Plugin Registration tool)
InitiatingUserId: Gets the GUID of the user who performed the action triggering the plugin.
rajeevpentyala.com/.../userid-initiatinguserid-properties-in-plugin-of-crm
Hope this helps.
Hey, Plugin can be set to run as Admin Context. But when you check the auditing history, it will shown up as Admin instead of the user it self and will make you hard to inspect. I suggests why not just give the user the correct security role?
Hello J.O,
When you write plugin you can configure on which user context you want to run your plugin code. By default it will set as Run in User's context, so you can run it on the current user context just like JS code or you cam set specific user there on which you want to run your plugin code.
You do have different option for impersonating users, I will suggest you to go through this KB: msdn.microsoft.com/.../gg309416.aspx it will help you.
Goutam stated, "By default client side script run in user context ..." Makes sense that the client will always run in user context....what about if I rid the js and right the plugin to do what I whant? Still user context?
AAccess-Teams-Template.png"_blank" href="/api/data/v9.1/msdyn_richtextfiles(0559E2F8-31AD-4792-957A-C7E85182FDD9)/msdyn_imageblob/$value?size=full">community.dynamics.com/.../Access-Teams-Template.png
community.dynamics.com/.../access-teams-and-access-team-templates
Please let me know.
Thanks.
Excellent sir. Thank you. What if I update entity server-side? Will it still run in user context?
Are you updating entity in the form onload ?
By default client side script run in user context so the user which you are logged in does not have the entity write privilege and when you are trying to update the entity its throws error. .
In this scenario I would suggest give the write access to the entity and implement two role based forms (Editable ,read only) for the entity. Based on user assign roles display the editable and read only form.
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
52
Victor Onyebuchi
6