Skip to main content

I am trying to compare the value of a field in two different models and based on the results check a box. I have been trying to create a ui-only formula field with no success.

Can someone tell me what I am doing wrong or if the ui-only field can not do what I want it to do?


Use Case
Two object “A” and “B”
The ui-only field is on object A
I want to compare the Item field in object a with the item field in object b
If there is a match the box is checked


Formula:
CONTAINS(MODEL_LOOKUP(“B”,“SCMC__Item_Master__r.Id”,“SCMC__Item_Master__r.Id”))

Hi Tami

I created a page using 2 models.  I created a Ui Only Field in the first model and set the display type as formula and the Formula Return Type = checkbox.

I created a second Ui Field and chose the Display Type as Reference and pointed it to the Object that I want to compare fields with a filter to drill down to the record.

I used the following formula for the first Ui Only Field:

IF( {{field_1}} != {{UiReferenceField}}, false, true)

Hope this helps?



Hi Greg,

Thank you for the great directions, you pointed me in the direction I needed to go! 


I had to change the reference ui-only field to a formula field looking to a model. I needed to lookup to a model and not an object because I needed the conditions set in the model to be taken into consideration. 

I am using this to render an icon on a drawer icon to only show if there is data in the drawer.


Explanation:

1. Created a page using 2 models, but the ui-only fields are on the same model.

2. Created a Ui Field and chose the display type as formula and the Formula Return Type = Text. The formula will pull in the results from the second model so I can compare fields.

3. Created a Ui Only Field and set the display type as formula and the Formula Return Type = checkbox.
 


Here is the final result:

Ui-Only field 1:
MODEL_LOOKUP(“Model that I want to pull results from”,“field”,“field”,{{field}})

Ui-Only field 2:
IF( {{field__c from model}} == {{Ui-Only Formula Field 1}}, 1, 0)

Hope this helps someone!