[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 822
  • Last Modified:

how to retreive attributes of an particualr entity in Microsoft Dynamics CRM 4.0

how to retreive attributes of an particualr entity in Microsoft Dynamics CRM 4.0
0
ssantoshreddy
Asked:
ssantoshreddy
1 Solution
 
rakeshAgarwalCommented:
This is sql query to get the attribute
select attribute.name , entity.name from attribute , entity
where attribute.entityid = entity.entityid

You can retrieve the data using  SDK also. Please rfere SDk guide for the same
Regards
Rakesh Agarwal
www.dynamicsexchange.com

0
 
Biffster007Commented:
Hi,

Here is an example of Retrieve and RetrieveMultiple methods using the CRM web service.

Note:  The Retrieve method takes the GUID of the entity in question and returns the specified columns for that entity and the RetrieveMultiple method can take 1 or more values for certain attributes of the entity and also and returns the specified columns for that entity.

Retrieve Method:

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the column set object that indicates the fields to be retrieved.
ColumnSet cols = new ColumnSet();

// Set the properties of the column set.
cols.Attributes = new string [] {"name"};

// Create the target object for the request.
TargetRetrieveAccount target = new TargetRetrieveAccount();

// Set the properties of the target object.
// EntityId is the GUID of the record being retrieved.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
RetrieveRequest retrieve = new RetrieveRequest();

// Set the properties of the request object.
retrieve.Target = target;
retrieve.ColumnSet = cols;

// Execute the request.
RetrieveResponse retrieved = (RetrieveResponse)service.Execute(retrieve);

----------------------------

RetrieveMultiple Method:

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the ColumnSet that indicates the properties to be retrieved.
ColumnSet cols = new ColumnSet();

// Set the properties of the ColumnSet.
cols.Attributes = new string [] {"fullname", "contactid"};

// Create the ConditionExpression.
ConditionExpression condition = new ConditionExpression();

// Set the condition for the retrieval to be when the contact's address' city is Sammamish.
condition.AttributeName = "address1_city";
condition.Operator = ConditionOperator.Like;
condition.Values = new string [] {"Sammamish"};

// Create the FilterExpression.
FilterExpression filter = new FilterExpression();

// Set the properties of the filter.
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = new ConditionExpression[] {condition};

// Create the QueryExpression object.
QueryExpression query = new QueryExpression();

// Set the properties of the QueryExpression object.
query.EntityName = EntityName.contact.ToString();
query.ColumnSet = cols;
query.Criteria = filter;

// Retrieve the contacts.
BusinessEntityCollection contacts = service.RetrieveMultiple(query);

---------------------------------------------

Now I hope I've understood your question correctly??

Cheers,
MH
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now