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
AkiraDioAkiraDio 

The default value and change it

There is a table:
http://akiradio-developer-edition.na9.force.com/

 

Value Portfolio Revenue Run Rate and IPT Revenue Target for your line of business are set by default. Requires that by clicking on the field could change the value, and perform calculations.


Sorry for my English.

 

 

 


code:

public class DecimalController
{
    public Decimal Portfolio {get; set;}
    public Decimal Revenue_Target {get; set;}
    public Decimal Estimated {get; set;}
    public Decimal Estimated_Revenue {get; set;}
    public Decimal Market {get; set;}
    public Decimal Net_Annualized {get; set;}
    
    
    public string Portfolio_name {get; set;}
    public string Revenue_Target_name {get; set;}
    public string Estimated_name {get; set;}
    public string Estimated_Revenue_name {get; set;}
    public string Market_name {get; set;}
    public string Net_Annualized_name {get; set;}
    
    public string Error {get; set;}
    
    
    public DecimalController ()
    {
        Portfolio = 1500000;
        Revenue_Target = 1600000;
        Portfolio_name = 'Portfolio Revenue Run Rate';
        Estimated_Revenue_name = 'Estimated Revenue Attrition Rate';
        Revenue_Target_name = 'IPT Revenue Target for your line of business';
        Market_name = 'Market Effect';
        Estimated_name = 'Estimated Gross Annualized Revenue Target';
        Net_Annualized_name = 'Net Annualized Revenue Target';
        
    }
    
    public PageReference reckoning ()
        {
            if (Estimated_Revenue> = 0 && Market> = 0)
            {
                decimal result = Portfolio * Estimated_Revenue/100 + (Revenue_Target - Portfolio) * 2 - ((Market/100) * Portfolio);
                Estimated = result;
                Net_Annualized = result / 2;
            }
            else
            {
            
                Error = 'Error, enter values> 0 or = 0';
                

            }
           return null;
         }

        

}


<apex:page controller="DecimalController" showHeader="false" sidebar="false">
<apex:pageBlock title="Goal calculator">
<apex:pageBlockSection>
        <apex:form>
            <apex:pageBlockTable value="{!Portfolio}" var="i">
                <apex:column value="{!Portfolio_name}" width="300"/>
                <apex:column value="{!Portfolio}"/>
            </ Apex: pageBlockTable>
 
            <apex:pageBlockTable value="{!Portfolio}" var="i">
                <apex:column value="{!Estimated_Revenue_name}" width="300"/>
                <apex:column>
                    <apex:inputText value="{!Estimated_Revenue}"/>
                </ Apex: column>
            </ Apex: pageBlockTable>

            <apex:pageBlockTable value="{!Portfolio}" var="i">
                <apex:column value="{!Revenue_Target_name}" width="300"/>
                <apex:column value="{!Revenue_Target}"/>
            </ Apex: pageBlockTable>

             <apex:pageBlockTable value="{!Portfolio}" var="i">
                <apex:column value="{!Market_name}" width="300"/>
                <apex:column>
                    <apex:inputText value="{!Market}"/>
                </ Apex: column>
            </ Apex: pageBlockTable>
            <apex:commandButton action="{!reckoning}" value="reckoning"/>
            
             <apex:pageBlockTable value="{!Portfolio}" var="i">
                <apex:column value="{!Estimated_name}" width="300"/>
                <apex:column value="{!Estimated}"/>
            </ Apex: pageBlockTable>
            
             <apex:pageBlockTable value="{!Portfolio}" var="i">
                <apex:column value="{!Net_Annualized_name}" width="300"/>
                <apex:column value="{!Net_Annualized}"/>
            </ Apex: pageBlockTable>
            {! Error}
    
                               
        </ Apex: form>
</ Apex: pageBlockSection>
</ Apex: pageBlock>
    
</ Apex: page>

Best Answer chosen by Admin (Salesforce Developers) 
AkiraDioAkiraDio

It's very simple ...

 

<apex:page controller="DecimalController" showHeader="false" sidebar="false">
<apex:pageBlock title="Goal calculator" >
<apex:pageBlockSection >
<apex:form >
<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Portfolio_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Portfolio}"/>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Estimated_Revenue_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Estimated_Revenue}"/>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Revenue_Target_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Revenue_Target}"/>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Market_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Market}"/>
</apex:column>
</apex:pageBlockTable>
<apex:commandButton action="{!reckoning}" value="reckoning"/>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Estimated_name}" width="300"/>
<apex:column value="{!Estimated}"/>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Net_Annualized_name}" width="300"/>
<apex:column value="{!Net_Annualized}"/>
</apex:pageBlockTable>
{!Error}


</apex:form>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:page>

All Answers

Scott_VSScott_VS

What is the problem?

AkiraDioAkiraDio

I want to be that when you click on the value of Portfolio Revenue Run Rate (150000) can be changed to any other (the calculation should go with the new values)

Scott_VSScott_VS

Notice the difference between how you render the Portfolio value and the Estimated_Revunue in your Visualforce page:

 

<apex:column value="{!Portfolio}"/>

 

and 

 

<apex:column>
          <apex:inputText value="{!Estimated_Revenue}"/>
</ Apex: column>

 

If you want the user to edit the Portfolio value, you have to put it in a <apex:inputText> tag.

AkiraDioAkiraDio

Sorry, I do not quite understand. Can you show me an example? For yet I still do not know much English. Once again, I ask forgiveness.

Sankalp JhingranSankalp Jhingran

Hi,

 

You can create an output link, use an ActionFunction to call the controller's method to perform calculations. I beleive you are looking for something as shown in the this page:

http://testdomain5-developer-edition.na3.force.com/MySite/myp1__ActionFunctionTest

 

Here's a simple example code, I have created for you:

<apex:page controller="ActionFunctionTestController" >
<apex:form id="frm1" >
<apex:pageBlock >
<apex:outputLabel onclick="callDoCalc('35345345345');" id="cl1">
<B>2156487 - Click here to call method</B>
</apex:outputLabel>
<apex:actionFunction action="{!doCalc}" name="callDoCalc" reRender="frm1,ot1">
<apex:param assignTo="{!testVar1}" value="" name="param1"/>
</apex:actionFunction>
<BR></BR>
<apex:outputText id="ot1" rendered="true">
Value of actionFunctionResult : {!actionFunctionResult}
<BR></BR>
Value of testVar1 : {!testVar1}
</apex:outputText>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Controller:

public class ActionFunctionTestController {

public string testVar1{get;set;}
public string actionFunctionResult{get;set;}

public PageReference doCalc(){
actionFunctionResult = 'This string variable got its value from the actionFunction';
return null;
}
}

 

NOTE: If you get your queries resolved, please mark the post as answered, so that it will help others

 

-Sankalp

Forcesecrets Blog 

 

AkiraDioAkiraDio

It's very simple ...

 

<apex:page controller="DecimalController" showHeader="false" sidebar="false">
<apex:pageBlock title="Goal calculator" >
<apex:pageBlockSection >
<apex:form >
<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Portfolio_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Portfolio}"/>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Estimated_Revenue_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Estimated_Revenue}"/>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Revenue_Target_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Revenue_Target}"/>
</apex:column>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Market_name}" width="300"/>
<apex:column >
<apex:inputText value="{!Market}"/>
</apex:column>
</apex:pageBlockTable>
<apex:commandButton action="{!reckoning}" value="reckoning"/>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Estimated_name}" width="300"/>
<apex:column value="{!Estimated}"/>
</apex:pageBlockTable>

<apex:pageBlockTable value="{!Portfolio}" var="i">
<apex:column value="{!Net_Annualized_name}" width="300"/>
<apex:column value="{!Net_Annualized}"/>
</apex:pageBlockTable>
{!Error}


</apex:form>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:page>

This was selected as the best answer