How do I conditionally activate conditions on a Model and activate the second condition if first condition did not return rows

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I have a scenario where from a custom Quote object I am trying to match an item name on the Salesforce Products object. If the match fails I need to activate a second condition matching on a custom field called "drawing number".

I know that using actions I can activate conditions on the Product Model. What I need to figure out is how do I determine if the query returned a row. I know I can do this in javascript to see if the model returned a row. But if there is no row returned how do I conditionally specify that the next Product Model condition (filter) needs to be executed in that case to try to match on the drawing number.
Photo of Jayesh Bhatnagar

Jayesh Bhatnagar

  • 476 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Make a third condition is the opposite of your first condition. Then use this Grouping Logic.

1 OR (2 AND 3)
Photo of Jayesh Bhatnagar

Jayesh Bhatnagar

  • 476 Points 250 badge 2x thumb
I need to populate a text field with different values based on how the match was returned. For e.g. if the Item Name matched exactly I would populate a text field with "Item Name Match". If instead the drawing number matches I would populate the text field with "Drawing Number Match".
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Conditions can be deactivated if no rows are found in the source model.

So, make a model for "Item Name" and "Drawing Number". Set conditions on these models so that they abort if there is no match.



Set your conditions in your original model to look for matches in these new models. If no match then deactivate the condition. This is assuming that at least one of the fields always has data.



Now the only thing I'm not sure about your requirement is what you want to do with your text field. If it's only display on the screen then I'd use a template field to dynamically display either item name or drawing number. Make sure to enable HTML on the template field. Not doing so won't shrink the field size on the screen to only what's necessary to display the text.
{{#Item_Name__c}}{{Item_Name__c}}{{/Item_Name__c}}
{{#Drawing_Number__c}}{{Drawing_Number__c}}{{/Drawing_Number__c}}
Photo of Jayesh Bhatnagar

Jayesh Bhatnagar

  • 476 Points 250 badge 2x thumb
The Quote Items/Products Model will have multiple rows of items in it. How do I make this work for a multiple items scenario. The condition seems to currently just match the first row returned from the Model.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Change the operator of the condition to be "in" rather than "=".