Data constraints- I need help

I have a repeating group getting data from a datatype called HOMEWORK and there are two partners to every submitted homework. The teacher who is the partner in this case and the student who is the creator.

When a student is logged in, I want them to see only their homework. And when a teacher is logged in, I want them to see only the homework that they are partners to.

THE CHALLENGE
How can I add a two factor constraint here?

I tried adding another constraint where partner = current user as you see in the image below. But the data returned is for only when current user is a partner

Hi there, @kingalready13… if I understand your post correctly, a privacy rule on the Homework data type that looks like the following could do the trick.

Hope this helps.

Best…
Mike

1 Like

Obviously, no one can answer that without knowing your database structure…

But, assuming you have a Partner field, of type User, on the Homework datatype (which would be the obvious way of doing things), it’s as simple as adding a constraint on your search for Homeworks, of Partner is Current User for the teachers…

And Created by Current User for students…

If that’s all happening in a single RG, I’s use a conditional data source based on whether the user is a teacher or a student.

Of course, if your database is structured in a different way (i.e. you’ve got a list of Partners on the Homework datatype), then you’ll need to modify things accordingly.

1 Like

Theres is no privacy rules. I took them off

Um, okay… but I am saying that the privacy rule I showed is a way (and one might argue the right way) to do what you described… so, maybe you should try putting that rule in place.

1 Like

UPDATE : now that you’ve posted a screenshot… I can see you’re adding both constraints in a single search…

That will return only items that meet both (i.e. Campaigns created by the current User AND for whom the current User is the partner), which presumably will be never…

As I said, if you use a conditional DataSource depending on the user type it should work fine.

You could also use 2 searches and merge them (although I’m not sure there’s any reason to do that).

Or, as @mikeloc suggest, adding the privacy rules he provided will do the same job, as well as keeping your data secure and faster to load…

Thanks… I worked it out

1 Like

I worked it out… thanks for your help

1 Like