XRM and users RRS feed

  • Question

  • hi There,


    Is there any way using XRM of fetching wich user is executing some action? i need to ask something like "whosLogged()" so it will return the current user object..any idea?



    Wednesday, September 22, 2010 9:47 PM


All replies

  • I guess you are referring to current user in crm. Retrieve the system user entity instance for the currently logged on user or the user under whose context the executed code is running.

    WhoAmI Request

     from = new
                    PartyIdType = SystemUser
    .SchemaName, // must set the type first
                    PartyId = _context.WhoAmI().UserId



    Hope this helps. Amar
    • Marked as answer by shirkavand Monday, September 27, 2010 6:09 PM
    Wednesday, September 22, 2010 10:30 PM
  • Hi,


    Thanks for your fast reply. For using this  "WhoAmI"  wich assembly i have to add? i am gettin "namespace not found"



    Wednesday, September 22, 2010 10:52 PM
  • You need to add the Microsoft.crm.sdktypeproxy.dll, this can be found in the SDK download or on the CRM server.
    MSCRM Bing'd - http://bingsoft.wordpress.com

    Check out the CRM 4 to CRM 2011 JavaScript Converter Tool
    Wednesday, September 22, 2010 11:23 PM
  • Hi there,


     The "Microsoft.crm.sdk.dll" does not contain any definition of "WhoAmIRequest", instead i have used "Microsoft.Crm.SdkTypeProxy.dll" wich does have it. But now, i got some "ambiguous" errors, for example:


      'contract' is an ambiguous reference between 'Xrm.contract' and 'Microsoft.Crm.SdkTypeProxy.contract'


    Am i missing something here? any idea?




    Thursday, September 23, 2010 3:59 PM
  • you will get this. because both have contract definition. so while using contract use like below instead of just using contract

    Microsoft.Crm.SdkTypeProxy.contract _contract=new Microsoft.Crm.SdkTypeProxy.contract();

    Mahain : http://mahenderpal.wordpress.com
    • Proposed as answer by HIMBAPModerator Thursday, September 23, 2010 4:05 PM
    Thursday, September 23, 2010 4:05 PM
  • Hi there,

    Well, using:

    Microsoft.Crm.SdkTypeProxy.contract _contract=new Microsoft.Crm.SdkTypeProxy.contract();

    Will solve the "ambiguous" errors, but  this change cause a lot or compilations incomaptibilities/error in my code(lots of them), things like "can not implicity convert contract(XRM) to cotract(CRM)" etc that i will need to solve. Is there any way of indicating that i want to use XRM contract instead Microsoft.Crm. SdkTypeProxy ? so i can avoid this kind of errors..


    Thursday, September 23, 2010 5:01 PM
  • yes you can do that in the same way you can use Xrm.contract

    Mahain : http://mahenderpal.wordpress.com
    • Marked as answer by shirkavand Monday, September 27, 2010 6:08 PM
    Thursday, September 23, 2010 5:13 PM