Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Retrieve Mobile Phone and telephone using Retrivemultiple C# FetchXML

$
0
0

Hi All,

I am trying to retrieve contact info in console application using FetchXml and RetriveMultiple.

I am using CrmServiceHelpers.cs and DeviceIdManager.cs from SDK.

It is showing mobileInfo and Telephoneinfo does not exist in current context. How to call Mobile and telephone fields using RetriveMutiple in my program.

For rest of the fields in program runs fine.

namespace FetchXML_Aggregate

{

classProgram

{

staticvoid Main(string[] args)

{

// obtain the target orgnization web address and client logon

Microsoft.Crm.Sdk.Samples.ServerConnection serverConnect = new Microsoft.Crm.Sdk.Samples.ServerConnection();

Microsoft.Crm.Sdk.Samples.ServerConnection.Configuration config = serverConnect.GetServerConfiguration();

OrganizationServiceProxy _serviceProxy;

using (_serviceProxy = Microsoft.Crm.Sdk.Samples.ServerConnection.GetOrganizationProxy(config))

{

string strAggregate = @"<fetch distinct='false' mapping='logical' output-format='xml-platform'

version='1.0'>

<entity name='contact'>

<attribute name='fullname'/>

<attribute name='contactid'/>

<attribute name='address1_telephone1'/>

<attribute name='mobilephone'/>

<attribute name='firstname'/>

<attribute name='ownerid'/>

<order descending='false' attribute='fullname'/>

<filter type='and'>

<filter type='or'>

<condition attribute='fullname' operator='not-null'/>

<condition attribute='address1_telephone1' operator='not-null'/>

<condition attribute='firstname' operator='not-null'/>

<condition attribute='contactid' operator='not-null'/>

<condition attribute='mobilephone' operator='not-null'/>

</filter>

<condition attribute='firstname' operator='eq' value='david'/>

</filter>

</entity>

</fetch>";

var aggResults = _serviceProxy.RetrieveMultiple(newFetchExpression(strAggregate));

foreach (var c in aggResults.Entities)

{

string NameInfo = (string)c.Attributes["fullname"];

Guid ContactID = (Guid)c.Attributes["contactid"];

if(c.Attributes.Contains("address1_telephone1"))

{

string TelephoneInfo = (string)c.Attributes["address1_telephone1"];

}

 

 

if (c.Attributes.Contains("mobilephone"))

{

string MobileInfo = (string)c.Attributes["mobilephone"];

}

Console.WriteLine("Name : " + NameInfo);

Console.WriteLine("IdentityofContact : " + ContactID);

Console.WriteLine("Mobile : " + MobileInfo);

Console.WriteLine("Telephone : " + TelephoneInfo);

Console.Read();

}

}

}

}

}


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>