Skip to content

Commit f856c47

Browse files
committed
Added ability to order by descending in the GetAllByQueryInternalJObjectAsync customOrderByField parameter.
1 parent db3080f commit f856c47

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ServiceNow.Api/ServiceNowClient.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,16 @@ internal async Task<List<JObject>> GetAllByQueryInternalJObjectAsync(
247247
? _options.PagingFieldName
248248
: customOrderByField;
249249

250-
var orderByCommand = orderByField.StartsWith("-", StringComparison.Ordinal)
251-
? "ORDERBYDESC"
252-
: "ORDERBY";
250+
string orderByCommand;
251+
if (orderByField?.StartsWith("-", StringComparison.Ordinal) ?? false)
252+
{
253+
orderByCommand = "ORDERBYDESC";
254+
orderByField = orderByField.Substring(1);
255+
}
256+
else
257+
{
258+
orderByCommand = "ORDERBY";
259+
}
253260

254261
_logger.LogTrace($"Entered {nameof(GetAllByQueryInternalJObjectAsync)}" +
255262
$" type: {typeof(JObject)}" +

0 commit comments

Comments
 (0)