Filter d/results from SharePoint 2013 GET HTTP CALL?

GEE OTTO 11 Reputation points
2022-03-08T20:29:26.197+00:00

Is there a way to further filter the d/results of a call to pick a certain item for manipulation via WF?

ID Type UIN
1 ABC
2 XXX
3 XYZ
4 XXX
5 ABC

Say I wanted to use this URL mysite/_api/web/lists/getByTitle/('ListX')/items?$select=[Current Item:Type]&$orderby=ID desc to pull the existing instances of a UIN. Since this is existing data and this WF will be added I have a IF statement to check the count of d/results and IF = 0 set count to 1, ELSE add 1 to count. and do the other stuff to make the UIN.

How can I do this but only pull the largest instance of UIN by type from d/results? If I ran it the way it works now it will assign the same UIN to items by Type b/c the count will return the type that is set on the current item, so if type = ABC there are going to be 2 items in results so it would assign ABC-0002 to the ID 1 and ID5 however once a make a new item it would assign ABC-0003 as there are two existing items which via WF would increment it by 1. The incrementing and string creation are easy the hard part is figuring out how to examine and take the largest item from d/results.

Normally I would substring two values then set them to variable then say IF value = to value, add 1 to value, then set var to the new value

Any advice would be great

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,417 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,663 questions
{count} vote

1 answer

Sort by: Most helpful
  1. GEE OTTO 11 Reputation points
    2022-03-11T15:57:42.093+00:00

    I fixed this issue I merely wasnt passing the correct arguments via the URL, my call was only returning [Type] and I wanted to read both [Type] and [UIN] in the results for different actions based on existing values.

    I updated the call to: mysite/_api/web/lists/getByTitle/('ListX')/items?$select=Type,UIN&$filter= Type eq [Current Item:Type]&$orderby=UIN desc

    Now when I check the the initial count of responseContent and need to further process I can do Get d/results/(0)/UIN and obtain the exiting UIN of the existing items by [Type].

    The only thing I had to tweak was adding an additional IF when the result is empty i.e. a new [Type] is added and there are no existing items to return.

    1 person found this answer helpful.