Select to view content in your preferred language

Problem with where clause in pulldata("@layer"...)

63
1
10 hours ago
ZenMasterZeke
Frequent Contributor

Having trouble with the where clause in a pulldata("@layer"...) calculation. I have two surveys: one where a user is given a user name (field name user_name) for logging in and enters their information such as name, address, etc. Records in the first form will be unique users.

The second form is where the user logs in with the same user name (field name user_login) and enters resources they have. There can be multiple records per user in this form.

I want to pull a separate field from the first form (organization_name) where the username from the second form matches the username from the first form. (This is basically creating related tables/joins, but the Web Designer doesn't support them, afaik.) In other words, return fom1.organization_name where form1.user_name = form2.user_login.

My calculation is

pulldata("@layer", "getValue", "attributes.name", "https://services.../FeatureServer/0", "user_name=user_login")

 

But whenever I run this, I get an error that there is no survey element named ${user_name}. I've tried using the ${} format on one field, both, the other, switching the order of the fields, etc. Is there a way to do this? Thanks!

 

0 Kudos
1 Reply
Neal_t_k
Frequent Contributor

try putting the where clause in a helper field 

whcl = concat ("user_login = '",${user_name},"'")

pulldata("@layer", "getValue", "attributes.name", "https://services.../FeatureServer/0", ${whcl})

user_login = the field in the feature layer you are querying

user_name =  the name of the question in the form you are using to match.

0 Kudos