Notifications
Announcements
No record found.
write code for the Query expression which will retrieve the two attributes from entity let say "Account".
*This post is locked for comments
you can use the below code:
QueryExpression query = new QueryExpression
{
EntityName = "account",
ColumnSet = new ColumnSet("Col1", "Col2"),
Criteria = new FilterExpression
Conditions = { new ConditionExpression { AttributeName = "address1_city", Operator = ConditionOperator.NotNull } }
}
};
EntityCollection eCollection = service.RetrieveMultiple(query);
if (eCollection .Entities.Count > 0) //Check for result count
foreach (var item in eCollection .Entities)
if (item.Attributes["Col1"].ToString() == "Chennai") //Condition here
item.Attributes["Col2"] = "India";
service.Update(item);
Regards
Pranav
If found useful, please mark the answer as verified
Please refer below -
msdn.microsoft.com/.../gg328149.aspx
msdn.microsoft.com/.../gg327917.aspx
Hi,
You can try the below code-
==============
public void CheckQE()
ClientCredentials _credential = new ClientCredentials();
_credential.UserName.UserName = "user@testcrm.onmicrosoft.com";
_credential.UserName.Password = "password";
var _organizationURI = "testcrm.crm6.dynamics.com/.../Organization.svc";
using (service = new OrganizationServiceProxy(new Uri(_organizationURI), null, _credential, null))
QueryExpression qe = new QueryExpression();
qe.EntityName = "account";
qe.ColumnSet = new ColumnSet();
qe.ColumnSet.Columns.Add("name");
qe.ColumnSet.Columns.Add("accountnumber");
var results = service.RetrieveMultiple(qe);
foreach (Entity act in results.Entities)
if (act.Contains("name"))
Console.WriteLine("Account Name:" + act["name"]);
if (act.Contains("accountnumber"))
Console.WriteLine("Account Number:" + act["accountnumber"]);
===============
Hello,
In addition to that did you check SDK ??, it has sample codes which should help you. If not done yet download latest CRM 2016 SDK.
Hi Srinivasareddy Sagili,
You can use the code below.
QueryExpression query = new QueryExpression { EntityName = "account", ColumnSet = new ColumnSet("name","accountnumber"), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "accountid", Operator = ConditionOperator.Equal, Values = { new Guid("xxxx-xxx-xxxx-xxxxx-xxxx") } } } } }; orgService.RetrieveMultiple(query);
See: https://arunpotti.wordpress.com/2014/12/11/retrieve-records-using-query-expression-c-sdk-in-crm/
Hope this helps.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2