Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

LinkEnity Columns order by feature in crm 2013

Posted on by Microsoft Employee

Dear all , 

string subjectmatrixid = string.Empty;

object oVal = null;
bool ismappedcategory = true;
// CrmServiceAdapter OrgService=new CrmServiceAdapter();
SchemaMappingController mappingController = new SchemaMappingController();
QueryExpression queryExpression = new QueryExpression("icms_icmssubjectmatrixmapping");
queryExpression.LinkEntities.Add(new LinkEntity("icms_icmssubjectmatrixmapping", "ava_subjectmatrix", "icms_subcategory", "ava_subjectmatrix_subjectname", JoinOperator.Inner));
// queryExpression.LinkEntities[0].LinkCriteria.AddCondition("ava_subjectmatrix_categoryname", ConditionOperator.Equal, icms_category);
queryExpression.LinkEntities[0].EntityAlias = "Link";
queryExpression.Criteria.Conditions.Add(new ConditionExpression("icms_msoswitchboardcategory", ConditionOperator.Equal, (object)switchboardCategory));
queryExpression.Criteria.Conditions.Add(new ConditionExpression("icms_msoswitchboardsubcategory", ConditionOperator.Equal, (object)switchboardSubcategory));
queryExpression.Criteria.Conditions.Add(new ConditionExpression("icms_ismappedcategory", ConditionOperator.Equal, (object)ismappedcategory));
queryExpression.LinkEntities[0].Columns = new ColumnSet("ava_subjectmatrixid", "ava_subjectmatrix_subject");
//queryExpression.AddOrder("Link.ava_subjectmatrixid", OrderType.Descending);
EntityCollection entitiesJS1 = CrmServiceAdapter.OrgService.RetrieveMultiple(queryExpression);
ICMSLogHelper.LogCreateMisroutedCaseCCMP_SOAPRequest("subjemtmatrixJSid", entitiesJS1.Entities.Count().ToString(), "", ConfigurationManager.AppSettings["LogType"]);

if (entitiesJS1.Entities.Count > 0)
{//int i = 0;
if (entitiesJS1.Entities[0].Contains("Link.ava_subjectmatrix_subject"))
oVal = entitiesJS1.Entities[0].GetAttributeValue<AliasedValue>("Link.ava_subjectmatrix_subject").Value;
subjectmatrixid = ((EntityReference)oVal).Id.ToString();
ICMSLogHelper.LogCreateMisroutedCaseCCMP_SOAPRequest("ava_subjectmatrix_subject", subjectmatrixid, "", ConfigurationManager.AppSettings["LogType"]);
}
return subjectmatrixid;

"queryExpression.AddOrder("Link.ava_subjectmatrixid", OrderType.Descending);" this line throwing error 

saying the entity icms_icmssubjectmatrixmapping doesnt have the column name "Link.ava_subjectmatrixid" 

how to achive the LinkEntity columns order by  ???

please help ??

*This post is locked for comments

  • Nuno Profile Picture
    Nuno 2,005 on at
    RE: LinkEnity Columns order by feature in crm 2013

    Ok, you probably are using ddls from SDK 2011. With dlls from SDK 2013 it would work!

    But if it is working now, great!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: LinkEnity Columns order by feature in crm 2013

    Hello Nuno,

    its 2013 version , i changed to FetchXML, its working now thanks

  • Nuno Profile Picture
    Nuno 2,005 on at
    RE: LinkEnity Columns order by feature in crm 2013

    To which Dynamics CRM version are you developing for?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: LinkEnity Columns order by feature in crm 2013

    i tried, but it threw an error

    Error 7 'Microsoft.Xrm.Sdk.Query.LinkEntity' does not contain a definition for 'Orders' and no extension method 'Orders' accepting a first argument of type 'Microsoft.Xrm.Sdk.Query.LinkEntity' could be found (are you missing a using directive or an assembly reference?)

  • Suggested answer
    Nuno Profile Picture
    Nuno 2,005 on at
    RE: LinkEnity Columns order by feature in crm 2013

    queryExpression.LinkEntities[0].Orders.Add(new OrderExpression("ava_subjectmatrixid", OrderType.Descending));

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: LinkEnity Columns order by feature in crm 2013

    I am not sure you can do it with queryexpression..  but you might be able to do it with Fetch if you use alias with the order attribute

    <order alias="link-alias-name" attribute="link-entity-attribute">

    Maybe try it with fetch and then convert to query expression using the sdk.. then you'll know the syntax:

    msdn.microsoft.com/.../hh547457.aspx

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.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans