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
zen_njzen_nj 

how to create pop up window when someone saves an entry in a custom object (and a condition is met)

I have a simple requirement and I am hoping it's straight forward to do.  I am still a beginner in Visualforce and apex code so am looking for someone to help out.

 

The requirement is pretty simple - when someone edits an entry in the custom object (but it can be standard object as well like Case),  and if one of the field in the object has a certain value, then when the entry has been saved, I want to have a pop up window with a message reminding someone to do something.

 

So for simplicity, let's say the custom object is called Conn__c, and the field is a picklist field called Status__c.

So whenever Status__c="Closed" (or other value), I want to have a message window pop up reminding the user to do xyz.

There should be an ok button in the popup window that the user could then click to get rid of the pop-up window and return control back to the main window (i.e. the Conn__c entry that was just saved)

 

Can someone please provide me with some guidance on this. It doesn't have to be a complete code, but something specific (and combined with pseudocode) would be helpful so I can at least figure out what direction to take.

 

I guess I need to have an apex class/trigger that will check whenever the Conn__c object is saved/edited and if the condition is met, then it will generate a popup message. 

Or maybe it can just be a custom button that override the "Save" button when someone is in edit.

I had some sample code before from someone that was using s-control but that isn't supported anymore in salesforce and it looks like the way to go now is with apex code and visualforce page.


Thanks in advance.

 

Suresh RaghuramSuresh Raghuram

hey Zen when it comes to the VF Pages you can do one thing.

 


After making all the changes and clicking the save button you add

 

<apex:CommandButton action="{!Save}"  onClick="popupWindow();" value="Save" />

 

Write the Script in the visual force

 

<apex:page>

<apex:form>

<script>

popup(){

Window.open('/VFPage Name');

}

ok(){

Window.close();

}

</script>

 

<apex:CommandButton action="{!Save}"  onClick="popupWindow();" value="Save" />

<apex:CommandButton action="{!ok}"  onClick="popupWindow();" value="ok" /> // This and the script for ok to be on the popup page.

</apex:form>

</apex:page> 

 

If this gives helps you make this as a solution.

zen_njzen_nj

Hi Suree

 

I am sorry, I am trying to understand the whole VF and apex class thing still.

Are you saying I need to create a VF page (call it something like VFEdit) and replace the default Edit button and then in that VF page, put in the code below to replace the Save button feature?