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
afleetwoodafleetwood 

IF Statement with checkbox and Image

I can't seem to get my formula correct---

I want to have an image displayed if Named_Account__c = true

 

IF (Named_Account__c, IMAGE(servlet/servlet,filedownload?file=xxxxxxx"), 'blank")

 

and i get this message

Error: Incorrect number of parameters for function 'IMAGE()'. Expected 2, received 1

 

What am i missing?

Best Answer chosen by Admin (Salesforce Developers) 
chris.noechris.noe

Not sure what the issue would be then.  Are you using internet explorer?  I noticed this in the help file for the image formula: "If you use Internet Explorer, you may need to change your security settings so that it does not display a warning prompt when images use HTTP protocol. See the online help for Internet Explorer for instructions on changing your security settings."

 

I have set this up in my developer org and it works fine with the following formula:

 

IF(Named_Account__c, IMAGE("/servlet/servlet.FileDownload?file=015d0000000dS1A", "Named Account"), "")

 

All Answers

chris.noechris.noe

You are missing the second parameter required by the IMAGE function which is "alternate_text" and you also have some syntax errors in the formula.  Try this:

 

IF (Named_Account__c, IMAGE("/servlet/servlet.filedownload?file=xxxxxxx", "Named Account"), 'blank"))

afleetwoodafleetwood

Thank you for your help!!

 

Unfortunately, though the formula had no errors, it does not display my graphic (stored in documents) correctly.  The graphic displayed correctly before I created the formula to only display when the Named Account box was checked.... any suggestions!

 

 

chris.noechris.noe

Make sure your image in Documents has the "Externally Available Image" checkbox checked and also make sure the the Document folder that is accessible by all users (i.e. not in your personal documents folder or a folder with restricted visibility).

afleetwoodafleetwood

yep-- done all that. The image worked before the addition of the IF statement

chris.noechris.noe

Can you post your modified formula again so I can take a look?

afleetwoodafleetwood

I tried the following:

IF (Named_Account__c, IMAGE("/servlet/servlet.filedownload?file=xxxxxxx", "Named Account"), " ")

 

and

IF (Named_Account__c, IMAGE("/servlet/servlet.filedownload?file=xxxxxxx", "Named Account"), "blank ")    ----- This one showed the text BLANK when box was not checked

chris.noechris.noe

Try capitalizing the F and D in filedownload.  Looks like they are case sensative:

 

IF(Named_Account__c, IMAGE("/servlet/servlet.FileDownload?file=xxxxxx", "Named Account"), " ")

afleetwoodafleetwood

Chris,

 

Thanks for your patience, it still shows a box with a red X in it and the text Named Account but not my graphic.  

  Any other ideas?

 

IF (Named_Account__c, IMAGE("/servlet/servlet.FileDownload?file=xxxxxxx", "Named Account"), " ")

chris.noechris.noe

What are you putting in for the value of "xxxxxxx"?  This should be the id of the document that you get from the URL when viewing the document.  If the URL for your document is https://na15.salesforce.com/015i0000000UZhy, the value you input for "xxxxxxx" should be 015i0000000UZhy.

afleetwoodafleetwood

it is... I just didn't feel like typing all the numbers/digits. I copied the link from the view document page and just started with the "servlet" part.  As I said, it was working fine until I added the IF statement, so there is something there that is causing a problem.

chris.noechris.noe

Not sure what the issue would be then.  Are you using internet explorer?  I noticed this in the help file for the image formula: "If you use Internet Explorer, you may need to change your security settings so that it does not display a warning prompt when images use HTTP protocol. See the online help for Internet Explorer for instructions on changing your security settings."

 

I have set this up in my developer org and it works fine with the following formula:

 

IF(Named_Account__c, IMAGE("/servlet/servlet.FileDownload?file=015d0000000dS1A", "Named Account"), "")

 

This was selected as the best answer
afleetwoodafleetwood

Thank YOU-- you were such a big help!!!

 

It was totally my mistake-- it is officially working now

 

Anne Fleetwood

Salesforce Administrator

Direct: 843.795.7006 (home office)

THE KEN BLANCHARD COMPANIES