web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • Inogic Profile Picture
    633 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
    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.

  • Community Member Profile Picture
    on at
    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

  • Community Member Profile Picture
    on at
    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
    10,328 Moderator 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans