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
Florian ReissnerFlorian Reissner 

Lead assignment, Compare with array

Hi All,
I am trying to implement a Formula for auto lead assignment that does the following in a more efficient way:
IF(Round_Robin_ID__c = 1 || Round_Robin_ID__c = 3 || Round_Robin_ID__c = 6 ....)
Basically I have an array of numbers that I want to compare the Round_Robin_ID against. Ideally it would look like:
IF(ISINARRAY(Round_Robin_ID__c,[1,3,4,6,7,9,.....])
Does anyone know a smart solution to this?
Thank you!
V V Satyanarayana MaddipatiV V Satyanarayana Maddipati
Hi Florian,

Try the below code :
Set<Integer> roundRobinSet  =  new Set<Integer>{1,3,4,6,7,9};

if(roundRobinSet.contains(Round_Robin_Id__c)) {
// perform Cutsom logic.
}

Best Regards,
Satya.
Florian ReissnerFlorian Reissner
Hi Satya, Thanks for that fast reply! I think I can only enter ONE formula that evaluates to true or false in the lead assignment. As far as I understand it is not possible to include several command lines. Would it be possible to do it like this:? {1,3,4,6,7,9}.contains(Round_robin_Id__c) = TRUE Thanks for your help.
Jigna ShapariaJigna Shaparia
Hi Florian,

Easiest way that i might try would create a new picklist column and then compare it with value of picklist using formula
ISPICKVAL(picklist_field, text_literal)
Checks whether the value of a picklist field is equal to a string literal.

Hope this might help you.

Regards,
Jigna
Florian ReissnerFlorian Reissner
Hi Jigna, Thanks for your toughs. The Round Robin numbers that I specify are calculated by an external tool and change about every two weeks. My idea is to autogenerate the string in externally and copy it into SF. That is why I am looking for an easy way to change the lead distribution without going by the menu of the lead assignment tool. This is also why I cannot define a picklist each time unfortunately ;-)
Florian ReissnerFlorian Reissner
To make clearer what I mean this is a screenshot of how it is done currently:manual entering of a rule
And this is what SF makes it look like:
User-added image
I want to reproduce the same thing with Apex