Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Initialize service using admin guid in javascript

Posted on by Microsoft Employee

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 24,094 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.

  • Community Member Profile Picture
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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
    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans