locked
Run the plugin with a different context than the current user context ?!? RRS feed

  • Question

  • Hi every body
    I developed a plugin to create a phone number record (new_phonenumber entity). The plugin runs on create message another entity named new_salecontract to create a recording telephone number attached to the salecontract, the salecontract is attached to the account entity,so one customer can have many contract, and many phone number, in the customer entity we can see the list of all sales contract and the list off all his phone number. In the DataGrid of the phone number list we can find the two button add new phone and add exsiting phone number. we know that those button disappears with roles management,
    but my problem is the following:
    the plugin that run at the create message in the salecontract entity use the current user context to create the phone number record attached at the same time to salecontract and the customer, so my question is if the CRM user does not has the role to create the phone number record but he can create a salescontract record, is the plugin can run and create the phone number record?
    to be more clear, can we run a plugin with a user context user different thant the current user that run the plugin?

    thx for help.
    Tuesday, April 28, 2009 7:59 AM

Answers

  • Hi,

    you can perform this task. You can specify a context in the moment of registration of step of plugin.
    Истина открывается подготовленному уму. Мой блог - http://a33ik.blogspot.com
    • Marked as answer by BERKAYA Hedi Tuesday, April 28, 2009 8:19 AM
    Tuesday, April 28, 2009 8:07 AM
    Moderator

All replies

  • Hi,

    you can perform this task. You can specify a context in the moment of registration of step of plugin.
    Истина открывается подготовленному уму. Мой блог - http://a33ik.blogspot.com
    • Marked as answer by BERKAYA Hedi Tuesday, April 28, 2009 8:19 AM
    Tuesday, April 28, 2009 8:07 AM
    Moderator
  • Hi,

    To run your plugin under some different user's context,  while registering your plugin,
    you could set Run in user's context to the impersonating user from the drop down and set CreateCrmService(true) while creating crm service.

    Or for CreateCrmService method you could pass the guid of the user whom you could like to impersonate !

    check this url
    http://msdn.microsoft.com/en-us/library/cc151091.aspx

    Regards,
    Nishant Rana
    http://nishantrana.wordpress.com
    Tuesday, April 28, 2009 8:15 AM