85
Views
23
Comments
how to search through table with blocks
Application Type
Reactive

hello,


i have a table with blocks in it. I want to search in this table trhough the blocks. I have a local variable that is connected to the search bar. I passed this local variable to the block's input parameter. So it passes the filled in variable from the parent screen to the block's input paramter. 


However i already have another input paramter on this block, UserId. So it evertime needs both a UserId and TextInput for the search to work. Because when you search you can not give a UserId, it does not search with only search's input. 


Have a look on the aggregates: 


right here you have test values:


however you see there are no records returned. Only when the UserId is also entered:


So how can i fix this in such a way that searching is possible?

2025-02-04 10-17-42
Shreelakshmi N S
Champion

Hi,

Whenever you are doing a search is the UserId is getting passed or not to the block?

Regards,

Shree

UserImage.jpg
sam m

no im not passing the UserId. The only thing passed to the block is the input of the search

2025-02-04 10-17-42
Shreelakshmi N S
Champion

Okay.. In that case please change the aggregate filter as below. It should work.

1. UserId = Nullidentifier() or DigitaleCV.UserId = UserId

2. Zoeken = "" or Certificate.CertificaatName like "%"+Zoeken+"%"


Let me know if this works

Regards,

Shree

2022-12-09 04-50-17
Shubham Doshi

Hello Sam,

You can pass Nullidentifier() in as a userid input. And then you can add filter as If(UserId = Nullidentifier(), DigitalCV.UserId <> NullIdentifier(), DigitalCV.UserId = UserId)

2023-03-16 16-29-51
Paulo Rosário

Hello Sam, 

This is happening because of your filter: DigitaleCV .UserId = UserId.

This filter will only show records with a userId value.  

If the user id is not needed then I would suggest removing that part of the filter or changing it to:

 Userid = Nullidentifier() or DigitaleCV.UserId = UserId 

Hope it helps !

Paulo Rosário 

UserImage.jpg
sam m

i understand however this filter is needed otherwise it will show wrong data

2023-03-16 16-29-51
Paulo Rosário

Then you should verify that you are always passing a valid UserID to the block in order for the search to work.

I assume that the userid you are using as input comes from a data action or something along those lines if that is the case make sure that you refresh the data action before calling the Web block. 

2022-12-09 04-50-17
Shubham Doshi

But using or condition will filter out the data when you are actually passing the value and even if the wrong user id is getting passed. So I would suggest you to use If condition to avoid this conflict.

UserImage.jpg
sam m
2022-12-09 04-50-17
Shubham Doshi

I am assuming you only want to pass value of Zoeken when you have entered the search input. So, here you can use If(SearchVariable <> "", Getuser.Id, Nullidentifier() )

This will prevent input to pass userid when you are using search keyword

2023-03-16 16-29-51
Paulo Rosário

Make sure that you are refreshing your aggregate in your on-parameters changed event. 

2020-07-29 19-08-40
Sanjay Kumar Sahu

Hello Sam,

You don't need to pass UserId in aggregate filter and in the block. We already have GetUserId() builtin action to fetch logged-in userId, hence in aggregate you can directly use GetUserId() like below:

DigitaleCV.UserId = GetUserId()

It will work fine, perhaps while testing in aggregate you have to give userId manually.


Hope it helps!!


Sanjay

UserImage.jpg
sam m

if i use getuserid() it will pass the userid of the current user. That is not what i want. The UserId filter ensures that the data in those blocks are showed per user. So each user has its own data, that is done by the userid filter

2020-07-29 19-08-40
Sanjay Kumar Sahu

Ok, In that case I'm assuming you are passing correct user id(you have to make sure it), your flow is correct, I guess your block is not refreshed with latest filter data, for that you should refresh your aggregate in OnParameterChanged event of block. Just drag and drop your aggregate inside that action.

UserImage.jpg
sam m
2020-07-29 19-08-40
Sanjay Kumar Sahu

Ok, There can be issue with your input parameters data, as you are using block inside the table, you have to make sure if ZoekInput has correct value, may I know how you are passing ZoekInput or mapping value to this variable? If it is coming from any screen aggregate then you have to referesh that aggregate and this variable or just refresh aggregate and map aggregate field to your input parameter Zoeken.

UserImage.jpg
sam m

i have a input parameter on the Certificaat block:



So on the table, i select the local variable ZoekInput as the value of the input parameter Zoeken. ZoekInput is the variable for the searchbar. So i am passing it like this, however i am not sure right now if i pass the value the correct way

2020-07-29 19-08-40
Sanjay Kumar Sahu

I guess, your local variable ZoekInput is not getting refreshed. Can you send current CertificaatNaam of GetCertificatesByUser in input parameter for Zoeken. And GetCertificatesByUser of screen must be refreshed within Input_TextVarOnChange along with GetUserByName aggregate.

In this way whenever you will be giving a new search keyword, your both aggregates will be refreshed and this should cause execution on OnParametersChanged event of block.

Hope this works!

UserImage.jpg
sam m

this is the onParameterChanged action of Certificaatlist block:

as you can see it refreshes. And right here the Input_TextVarOnChange action of the screen DigitaleCV_S:


here it also refrshes. I think the problem is becasue of this filter in the aggregate GetCertificatesByUser in the block CertificaatList:


becasue with this filter it expects a UserId input whenever you search something, please see the Test value:


it only shows something if you also fill in the UserId, so this problem does not have to do with refreshing aggregates

2020-07-29 19-08-40
Sanjay Kumar Sahu

well this is fine, still you should use GetCertificatesByUser.List.Current.CertificaatNaam as input parameter of Zoeken. Now my only I guess is your aggregate GetUsersByName have some problem. May I know what is the filter used here and if you are expecting a user list or single user name?

UserImage.jpg
sam m

do you mean to change ZoekInput to GetCertificatesByUser.List.Current.CertificaatNaam ? 

Because the table is on a screen that does not have the aggregate GetCertificatesByUser, this means that i have to add the aggregate to this screenHowever, i wonder how this is going to fitler on CertificaatNaam?




2020-07-29 19-08-40
Sanjay Kumar Sahu

Yes, I was saying about that because I have seen that aggregate at screen in your previous post: 


UserImage.jpg
sam m

you are right, i was just testing something out. But how is this going to work? Becasue if i set GetCertificatesByUser.List.Current.CertificaatNaam as input, how is the filter going to filter on the searched keyword? Becasue this way the input of the search bar is not passed?

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