Tricky model condition.

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
Here is a scenario which i have not been able to put a logic for.
display set of records from object A where logged in user is owner and record is created in last 90 days
OR
display set of records from object A where record created in last 90 days and logged in user is member of its child object record B

now there is a possibility that logged in user is owner as well as member in object B. somehow, all the permutations and combinations fails to fetch correct data. either no row is returned or if i disable one of the condition, then incomplete dataset is returned. any suggestions will be appreciated.
Photo of Sunny Sharma

Sunny Sharma

  • 678 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of TJ

TJ

  • 952 Points 500 badge 2x thumb
What do you mean by 'member of child object record'?
Photo of Sunny Sharma

Sunny Sharma

  • 678 Points 500 badge 2x thumb
means B.user__c = running user
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
This is doable in Skuid. 

First you need to set up a condition that limits records to those created in the last 90 days.  It looks like that is required on both paths. 

Second,  set up a condition that limits records to those owned by the current user. 

The third part is tricky.  You can't just do a subquery condition and then include it in an or statement (with 2)   Salesforce will yell at you.   So you need to create a second model (put it above your first model).  It needs to filter all the children records to those owned by the current user.  (You might also be able to reduce that model volume by adding a second condition that limits it to records whose parent was created in the last 90 days).  This model also needs to have the parentId as a field. 

Then go back to your first model and add a third condition that filters record ID's to those IN the list of Parent ID's from the second model.   See this condition below - where I'm trying to filter Accounts to those where the Opportunity Child record is owned by the running user. 



Finally you tie these together with Grouping Logic so that records are retrieve when they meet conditions 1 and (2 or 3). 



That should take care of things. 
Photo of Sunny Sharma

Sunny Sharma

  • 678 Points 500 badge 2x thumb
thanks Rob. the sequence of models was the issue. thanks again.
:)