function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RMS ITRMS IT 

Make one or two field required when picklist value is selected.

Hello,

I have a scenario whereby when a user select a certain value from a picklist. He/She must fill up either one of two custom lookup fields.
Through google and lurking i am able to come up with the following... but i just can't get the syntax correct. 

Appreciate any advice for my formula. 

AND ( 
OR ( 
ISPICKVAL(Type__c, "R2R-2015"), 
ISPICKVAL(Type__c, "R2R-2016"), 
ISPICKVAL(Type__c, "R2R-2017") 
), 
 LEN ( MIF_Contract__c ) < 1 OR LEN ( MIF_Profile__c ) < 1) 
)
Best Answer chosen by RMS IT
Shingo YamazakiShingo Yamazaki
Oh, sorry. I misunderstood the logic you'd like to realize.

Then 2nd "OR" operator should be "AND", like this.


AND ( 
OR ( 
ISPICKVAL(Type__c, "R2R-2015"), 
ISPICKVAL(Type__c, "R2R-2016"), 
ISPICKVAL(Type__c, "R2R-2017") 
), 
 AND(LEN ( MIF_Contract__c ) < 1, LEN ( MIF_Profile__c ) < 1)
)

Does it work?

All Answers

Shingo YamazakiShingo Yamazaki
Try this.

AND ( 
OR ( 
ISPICKVAL(Type__c, "R2R-2015"), 
ISPICKVAL(Type__c, "R2R-2016"), 
ISPICKVAL(Type__c, "R2R-2017") 
), 
 OR(LEN ( MIF_Contract__c ) < 1, LEN ( MIF_Profile__c ) < 1)
)
RMS ITRMS IT
Hi There
thanks for the reply. I have tried your suggestion but it still only check the first condition LEN ( MIF_Contract__c ) < 1
i would like it that no error will return if either MIF_Contract__c or  MIF_Profile__c is filled. 

Regrads
 
Shingo YamazakiShingo Yamazaki
Oh, sorry. I misunderstood the logic you'd like to realize.

Then 2nd "OR" operator should be "AND", like this.


AND ( 
OR ( 
ISPICKVAL(Type__c, "R2R-2015"), 
ISPICKVAL(Type__c, "R2R-2016"), 
ISPICKVAL(Type__c, "R2R-2017") 
), 
 AND(LEN ( MIF_Contract__c ) < 1, LEN ( MIF_Profile__c ) < 1)
)

Does it work?
This was selected as the best answer
RMS ITRMS IT
It Works !

Thank You !
Shingo YamazakiShingo Yamazaki
I'm glad to here that.

I hope you choose one of my comments as a best answer and make this question Solved.