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
Lee Franke.ax999Lee Franke.ax999 

How do to a confirmation popup based on data

We have a standard page (non-VF) with an "Edit" button that launches a VF page.

 

Somewhere in this workflow (before the edit page is rendered) I would like a confirmation popup that only appears if 2 properties are met.

 

if (user == X and RecordType==Y).

 

If the user selects "OK" then the record is edited. If the user selects "Cancel" then they stay on the original page.

 

I seriously doubt I can code behind the edit button enough for it to occur on the non-VF page, so I'll need to get it done on a VF page. Can I put the confirm window on the constructor of the existing VF page? Or will I need a new  pass thru VF page that does the confirmation and then launches the appropriate page?

 

Did I miss anything?

 

thanks,

 

lee

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

 Hi,

 

You can create a custom button with the same label on the standard page and check condition in JavaScript and redirect the use according to your condition.

 

Refer the below example

 

I have created a custom buttonwith Content Source =OnClcik Javascript on the Contact with edit label and check the following condition

 

var c=confirm("do you want to edit");

if(c==true)

window.location='/{!Contact.Id}/e';

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

 

All Answers

Navatar_DbSupNavatar_DbSup

 Hi,

 

You can create a custom button with the same label on the standard page and check condition in JavaScript and redirect the use according to your condition.

 

Refer the below example

 

I have created a custom buttonwith Content Source =OnClcik Javascript on the Contact with edit label and check the following condition

 

var c=confirm("do you want to edit");

if(c==true)

window.location='/{!Contact.Id}/e';

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

 

This was selected as the best answer
Lee Franke.ax999Lee Franke.ax999

How in Javascript can I get user and record information? As I was looking into this, that seemed to be the problem was that I could not access the data that I needed in order to run the test.

 

thanks,

 

lee

Starz26Starz26

When you create the button use the merge fields in the editor, that is the eaisest way.

 

there are merge fields for $User and all of the fields on the record

 

When using the merge fields in Java remember to wrap them in single quotes i.e. '{!Stage}' if they are text based

Lee Franke.ax999Lee Franke.ax999

Merge fields, I forgot about those.

 

I'm a part time Salesforce developer for our company, so everytime I have something to do I have to blow the dust bunnies out of my brain.

 

thanks!

 

 

lee