Answered by:
XRM and users

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?
Cheers
Wednesday, September 22, 2010 9:47 PM
Answers
-
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
var from = new List <XrmLinq.Core.ActivityParty >(); from.Add( new XrmLinq.Core.ActivityParty { PartyIdType = SystemUser .Fields .SchemaName, // must set the type first PartyId = _context.WhoAmI().UserId });
http://www.xrmlinq.com/code/strongly-typed-queries.aspx
Hope this helps. Amar- Marked as answer by shirkavand Monday, September 27, 2010 6:09 PM
Wednesday, September 22, 2010 10:30 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 PMModerator
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
var from = new List <XrmLinq.Core.ActivityParty >(); from.Add( new XrmLinq.Core.ActivityParty { PartyIdType = SystemUser .Fields .SchemaName, // must set the type first PartyId = _context.WhoAmI().UserId });
http://www.xrmlinq.com/code/strongly-typed-queries.aspx
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"
cheers
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- Edited by RhettClintonMVP, Moderator Thursday, September 23, 2010 10:26 PM Updated dll name
Wednesday, September 22, 2010 11:23 PMModerator -
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?
Cheers
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 PMModerator -
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..
Cheers
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 PMModerator