2

I am trying to create an image field (Opp) to show one money dollar image if the closed mrc field is between 0 to 100, two money dollar images if its between than $200-299, three money dollar images if its $300-399, and one money BAG if its greater than $399. Problem is I have a gap in my formula it is not covering 101 -201 and I feel like this isnt written properly, Can anyone please advise?

IF( RecordTypeId = "012j0000000zPMn", 
IF( Closed_MRC__c < 101, 
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq ", "One Dollar", 30, 30),
IF( Closed_MRC__c < 201, 
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq ", "One Dollar", 30, 30) & " " & IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq ", "One Dollar", 30, 30),
IF( Closed_MRC__c <= 399,
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq ", "One Dollar", 30, 30) & " " & IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq ", "One Dollar", 30, 30) & " " & IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq ", "One Dollar", 30, 30),
IF( Closed_MRC__c  >=  400, 
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klk ", "Bag of Money", 30, 30),"")
))), "")
  • What are you suppose to show between 101 and 200? – GrayB Aug 27 '15 at 13:46
  • the ranges need to be adjusted in the formula--- 0-199=one dollar image 200-299 two dollar images 300-399 three dollar images and 400+ money bag – JazzyJ Aug 27 '15 at 13:51
  • 2
    Do not hard-code those URLs like that. This will break everytime you deploy between environments or if your org is migrated to another instance. You can use "servlet/yourfile" – PepeFloyd Aug 27 '15 at 13:51
  • For example should i use servlet/servlet.FileDownload?file=015j00000016Klq instead of c.na16.content.force.com/servlet/… – JazzyJ Aug 27 '15 at 14:08
2

To start you can change the numbers in the if statement to get the right images to appear like so:

IF( RecordTypeId = "012j0000000zPMn", 
IF( Closed_MRC__c < 200, 
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq", "One Dollar", 30, 30),
IF( Closed_MRC__c < 300, 
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq", "One Dollar", 30, 30) & " " & IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq", "One Dollar", 30, 30),
IF( Closed_MRC__c < 400,
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq", "One Dollar", 30, 30) & " " & IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq", "One Dollar", 30, 30) & " " & IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klq", "One Dollar", 30, 30),
IF( Closed_MRC__c  >  400, 
IMAGE("https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klk", "Bag of Money", 30, 30),"")
))), "")

You should also not use the url https://c.na16.content.force.com/servlet/servlet.FileDownload?file=015j00000016Klk

Instead you should upload your files to static resources.

The example below would be if you create two static resources named money and bag_of_money:

IF( RecordTypeId = "012j0000000zPMn", 
IF( Closed_MRC__c < 200, 
IMAGE("/resource/money", "One Dollar", 30, 30),
IF( Closed_MRC__c < 300, 
IMAGE("/resource/money", "One Dollar", 30, 30) & " " & IMAGE("/resource/money", "One Dollar", 30, 30),
IF( Closed_MRC__c < 400,
IMAGE("/resource/money", "One Dollar", 30, 30) & " " & IMAGE("/resource/money", "One Dollar", 30, 30) & " " & IMAGE("/resource/money", "One Dollar", 30, 30),
IF( Closed_MRC__c  >  400, 
IMAGE("/resource/bag_of_money", "Bag of Money", 30, 30),"")
))), "")

Additionally, I would use RecordType.Name instead of RecordTypeId as ids are different between all sandboxes and production

IF( RecordType.Name = "My Record Type Name", 
IF( Closed_MRC__c < 200, 
IMAGE("/resource/money", "One Dollar", 30, 30),
IF( Closed_MRC__c < 300, 
IMAGE("/resource/money", "One Dollar", 30, 30) & " " & IMAGE("/resource/money", "One Dollar", 30, 30),
IF( Closed_MRC__c < 400,
IMAGE("/resource/money", "One Dollar", 30, 30) & " " & IMAGE("/resource/money", "One Dollar", 30, 30) & " " & IMAGE("/resource/money", "One Dollar", 30, 30),
IF( Closed_MRC__c  >  400, 
IMAGE("/resource/bag_of_money", "Bag of Money", 30, 30),"")
))), "")
| improve this answer | |
  • My images are located in the documents tab under Grpahics Pack for Formulas already. Do I need to change this to do the static resource? Well seems like I have done this, how would I have the names of the resources to be the Money and Bag of Money – JazzyJ Aug 27 '15 at 14:10
  • 1
    The issue will arise when you start using these images in other sandboxes or if your server changes from na16 to something else. Static resources are a safer bet because they can easily be moved when creating sandboxes or deploying to production and the urls won't change. Right now, you would have to reupload those files in the new environment and change all your formulas to use the new ids for the documents. It's a warning as it might become a headache in the future :) – GrayB Aug 27 '15 at 14:19
  • Also, you could use RecordType Name instead of RecordType Id's so that it would work on production org as well. Because the Id's will be different in Production environment (except its in Full Sandbox) – Mayuresh Pawar Aug 27 '15 at 14:29

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.