You need to sign in to do that
Don't have an account?
Juan Antonio Cantarero
Get Opportunity field value from javascript in VisualForce
Dear,
I want to perform some customs validations in the Opportunity but I can't use the "validation rules" functionality. The approach I would like to use is to create a custom VisualPage at the top of the Opportunity details page. When this VisualPage is loaded I run a "window.onload = function()". On this function I can perform any validation I want and in case of error, an alert is shown.
But my problem is that I don't know how to get the Opportunity field values from javascript. Below is my code. I hope you can give some light here:
Thanks in advance!.
I want to perform some customs validations in the Opportunity but I can't use the "validation rules" functionality. The approach I would like to use is to create a custom VisualPage at the top of the Opportunity details page. When this VisualPage is loaded I run a "window.onload = function()". On this function I can perform any validation I want and in case of error, an alert is shown.
But my problem is that I don't know how to get the Opportunity field values from javascript. Below is my code. I hope you can give some light here:
<apex:page standardcontroller="Opportunity"> <apex:form id="formId"> <!-- No Opportunity fields are placed here --> <apex:image value="/img/msg_icons/confirm16.png" style="vertical-align:top;" id="Warning_icon"/> </apex:form> <script> var Original_Amount__c = '{!Opportunity.Original_Amount__c}'; //THIS DO NOT WORKS window.onload = function() { var Original_Amount__c = document.getElementById({!Opportunity.Original_Amount__c}); //THIS DO NOT WORKS //Validations with Original_Amount__c value.... }; </script> </apex:page>
Thanks in advance!.
Do you need to display some warning message, when some fields are not have the data while saving the opportunity?
try with below code. you add multiple conditions in Controller.
VF Page Class:
If this helps, Please mark it as best answer.
Thanks,
Ankaiah
My license is SalesForce Professional Edition. Am I able to define code with classes like in your proposal?
Thanks.
You cant able to do in professional edition.
You need to develop in developer edition and then deploy it to your professional org. please refer the below link.
https://help.salesforce.com/s/articleView?id=000323569&type=1
Thanks,
Ankaiah
Thanks anyway.
Visit my site (https://couponplay.com/) to see more