• Juan Antonio Cantarero
  • NEWBIE
  • 10 Points
  • Member since 2021
  • Analyst
  • Linical Europe

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Dear.
This seems an easy question, but is doesn't. 
What I need is to show additional description about the picklist value selected in an Opportunity field. This description can be in a text field, another picklist, etc.
  • Approach 1: Using a formula in a VisualForce page. This sounds good, but I cannot get the value of the selected item of the custom field in the picklist. Also, I have to replicate this VisualForce on "New", "Edit" pages.
  • Approach 2: using dependant field: this partially works but by default, the selected value is "None". 
  • Approach 3: Using a text formula: but on "New" page, the formula is not calculated when the picklist value is selected. So it doesn't works. 
Any idea? I am very surprised about how SalesForce do not include this basic functionality. 
Thanks.
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:
 
<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!.
Dear. 
This seems an easy question with easy solution, but I don't find a technical solution after look in google, developer salesforce, etc.

This is what I want: I need to perform a set of validations in a lot of custom field values of the Opportunity. After see different options (process builder, validation rules, formulas, etc) the best approach if to use a VisualForce page. In that VisualForce page I want to show a text custom field, with a custom error message that can change via visualforce/javascript code.

This is my issue: I am not able to change the text custom field value. I have no erros. Just no changes on the text value. Below is the code I used in the VisualForce page.

Do you have any suggestion?
 
<apex:page standardcontroller="Opportunity">

    <apex:form id="formId">
        <apex:pageblock id="pb">
        
            <apex:pageBlockSection id="Block1" title="Opportunity Information" columns="2">
        
                <apex:inputField id="Warning_message" value="{!Opportunity.Warning_message__c}" />
                
            </apex:pageBlockSection>

        
        </apex:pageblock>
    </apex:form>
               
           
    <script type="text/javascript">
    
        function myFunction() 
        {
            document.getElementById('{!Opportunity.Warning_message__c}').value = "This will not change the value";
            document.getElementById('{!Opportunity.Warning_message__c}').innerHTML= "This will not change the value";
            document.getElementById('Warning_message').value = "This will not change the value";
            document.getElementById('Warning_message').innerHTML= "This will not change the value";            
            document.getElementById('{!$Component.formId.pb.Block1.Warning_message}').value = "This will not change the value";            
        }    
                            
        var msgObj= document.getElementById('{!Opportunity.Warning_message__c}');
        msgObj.value = "This will not change the value";            
        msgObj.innerHTML= "This will not change the value";            

    </script>
    
</apex:page>

Many thanks.
 
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:
 
<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!.
Dear. 
This seems an easy question with easy solution, but I don't find a technical solution after look in google, developer salesforce, etc.

This is what I want: I need to perform a set of validations in a lot of custom field values of the Opportunity. After see different options (process builder, validation rules, formulas, etc) the best approach if to use a VisualForce page. In that VisualForce page I want to show a text custom field, with a custom error message that can change via visualforce/javascript code.

This is my issue: I am not able to change the text custom field value. I have no erros. Just no changes on the text value. Below is the code I used in the VisualForce page.

Do you have any suggestion?
 
<apex:page standardcontroller="Opportunity">

    <apex:form id="formId">
        <apex:pageblock id="pb">
        
            <apex:pageBlockSection id="Block1" title="Opportunity Information" columns="2">
        
                <apex:inputField id="Warning_message" value="{!Opportunity.Warning_message__c}" />
                
            </apex:pageBlockSection>

        
        </apex:pageblock>
    </apex:form>
               
           
    <script type="text/javascript">
    
        function myFunction() 
        {
            document.getElementById('{!Opportunity.Warning_message__c}').value = "This will not change the value";
            document.getElementById('{!Opportunity.Warning_message__c}').innerHTML= "This will not change the value";
            document.getElementById('Warning_message').value = "This will not change the value";
            document.getElementById('Warning_message').innerHTML= "This will not change the value";            
            document.getElementById('{!$Component.formId.pb.Block1.Warning_message}').value = "This will not change the value";            
        }    
                            
        var msgObj= document.getElementById('{!Opportunity.Warning_message__c}');
        msgObj.value = "This will not change the value";            
        msgObj.innerHTML= "This will not change the value";            

    </script>
    
</apex:page>

Many thanks.