Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Initialize service using admin guid in javascript

(0) ShareShare
ReportReport
Posted on by

Hi All, I have a requirement that need to Initialize service using admin guid in java script. i need to get some entity data on client side where users don't have access to it only admin had access to it when users access some of the functionality in an entity. Could any one help me on this how can achieve this functionality. on server side i know initialize service using admin id as shown in below
IOrganizationService service = GetService(adminid).

But how can i achieve this on client side

*This post is locked for comments

  • Inogic Profile Picture
    Inogic 438 on at
    RE: Initialize service using admin guid in javascript

    Create a workflow that will have workflow assembly, which will run in context to the System Administrator( Which has appropriate privileges)and will be called from the JavaScript function. From this workflow you can pass the required data in output parameters which you can further use in your JavaScript function.

    You can refer this blog http://www.inogic.com/blog/2016/08/scenario-where-impersonation-in-custom-workflow-can-be-used-for-dynamics-crm/ 

  • tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: Initialize service using admin guid in javascript

    In CRM 2016 you can use Actions to achieve this quite easily. In CRM 2011 you can develop a "CRM Command pattern" as I like to call it. Create an entity called e.g. customCommand and set it to be not searcheable. It should have some custom attribute to store some value (I usually store some JSON there let's say it called Value). Add READ permissions for all users you want for this entity. Create a plugin that will fire on POST RetrieveMultiple for this entity.

    Now everything is just about creating the proper plugin for RetrieveMultiple. You can call retrieve for this entity with the filtering e.g. retrieve customCommand where Value equals "123456". In the plugin you can easily get this value from the Query and do anything you want even with admin context, so you can get some entities and put the value that you get in RetrieveMultiple result. Of course on JS side you will have to somehow get this information because you will get a list of customCommand objects but you get the idea.

    This approach can be used to avoid developing some custom WCF services.

  • RE: Initialize service using admin guid in javascript

    Hi Satish,

       I totally agree with Mark you can give the admin user another security role to achieve this function.

       But if you have to do it with customization instead of security role, there are some options:

    1. Use field security, expose the required field to some user or team which need to view the information.

    2. if your CRM is on premise, create a SSRS report with custom data source and use the EXECUTE AS statement to impersonate a user or login in SQL.

    3. exposed you CRM service to a custom web API or WCF service and call the service with admin authentication.

    check below link for more details:

    social.microsoft.com/.../impersonation-in-javascript

  • RE: Initialize service using admin guid in javascript

    Hi Mark, with out providing access to that entity how can achieve this i will provide access only to the admin only

  • Suggested answer
    TheMarkChristie Profile Picture
    TheMarkChristie 10,328 on at
    RE: Initialize service using admin guid in javascript

    Hi Satish

    I would push back on this as it is very close to multiplexing - If you need users to access and entity give them an account and set the security roles

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,575 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans