66
Views
10
Comments
Filtering List After REST Api Call

Hi All,

I am new to OS and am having a few teething problems. I am trying to pull data from PipeDrive into OS which I have managed to do fine and display it on a screen. 

However, I am wanting to implement search functionality and this is where I am hitting a problem. Due to it exposing company data I cannot share the OML however my current setup is this:

I have a screened called "Deals" which I am "fetching data from other sources" in this data action called "Deals" I am calling the pipedrive {{companyUrl}}/deals and parsing the required api_token for authentication.  I am then assigning the "Response" to an output parameter which is set as "GetDealsResponse List"

I am then displaying the contents of this output parameter on the screen and this works like a charm.


However, when I modify the data action by adding in a listFilter to filter the "Response" output parameter by Id (comparing it with a local variable called SearchKeyword) and then follow through with a ListAppendAll to push the filtered data into another output parameter called "Filtered" (also set as data type "GetDealsResponse List") and set the table on the Deals screen to pull from "Filtered" I hit problems. See screenshot attached for the full error. 

So that I can filter etc, I have manually changed the "Response" in the GetDeals REST Api method (generated by the consume API wizard) to a List. When it sets itself up it isnt a List type. I think this is where the problem is that I am consuming a non-list data type and trying to treat it as a list.  Does this sound right and what should I do differently to make it work? I have done some googling etc and played around with the JSON deserialize but couldnt get anywhere as it asks for a JSON text input and I have a structure being returned from the API call. 

As I say, I am very new to this, I'm at the stage where a small amount of knowledge is dangerous!

Very glad of any support please. :-)


Screenshot 2024-03-18 at 12.54.12.png
2025-12-15 09-29-24
Thibaut G

Could you share some Screenshots of the data action in service studio, and the API methods + the strcutures and its attributes/configuration ? this will give us a better understanding without having to share the OML


Kind regards

UserImage.jpg
Joel Lister

Hi Thilbaut,

Please see images attached. Hopefully it makes sense. This is the original version which gives me a list of every record from pipedrive. This works!

How do I add filtering to this please?

Screenshot 2024-03-18 at 16.10.59.png
Screenshot 2024-03-18 at 16.14.03.png
Screenshot 2024-03-18 at 16.16.05.png
Screenshot 2024-03-18 at 16.19.44.png
2025-12-15 09-29-24
Thibaut G

Hi Joel,

Thank you for providing more details. As I understand it, your API call and the initial parsing to the JSON structure are functioning correctly. 
However, the issue arises when attempting to filter the response using a Listfilter widget within the dataAction in your front end module.
Is this correct ?

Side note:
I would suggest refraining from directly using the response structure from your JSON as your frontend object. Instead, it's advisable to create a separate structure for your frontend and map the necessary parameters from the JSON response structure to your frontend structure

Kind regards

Thibaut 

UserImage.jpg
Joel Lister

Hi @Thibaut G thanks for your reply.

Yes you have understood that correctly. 


Please could you explain how I would approach the new structure and mapping it?

2025-12-15 09-29-24
Thibaut G

In your data tab, you have a folder Called Structures where you can manually create a structure. 

After creating your structure along with its parameters, proceed to create an output variable within your Data Action. Begin by selecting that the variable is a List, and then specify the structure you created as its Datatype. 


Once you've made the API call within your Data Action, instead of using the response outputparameter (this can be deleted), assign the value of your API response to the newly created output parameter. 
When using the Assign widget to assign a variable of a different structure type, you should encounter the option to map the parameters. Refer to the example below: 


Kind Regards


Thibaut 

2025-12-15 09-29-24
Thibaut G

Addition:
It's possible that you will have to use ForEach Widgets to do the mapping from your Json structure to your front end structure because its not a flat Json.
Feel free to ask if i need to clarify.

UserImage.jpg
Joel Lister

Thanks very much @Thibaut G 

Does this mean I could push everything into an aggregate? I find them far easier to manipulate.

2025-12-15 09-29-24
Thibaut G

Using an aggregate for an API response isn't supported. Aggregates are designed for internal OutSystems databases or database integrations only. 
Manipulating list variables, however, is entirely feasible once you grasp the fundamentals.

The suggestion to avoid using the JSON response structure generated by OutSystems stems from best practice guidelines both within OutSystems and in programming at large. 
there's a small possibility that the error is happening due to using the ListFilter on a automatically generated response structure but this is really a guess.

I recommend utilizing the debugger or service center logs to confirm whether the error indeed originates from the Listfilter widget action and not from the API call itself.

Best Regards, 
Thibaut



2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Joel,

First of all, it is always a better approach to have the filtering done by the REST method you're calling. Doesn't PipeDrive have a filter option? Since what you're doing now is getting an enourmous bulk of data over the wire, then do a CPU intensive filtering, then only display a tiny part. Not very performant! So if you can avoid it at all, do not filter like this!

That said, the "failed to parse" error means that the Platform is receiving JSON that it cannot parse according to the structures you defined for the REST interface. So either you meddled with the structure output, or you're getting some other output than you did before. If you can supply more detail, I can perhaps guide you better.

UserImage.jpg
Joel Lister

Thanks @Kilian Hekhuis , thanks for explaining that so clearly that makes a huge amount of sense. I will have a play around in postman and see if that can be done.


You are right, I did meddle with the structure. I changed it to a list type!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.