Why is my userID filter returning only one of my users?


Hi everyone, I am trying to display the username of the logged in user by user a filter. However, after applying the filter, I only have one user left. I also notice that even after starting the app fresh, I am auto logged into that particular User, "X". Do you guys have any idea what is causing this? Thanks!

Hi R,

I'm not sure where your confusion is coming from. You apply a Filter on the UserData.Id, and since the Id is unique, most obviously you can have only one record left. If you are wondering why this particular record, check the Test Values tab, Service Studio will autofill a value there if you haven't specified one yet yourself.

Hi R Y,

go to the test value tab into your aggregate and try to put 0 for filter value and check the result.

@Manish: if you add a 0 there you will get 0 records, as no Id will match the NullIdentifier()!

Kilian Hekhuis wrote:

Hi R,

I'm not sure where your confusion is coming from. You apply a Filter on the UserData.Id, and since the Id is unique, most obviously you can have only one record left. If you are wondering why this particular record, check the Test Values tab, Service Studio will autofill a value there if you haven't specified one yet yourself.


Hi Kilian, I am trying to display my User's name. However, even after logging into different accounts, the displayed name is the same... UserDataId is a user identifier input and should return the current logged in user. I do not understand why this is happening. 

You have 29 warnings. I bet one of these warnings warns you that you should have On Parameters Changed handler in that Block.

Kilian Hekhuis wrote:

You have 29 warnings. I bet one of these warnings warns you that you should have On Parameters Changed handler in that Block.

Hi Kilian, the warnings are from unused elements which I am testing. 

As you can see, I am trying to display the expression of the Username of logged in user. However, no matter what account I am logging in with the username is displayed as "X"...

What I was getting at, since you have UserDataId as Input Parameter to the Web Block, you need an On Parameter Changed handler so that if the Input Parameter changes its value, you refresh the Aggregate. If you don't do that, it will keep its initial value.

Kilian Hekhuis wrote:

What I was getting at, since you have UserDataId as Input Parameter to the Web Block, you need an On Parameter Changed handler so that if the Input Parameter changes its value, you refresh the Aggregate. If you don't do that, it will keep its initial value.


Ahh I see. But I thought when I restart the app, the cache should clear and the aggregate should refresh itself? So I will now create a new action which refreshes the aggregate, but how should I trigger the action?

Ok, I'll explain. I created a simple Block that shows the user name and has a UserId as Input Parameter:

GetUserById a Filter that looks like this:

Now, if I check the True Change warnings, I see this one:

and I bet you have that one as well (that's what I was getting at in a previous post). Also when I hover the Aggregate:

Now if you select the Block, these are its Properties:

One of these is the "On Parameters Changed" I alluded to earlier. Select "New Client Action" from the suggestions (note it should actually say Screen Action, but anyway...), the default name "OnParametersChanged" is fine. In that Action, refresh the data using the Refresh Data Statement:

Now, every time the input changes, the Aggregate is refreshed, and the user name should be changed.


Kilian Hekhuis wrote:

@Manish: if you add a 0 there you will get 0 records, as no Id will match the NullIdentifier()!

Hi Kilian,

yes, you are right if we put 0 no records will display, i just want to make him aware by changing the value in filter section and check result, because he is surprised by filtered result.



Kilian Hekhuis wrote:

Ok, I'll explain. I created a simple Block that shows the user name and has a UserId as Input Parameter:

GetUserById a Filter that looks like this:

Now, if I check the True Change warnings, I see this one:

and I bet you have that one as well (that's what I was getting at in a previous post). Also when I hover the Aggregate:

Now if you select the Block, these are its Properties:

One of these is the "On Parameters Changed" I alluded to earlier. Select "New Client Action" from the suggestions (note it should actually say Screen Action, but anyway...), the default name "OnParametersChanged" is fine. In that Action, refresh the data using the Refresh Data Statement:

Now, every time the input changes, the Aggregate is refreshed, and the user name should be changed.



Hi Kilian, many thanks for your detailed walkthrough. However, right now, there seems to be some error with my user login, because even after restarting the app, the logged in user is stuck at user "X". I have implemented the refresh action to no avail. 

This is my function...

What are you using as input to the Web Block's UserDataId? After the log in, do you refresh that input? I'd normally expect not UserData but plain User for a login, so perhaps you forget an extra query there? (Just speculating.)

Kilian Hekhuis wrote:

What are you using as input to the Web Block's UserDataId? After the log in, do you refresh that input? I'd normally expect not UserData but plain User for a login, so perhaps you forget an extra query there? (Just speculating.)

Hi Kilian, the reason it is "userdata" not "user" is because I named the database that way.. Is there a way to introduce a whole-of-app input refresh when the user that is logged in changes?


Kilian Hekhuis wrote:

Hi R,

I'm not sure where your confusion is coming from. You apply a Filter on the UserData.Id, and since the Id is unique, most obviously you can have only one record left. If you are wondering why this particular record, check the Test Values tab, Service Studio will autofill a value there if you haven't specified one yet yourself.

Hi Kilian, can I check, when I apply the filter the resultant user should be the one that is currently logged in right?


Hi R,

That depends on what we're talking about. There's a lot of posts in this thread, so what exactly do you mean?

Kilian Hekhuis wrote:

Hi R,

That depends on what we're talking about. There's a lot of posts in this thread, so what exactly do you mean?

Hi Kilian, you mentioned that the userID filter results in only 1 used returned. So In the case where I use the filter, the filtered user should be the user which is logged in right? 


R Y wrote:

Kilian Hekhuis wrote:

Hi R,

That depends on what we're talking about. There's a lot of posts in this thread, so what exactly do you mean?

Hi Kilian, you mentioned that the userID filter results in only 1 used returned. So In the case where I use the filter, the filtered user should be the user which is logged in right? 


Kilian, is this interpretation correct? Thanks!


R Y wrote:

Hi Kilian, you mentioned that the userID filter results in only 1 used returned. So In the case where I use the filter, the filtered user should be the user which is logged in right? 

Kilian, is this interpretation correct? Thanks!

Hi R Y,

That depends if the value of the Id you filter with is the ID of the logged-in user you are right. If the Id you filter on is not the logged-in user, then obviously you get the details of that user, not being the logged-in user.

If you want to filter on the currently logged in user try to use GetUserId().

Regards,

Daniel


Yes, like Daniël wrote. If you use a variable in an Aggregate or SQL, you have to provide a value for that variable in the Test Values tab (Aggregate) or Test Inputs tab (SQL). For Aggregates, Service Studio may provide some random value, which you can change.