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
VestaGMSVestaGMS 

Formula Help!

Is their a way to create a formula that would do the following:

 

When on the opportunity page Save is it hit, can a box pop up asking if the opportunity is a deal to close (which is a checkbox on the page)?

 

My sales staff always forgets to check the box so a reminder would be great.

 

Thanks to anyone who could help!

Best Answer chosen by Admin (Salesforce Developers) 
CaptainObviousCaptainObvious

As WYam mentioned, currently there is no formula to implement this functionality.

 

However, try this work-around...

 

First, create a new visualforce page (there is no 'Apex' involved, so you should be able to create this page in your production org).

<apex:page standardController="Opportunity" showHeader="false" sidebar="false"> <script src="/soap/ajax/17.0/connection.js" type="text/javascript"></script> <script type="text/javascript"> function initPage(){ var reminder = ''; var checkBox = '{!Opportunity.Deal_To_Close__c}'; //You may want to add additional logic here... if (checkBox == 'false') { reminder += "If this is a deal to close, please check the 'Deal To Close' checkbox"; } if (reminder!='') { alert(reminder); } } window.onload=initPage(); </script> </apex:page>

Next, add the Visualforce Page to the Opportunity page layout. (Set the height to '0' so that users don't see it).

 

How it works:

 

When the user navigates to the opportunity, the embedded visualforce page checks to see if the 'Deal To Close' checkbox is checked. If it is not, an alert box pops up reminding the user to check the box (the alert will also pop up after the user saves the opportunity).

Note that this does not prevent the opportunity from being saved (as with a validation rule).

You may want to add additional logic in the javascript so that the alert only shows if the opportunity is Closed/Won.

Hope this helps!

All Answers

SalesforceSallySalesforceSally

Create a validation rule with a message that tells users to check the checkbox

 

The validation rule would be

( Checkbox__c ) = false

 

VestaGMSVestaGMS
I do not want to make the person have to check the box though, just give them the reminder that they have the option to do it.
WYamWYam

Currently there is no "soft error" feature. I think this idea somewhere on the idea exchange and I know we've asked for the feature to our sales rep.

CaptainObviousCaptainObvious

As WYam mentioned, currently there is no formula to implement this functionality.

 

However, try this work-around...

 

First, create a new visualforce page (there is no 'Apex' involved, so you should be able to create this page in your production org).

<apex:page standardController="Opportunity" showHeader="false" sidebar="false"> <script src="/soap/ajax/17.0/connection.js" type="text/javascript"></script> <script type="text/javascript"> function initPage(){ var reminder = ''; var checkBox = '{!Opportunity.Deal_To_Close__c}'; //You may want to add additional logic here... if (checkBox == 'false') { reminder += "If this is a deal to close, please check the 'Deal To Close' checkbox"; } if (reminder!='') { alert(reminder); } } window.onload=initPage(); </script> </apex:page>

Next, add the Visualforce Page to the Opportunity page layout. (Set the height to '0' so that users don't see it).

 

How it works:

 

When the user navigates to the opportunity, the embedded visualforce page checks to see if the 'Deal To Close' checkbox is checked. If it is not, an alert box pops up reminding the user to check the box (the alert will also pop up after the user saves the opportunity).

Note that this does not prevent the opportunity from being saved (as with a validation rule).

You may want to add additional logic in the javascript so that the alert only shows if the opportunity is Closed/Won.

Hope this helps!

This was selected as the best answer
WYamWYam

That my friend, is awesome. I done learned something new!

 

Thanks Cap!

BenPBenP

The popup works great!  However, I'd like to limit it to only certain user profile id's.  I changed the IF statement as follows, but it's not popping up at all:

 

if (!$Profile.Id != "00e700000013cj1" && checkBox == "true" )

CaptainObviousCaptainObvious

Looks like you're missing the brackets in the merge field.

 

Try this:

 

... var profileId = '{!$Profile.id}'; if (profileId != "00e700000013cj1" && checkBox == "true" ) { ...

 

BenPBenP
I thank you kindly sir.  That plus correcting some case errors I had fixed me up.
BenPBenP

Well, it works fine for me as an admin.  However, other users don't get the popup.  Their profiles have access to the apex page and they have visibility to the field in question, but it just doesn't popup. 

 

Any ideas on what to check, I'm out of ideas.

CaptainObviousCaptainObvious
Do you have a different page layout for non-admins? If you do, is the apex page in their layout? If you log in as the user, do you see the popup?
BenPBenP
I do have a different layout for those people, but I have added the VF page to said layout already.  When I login as them, I can see the big blank space (left the height at 100), but the popup doesn't show.
CaptainObviousCaptainObvious
Can you post your javascript?
BenPBenP

<apex:page standardController="SVMXP__Service_Order__c" showHeader="false" sidebar="false" > <script src="/soap/ajax/17.0/connection.js" type="text/javascript"></script> <script type="text/javascript"> function initPage(){ var Popup = ''; var profile = '{!$Profile.id}'; var checkBox = '{!SVMXP__Service_Order__c.Warehouse_User__c}'; //You may want to add additional logic here... if (checkBox == "true" ) { //&& profile != "00e700000013cj1" Popup += "Service Team Alert: Do not send parts, direct them to their warehouse\n"; } if (Popup !='') { alert(Popup); } } window.onload=initPage(); </script> </apex:page>

 

You can see that I commented out the profile part just in case that was causing an issue.  The two fields in question are visible but read only in the field level security.  However, they are hidden on the layouts for all but myself.
CaptainObviousCaptainObvious

Looks like it should work- try using the 18 digit profile id instead.

BenPBenP
That may well make a difference, but i've commented out the profile part so it should popup whenever that checkbox = true regardless of profile.  Must be some permission, but I can't figure out what.
BenPBenP

I tweaked this a bit and moved to a case and it worked fine for everyone.  The page I have this on is created via s-control so maybe that has something to do with it.

 

I have another popup script that works, but it is a s-control.  I can fall back to that I think, just wanted to be up to date via visualforce.