Don't Render a Record if it's Referenced in a Junction Object

  • 1
  • Question
  • Updated 4 years ago
Situation:
  • Opportunity Skuid detail
  • Custom object titled Domain that looks up to the Account
  • Custom junction object titled Opportunity to Domain that looks up to Opportunity and Domain
What's currently happening:
  • I have a popup that a user must first create a Domain record, and then they copy that record to the junction object (using a multiple action that creates a new row pulling the Domain and Opportunity). An Opportunity cannot be closed won without at least one junction object.
  • When they've added the record to the junction object, it is still visible. This can be confusing if there are many domains.

  • If I refresh the page, it works how I want it to. The Domains that have been added to the junction object are no longer visible on the Domain object.
What I'd Like to Happen:
The moment someone clicks the green up arrow (this adds the Domain on the bottom table to the junction table on the top), that record is no longer visible on the Domain table. If they remove it from the top table, it should be visible again on the bottom.

Current Process:
On my domain model, I have a condition using a subquery: Domain__c records where Id is not in the set of values specified by returning Domain__c values from a subquery on the Opportunity_to_Domain_App__c object.

Clearly that's working, it's just not rendering as I add/remove records from the junction object. Any ideas how to get this to work? Perhaps some way to make the Domain object refresh on its own, or something to that effect?

Let me know if I need to clarify anything.

Thanks!
Dylan
Photo of Dylan Rodgers

Dylan Rodgers

  • 748 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I think you will get desired effect if you add a "query model" action in your "up arrow" sequence, and chose the "account domains" model. This will re-execute the  query with the subquery condition, and hide the record you have just used. 

At least that is what I think should work. 
Photo of Dylan Rodgers

Dylan Rodgers

  • 748 Points 500 badge 2x thumb
That worked immediately - thanks Rob! Did the same thing for the remove button on the junction object so this entire process looks great.

While we're here, I'm curious about doing one other thing related to these objects.

When an Opportunity is Closed Won, I'd love to have the records that are found in the junction object update the record that it looks up to on the Domain object.

So for example, if ESPN App (iOS) is the only thing actually being sold and is on the junction object for this opportunity, I'd like that to be reflected on the Domain record. The Domain record of ESPN App (iOS) would have a boolean field called Active__c that is set to TRUE. The other record, ESPN (Web) wouldn't be on the Opportunity and would be left at FALSE.

Is there a relatively simple solution here, or would it be easier done using an Apex trigger?