2

I'm sorry if the title is completely butchering what I'm looking for, please let me know if should be updated.

Here's what I'm struggling with:

I have 11 checkboxes on an opp layout. I need the label/name of whatever ones are TRUE to be passed to a single text field.

Ex: Department 1 ✔️ Department 2 ✔️ Department 3 ✔️

FieldToContainTheDepartmentNames__c should = "Department 1, Department 2, Department 3"

The idea is to essentially "summarize" what departments are being sold into, into a single field vs. having to look at all the checkboxes for a ✔️. I could also then reference this field on a few other objects/places.

I've figured out how to have it check a single checkbox field, but not all 11 at once:

IF( ED__c = TRUE,"ED","")
  • It would be a fair bit easier via Apex Trigger. Do you have any coding skills? If not you might want to work your way through some Trailhead modules to familiarize yourself with the basics. – Adrian Larson Dec 20 '18 at 19:51
  • @AdrianLarson I don't have any Apex coding skills, I've attempted some JS and Python before, but all incredibly rudimentary topics. Do you think after working through some trailhead modules I might actually be able to write it in apex myself? I've done plenty on trailhead, just not much on the dev side of things. – Devin Pearman Dec 20 '18 at 19:54
  • It depends on how much time you are willing to dedicate. If you don't mind having a trailing comma, then a formula might suffice. But removing that will be trickier than it sounds. – Adrian Larson Dec 20 '18 at 19:56
  • @AdrianLarson I'm not worried one bit about a trailing comma, I'd just like that single field value so it can be passed to other places where the info should be surfaced as well. I can certainly dedicate the time on trailhead, luckily I can set aside time to go through modules at work. I'm leaning towards a formula at this point, at least until I have learned some apex basics to write a trigger. – Devin Pearman Dec 20 '18 at 19:59
1

If you don't mind a trailing comma, then you can simply use string concatenation. Note that you do not need to compare a checkbox to TRUE.

IF(Foo__c, "Foo, ", "") & 
IF(Bar__c, "Bar, ", "") & 
IF(Baz__c, "Baz, ", "") & 
IF(Etc__c, "Etc, ", "")
  • So the IF is already implying that if the listed checkbox "Foo__c" is checked, then display Foo. Is that correct? – Devin Pearman Dec 20 '18 at 20:02
  • Yep. If the box is checked, the IF evaluates true. If it is unchecked, it evaluates false. – Adrian Larson Dec 20 '18 at 20:03
  • Thank you so much, that worked perfectly! I forgot one slight addition, along with the checkboxes, there's also a text field for "other department", am I able to somehow add that value on as well, if something gets entered there" I'm assuming I would somehow compare that Other_Dept__c to NULL and if false, somehow pass that value through. – Devin Pearman Dec 20 '18 at 21:06
  • Just concatenate in & Other_Dept__c at the end. I think it would treat null as blank, but not sure. – Adrian Larson Dec 20 '18 at 21:11
0

Concat a bunch of string together

IF(Ed__c,"ED,","") + IF(Tom__c,"TOM,","") + ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.