Add branch logic to search component

I have a search component on Event record that looks up two sets of object records; Contact, and User.

When a search result is clicked, a record is created in EventRelation object. The creation of this record fails if a user record has been selected, this is because I set field IsParent on EventRelation to TRUE. If the search result clicked is a contact, the EventRelation record is created without issue.

I want to add some logic to the actions that differ when selecting a User and Contact record.

If an EventRelation record is being created with a Contact; set IsParent to FALSE
If an EventRelation record is being created with a User; set IsParent to TRUE

What I’ve built so far isn’t working, the EventRelation record gets created, but the Branch logic doesn’t seem to be working, or something related isn’t working…i’m not too sure.

The branch logic should be checking if the UserId from the returned object is blank, if it’s blank then the IsParent field should be updated to TRUE.

I’d like to know what I am doing wrong, so this can be fixed? Or am I going to have to use two separate lookup fields, one for User records, the other for Contacts?

Hi Glenn

You could try nesting the logic.  Something like this I used in a SF formula which you can adapt:

IF(AND((NOT(ISPICKVAL(Fascia_Colour__c,“White”))), Grained__c = true), (UnitPrice__c * Quantity__c) + 240,(IF (OR(Grained__c = true, (NOT(ISPICKVAL(Fascia_Colour__c,“White”)))), (UnitPrice__c * Quantity__c) + 120, (UnitPrice__c * Quantity__c))))

Hope this helps you along.