Her's how to Sort Descending using the QueryByAttribute function

May 15, 2014 at 3:24 PM
After playing with this a bit I was able to get this to work successfully. The key is the placement of the ' character.
  queryOptions = {
          entityName: "account",
          attributes: ["address1_city", "statecode"],
          values:     ["Boston", 0],
          columnSet:  ["firstname", "lastname"],
          orderBy:    ["lastname' descending='true"] };
  results = XrmServiceToolkit.Soap.QueryByAttribute(queryOptions);
The serialized result will look like this (cleaned up a bit):

<fetch mapping='logical'>
<entity name='account'>
 <attribute name='firstname' />
 <attribute name='lastname' />
 <order attribute='lastname' descending='true' />      
    <condition attribute='address1_city' operator='eq' value='Boston' />
    <condition attribute='statecode' operator='eq' value='0' />