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
scriptagentscriptagent 

confirmation dialog...how ?

Hi,
 
I try to develop a trigger, which displays, if(customObject.newValue < customObject.oldValue), a popup (javascript) or a text warning . The customer should be able to change the newValue or to ignore the warning. 
Unfortunately I don't have the right idea, how I can develop this or I don't know how I can call a javascript code in a Apex trigger.
 
I'm open for other suggestions or solution ideas too.
 
Hope you are able to help!
Thanks a lot! Peter


Message Edited by scriptagent on 10-02-2008 07:14 AM
Best Answer chosen by Admin (Salesforce Developers) 
scriptagentscriptagent
Hey David,
 
thank you very much for the answer. I chose you third opportunity...to control with a checkbox is really easy and works great!
I shouldn't think so complex sometimes...thank you, have a good day, Peter

All Answers

scriptagentscriptagent
Good morning,
 
till now I got not really a progress.
 
There are chances to call a "confirmation dialog" with a workflow-rule ? There must be a solution...any ideas ?
 
Thanks a lot.
David VPDavid VP
You can't run Javascript code (running client side) from an apex trigger (running server side).

What you could do is :

1) implement the whole thing in Javascript (and put for example onChange events on the fields -> these could then call a javascript method displaying your pop-up with a window.open()

2) do your checks in the trigger comparing old and new values. When the new value < old value, reload the page but this time include a <script type="javascript">....</script> block that brings up your popup (which in turn could be a VF page that allows the user to pick the new value and update it from there before you close the window). I'm not sure if this'll work and it seems kinda messy to be honest.

3) Using no code at all you could create a validation rule on the object which will complain when newvalue < oldvalue. Add a checkbox field or something like that which the user can flag to override this behaviour (and make sure that your validation rule also looks at this flag, returning 'ok' whenever this is set, regardless of the new/old values. This will not give you the popup but it will accomplish what you're trying to do


David

scriptagentscriptagent
Hey David,
 
thank you very much for the answer. I chose you third opportunity...to control with a checkbox is really easy and works great!
I shouldn't think so complex sometimes...thank you, have a good day, Peter
This was selected as the best answer