0

The TotalValue__c field being calculated on the fly/client side while the user is entering the field values and and so that they don’t have to do the calculation themselves.

TotalValue__c = ((Revenue1__c + Revenue2__c)*Term__c) + Fee1__c + Fee2__c .

Visualforce Page

<apex:page controller="examplecontroller" sidebar="false" tabStyle="Opportunity" >

<apex:form id="newform">

 <apex:sectionHeader Title="Example"  />

   <apex:outputPanel id="addRender" >
    <apex:repeat value="{!serlin}" var="s" id="theRepeat">            
    <apex:pageBlock id="block1">

     <apex:pageBlockSection collapsible="true" showHeader="true" title="Service" id="section1">               

                <apex:inputfield value="{!s.Revenue1__c}" required="true"/>
                <apex:inputField value="{!s.Revenue2__c}" required="true"/>
                <apex:inputField value="{!s.Fee1__c}"  required="true"/>
                <apex:inputField value="{!s.Fee2__c}" required="true"/>
                <apex:inputField value="{!s.Term__c}" required="true"  />
                <apex:inputField value="{!s.TotalValue__c}" required="true" />

    </apex:pageBlockSection> 


</apex:pageBlock>       
</apex:repeat> 
</apex:outputPanel>

</apex:form>

Controller

public with sharing class examplecontroller {


public LIst<example__c> serlin {get;set;}
public String OpportunityId{get;set;}



public examplecontroller() 
{
    try{

        serlin = new list<Service_Line__c>();
        OpportunityId =ApexPages.currentPage().getParameters().get('id');

        if(OpportunityId != null && OpportunityId != '') 
        {

            serlin =  [SELECT Id,Revenue1__c,Revenue2__c,Fee1__c,Fee2__c,Term__c,TotalValue__c FROM example__c WHERE Opportunity__c =:OpportunityId];
            System.debug('serlinlst:'+serlin);

        }
    } catch(Exception e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    } 

}

}

what is best way to achieve this one using jquery or javascript or visualforce components?

Thanks Nagarjuna

  • What is the question? Is something throwing an error? It doesn't look like you have any logic currently in your code to handle this. Is the Total_Contract_Value__c going to be stored in Salesforce? Is this something better done in Javascript? – Nick Cook Jul 14 '14 at 10:44
  • 1
    This Update Total with Javascript has a JavaScript answer and a Salesforce re-render answer that if you are not comfortable with JavaScript and don't mind a small time delay is probably a better way to go. – Keith C Jul 14 '14 at 10:51
  • @nagarjuna Cool. I've copied the comment to an answer; marking that as the accepted answer will avoid others looking to help you even though you have figured it out. – Keith C Jul 14 '14 at 13:30
1

This Update Total with Javascript has a JavaScript answer and a Salesforce re-render answer that if you are not comfortable with JavaScript and don't mind a small time delay is probably a better way to go.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.