Hello,
I need to fetch the userid associated with email id in ASP.NET. Please suggest.
*This post is locked for comments
Hello,
I need to fetch the userid associated with email id in ASP.NET. Please suggest.
*This post is locked for comments
Hi Jagmohan,
I am implementing in ASP.NET MVC using SDK kindly suggest for the same.
Hello Bindu,
You can use following fetch for this
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="phonecall">
<attribute name="subject" />
<attribute name="statecode" />
<attribute name="prioritycode" />
<attribute name="scheduledend" />
<attribute name="createdby" />
<attribute name="regardingobjectid" />
<attribute name="activityid" />
<order attribute="subject" descending="false" />
<link-entity name="activityparty" from="activityid" to="activityid" link-type="inner" alias="aa">
<filter type="and">
<condition attribute="participationtypemask" operator="eq" value="2" />
<condition attribute="partyid" operator="eq" uiname="Adrian Dumitrascu" uitype="contact" value="{49A0E5B9-88DF-E311-B8E5-6C3BE5A8B200}" />
</filter>
</link-entity>
</entity>
</fetch>
Hi Aric,
The above snippet was helpful, thank you!
I need further help on phone call activity for the contact, I have passed the values to subject and description as mentioned above. How do I pass the parties id as from- to i.e. userid-contact id.
Please request you to suggest.
See the functions below to get the user id based on email address:
public Guid RetrieveUserIdByEmailAddress(string emailAddress)
{
QueryByAttribute query = new QueryByAttribute();
query.ColumnSet = new ColumnSet(new string[] { "systemuserid", "fullname" });
query.EntityName = "systemuser";
query.Attributes.Add("internalemailaddress");
query.Values.Add(emailAddress);
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;
RetrieveMultipleResponse response = (RetrieveMultipleResponse)service.Execute(request);
Entity results = (Entity)response.EntityCollection.Entities[0];
try
{
Guid lookupId = results.Id;
return lookupId;
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException(ex.Message);
}
}
If you don't have the contact id, you can follow simiar logic as above function, but query contact entity instead of systemuser entity and add the emailaddress1 attribute instead of internalemailaddress.
Hope this helps.
Hello Aric,
We have integrated CTI to Dynamics 365 so I will have only email id of that agent. Using that email id I need to fetch the user id to create a phone call activity.
Entity phoneCallEntity = new Entity("phonecall");
phoneCallEntity["subject"] = "Test Subject";
phoneCallEntity["description"] ="Test Description";
Guid activityId = resultService.Create(phoneCallEntity);
To create phone call activity for the contact I need to pass from(agent user id i.e party id) and to(i.e. particular contact by contact id) which I am not sure with the correct syntax for the same.
Here I have used Organization Service, so please suggest to complete the above procedure.
Hi Bindu,
If I am getting you correct, then you want the user Id of the user in the from field of the email message.
You can simply call it by using the retrieve function of the OrganizationService.
Entity email = service.Retrieve("email", emailId, new ColumnSet("from", "subject", "description"));
Entity from = (Entity)((EntityCollection)(email.Attributes["from"])).Entities[0];
EntityReference fromPartyId = (EntityReference)from.Attributes["partyid"];
fromPartyId will contain user id from the email message.
Hope this helps.
Hi Bindu ,
Try to write Web api query or fetch xml as Wei suggested earlier.
Webar API URI +
SystemUser$select=AccessMode,FirstName,FullName,LastName&$filter=IsDisabled eq false and AccessMode/Value ne 5 and AccessMode/Value ne 3 and Email eq "xxxx"
Here is the reference how to write.
docs.microsoft.com/.../query-data-web-api
Hopen this helps.
Hello Bindu,
You mean , you want to get the created or updated user in plugin? Or owner off the email?
If so , i can paste the sample code.
Hi,
depends on your will, use web api or sdk method to retrieve the user id.
webapi
msdn.microsoft.com/.../mt742424.aspx
SDK
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
52
Victor Onyebuchi
6