• tylero
  • NEWBIE
  • 20 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 6
    Replies
I have written a visualforce page for a custom object.  I need to have 3 fields summed together and have the total populate on change of the input values.

The total should calculate on change of any inputField value.  I can get it to work by using...
<script type="text/javascript" name="Real-time Calculation"> 
function calc(A,B,C,SUM) { 
  var one = Number(A); 
  if (isNaN(one)) { alert('Invalid entry: '+A); one=0; } 
  var two = Number(document.getElementById(B).value);  
  if (isNaN(two)) { alert('Invalid entry: '+B); two=0; }
  var three = Number(document.getElementById(C).value);  
  if (isNaN(three)) { alert('Invalid entry: '+C); three=0; }
  document.getElementById(SUM).value = one + two + three; 
} 
</script>
for the script code and...
<input value="{!Pricing__c.Num1__c}" styleClass="masterClass" id="dpd1" onChange="calc(this.value,'dpd2','dpd3','dpdresult')" />
<input value="{!Pricing__c.Num2__c}" styleClass="masterClass" id="dpd2" onchange="calc(this.value,'dpd1','dpd3','dpdresult')" />
<input value="{!Pricing__c.Num3__c}" styleClass="masterClass" id="dpd3" onchange="calc(this.value,'dpd1','dpd2','dpdresult')" />
<output value="{!Pricing__c.NumTotal__c}" id="dpdresult" />
for the visualforce code.

The total will populate on the visualforce page on change of the values for any of the 3 number fields.  The problem is that the values won't save to the record upon saving from the Visualforce page since the fields aren't <apex:inputField /> or <apex:outputField>.  If I change the <input /> fields to <apex:inputField />, then the entered values save to the record but don't populate the total.

How do I get the input values to save to the object fields and calculate the sum of the fields dynamically without saving the record or refreshing the page/section?

I am trying to capture an element from an external webpage and display it on a visualforce page whenever the text value in a field exists as a value for the external webpage. For example, if I type "GOOG" in the text field, then the page should render the current price for Google's stock.

 

Here are the details of the task:

1. Create a field to enter the ticker symbol of a stock.

2. Use the inputted ticker symbol to render a call to Google Finance or Yahoo! Finance.

3. Return the quoted price on the webpage to the visualforce page in a field.

4. The page should rerender the current price every 10 seconds.

 

I currently have the following object and fields:

Object: Stock_SC__c

 

Fields:

1. Ticker_Symbol_SC__c = text field to capture the desired ticker symbol.

2. Google_Finance_Link_SC__c = formula field that concatenates the base website URL (http://www.google.com/finance?q=) and Ticker_Symbol_SC__c text field.

3. Yahoo_Finance_Link_SC__c = formula field that concatenates the base website URL (http://finance.yahoo.com/q?s=) and Ticker_Symbol_SC__c text field.

 

The element of Google finance that stores the current price is "<span id="ref_694653_l">1,033.89</span>." For Yahoo! Finance, the element is "<span id="yfs_l84_z">73.06</span>."

 

Any help is appreciated!

  • November 25, 2013
  • Like
  • 0

I am new to coding and I am working on my first trigger.

 

I have an object called "Affiliations" and another called "Addresses." The Affiliations object enables multiple Business Account relationships for Person Accounts instead of one Business Account per Person Account. The Addresses object enables an Account to have multiple Addresses.

 

Business rules:

1. Every Business Account only has 1 physical address.

2. Person Accounts may have many addresses.

3. Person Accounts may have one or more Business Account affiliation(s).

4. Business Accounts may have one or more Business Account affiliation(s).

5. Each Person Account affiliated to a Business Account should inherit the physical address of the Business Account.

 

I am trying to achieve item #5 with a trigger. Whenever an Affiliation is created between a Business Account and Person Account, I want the Address record of the Business Account to be copied/cloned and made an attribute of the Person Account. I can get the trigger to create an Address record on the Person Account when an Affiliation record is created, but don't know what to do from there to get the values from the Business Account address on the new Address record.

 

This is what I have so far...

 

 

 

trigger createAffiliationAddress on Affiliation_SC__c (after insert, after update){

 


List<Address_SC__c> copyParentAddress = new List<Address_SC__c>();

List<Address_SC__c> parentAddress = [SELECT Id, Account_SC__c, Address_Line_1_SC__c, Address_Line_2_SC__c, City_SC__c,
Country_SC__c, Postal_Code_SC__c, State_SC__c
FROM Address_SC__c
WHERE Account_SC__c = :Trigger.new[0].id];

 

for (Affiliation_SC__c newAffiliation: Trigger.new){
copyParentAddress.add (new Address_SC__c(
Account_SC__c = newAffiliation.To_Account_SC__c));

 

// Rather than insert the addresses individually, add the addresses to a list and bulk insert it. This makes the
// trigger run faster and allows us to avoid hitting the governor limit on DML statements.

}
insert copyParentAddress;
}

 

 

 

Will you please help?

  • November 22, 2013
  • Like
  • 0
I have written a visualforce page for a custom object.  I need to have 3 fields summed together and have the total populate on change of the input values.

The total should calculate on change of any inputField value.  I can get it to work by using...
<script type="text/javascript" name="Real-time Calculation"> 
function calc(A,B,C,SUM) { 
  var one = Number(A); 
  if (isNaN(one)) { alert('Invalid entry: '+A); one=0; } 
  var two = Number(document.getElementById(B).value);  
  if (isNaN(two)) { alert('Invalid entry: '+B); two=0; }
  var three = Number(document.getElementById(C).value);  
  if (isNaN(three)) { alert('Invalid entry: '+C); three=0; }
  document.getElementById(SUM).value = one + two + three; 
} 
</script>
for the script code and...
<input value="{!Pricing__c.Num1__c}" styleClass="masterClass" id="dpd1" onChange="calc(this.value,'dpd2','dpd3','dpdresult')" />
<input value="{!Pricing__c.Num2__c}" styleClass="masterClass" id="dpd2" onchange="calc(this.value,'dpd1','dpd3','dpdresult')" />
<input value="{!Pricing__c.Num3__c}" styleClass="masterClass" id="dpd3" onchange="calc(this.value,'dpd1','dpd2','dpdresult')" />
<output value="{!Pricing__c.NumTotal__c}" id="dpdresult" />
for the visualforce code.

The total will populate on the visualforce page on change of the values for any of the 3 number fields.  The problem is that the values won't save to the record upon saving from the Visualforce page since the fields aren't <apex:inputField /> or <apex:outputField>.  If I change the <input /> fields to <apex:inputField />, then the entered values save to the record but don't populate the total.

How do I get the input values to save to the object fields and calculate the sum of the fields dynamically without saving the record or refreshing the page/section?

I am trying to capture an element from an external webpage and display it on a visualforce page whenever the text value in a field exists as a value for the external webpage. For example, if I type "GOOG" in the text field, then the page should render the current price for Google's stock.

 

Here are the details of the task:

1. Create a field to enter the ticker symbol of a stock.

2. Use the inputted ticker symbol to render a call to Google Finance or Yahoo! Finance.

3. Return the quoted price on the webpage to the visualforce page in a field.

4. The page should rerender the current price every 10 seconds.

 

I currently have the following object and fields:

Object: Stock_SC__c

 

Fields:

1. Ticker_Symbol_SC__c = text field to capture the desired ticker symbol.

2. Google_Finance_Link_SC__c = formula field that concatenates the base website URL (http://www.google.com/finance?q=) and Ticker_Symbol_SC__c text field.

3. Yahoo_Finance_Link_SC__c = formula field that concatenates the base website URL (http://finance.yahoo.com/q?s=) and Ticker_Symbol_SC__c text field.

 

The element of Google finance that stores the current price is "<span id="ref_694653_l">1,033.89</span>." For Yahoo! Finance, the element is "<span id="yfs_l84_z">73.06</span>."

 

Any help is appreciated!

  • November 25, 2013
  • Like
  • 0

I am new to coding and I am working on my first trigger.

 

I have an object called "Affiliations" and another called "Addresses." The Affiliations object enables multiple Business Account relationships for Person Accounts instead of one Business Account per Person Account. The Addresses object enables an Account to have multiple Addresses.

 

Business rules:

1. Every Business Account only has 1 physical address.

2. Person Accounts may have many addresses.

3. Person Accounts may have one or more Business Account affiliation(s).

4. Business Accounts may have one or more Business Account affiliation(s).

5. Each Person Account affiliated to a Business Account should inherit the physical address of the Business Account.

 

I am trying to achieve item #5 with a trigger. Whenever an Affiliation is created between a Business Account and Person Account, I want the Address record of the Business Account to be copied/cloned and made an attribute of the Person Account. I can get the trigger to create an Address record on the Person Account when an Affiliation record is created, but don't know what to do from there to get the values from the Business Account address on the new Address record.

 

This is what I have so far...

 

 

 

trigger createAffiliationAddress on Affiliation_SC__c (after insert, after update){

 


List<Address_SC__c> copyParentAddress = new List<Address_SC__c>();

List<Address_SC__c> parentAddress = [SELECT Id, Account_SC__c, Address_Line_1_SC__c, Address_Line_2_SC__c, City_SC__c,
Country_SC__c, Postal_Code_SC__c, State_SC__c
FROM Address_SC__c
WHERE Account_SC__c = :Trigger.new[0].id];

 

for (Affiliation_SC__c newAffiliation: Trigger.new){
copyParentAddress.add (new Address_SC__c(
Account_SC__c = newAffiliation.To_Account_SC__c));

 

// Rather than insert the addresses individually, add the addresses to a list and bulk insert it. This makes the
// trigger run faster and allows us to avoid hitting the governor limit on DML statements.

}
insert copyParentAddress;
}

 

 

 

Will you please help?

  • November 22, 2013
  • Like
  • 0
Hello All,

I am pulling a list of opportunities from controller and running it through apex:repeat.

one of the column has a click that calls the bootstrap modal. i wanted this modal to display details related to the record i clicked.

in my case, it is always displaying details of first record even if i click 5th row of this table.

here is my code, please help me.
<apex:page controller="OpportunityListViewController">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
  th{background: #ff9999;}
  tr{background: #ffe6e6;}
  a{font-color:blue;}
  </style>
 <apex:form >
 <apex:pageBlock >
 <div style="width:100%" class="container">
 <h4>New Leads - first contact</h4><br></br><br></br>
 <table width="100%" class="table table-bordered table-hover">
 <th >Action</th>
 <th>Opp ID</th>
 <th>FullName</th>
 <th>Email</th>
 <th>Home Phone</th>
 <th>Work Phone</th>
 <th>Mobile Phone</th>
 <th>Stage</th>
 <th>Status</th>
 <apex:repeat value="{!NewOpps}" var="New">
 <tr><td>
 
 <div><a href="#" data-target="#pwdModal" data-toggle="modal">Notes</a></div> 
  
  
  </td>
  <td>{!New.ID}</td>
  <td>{!New.Account.FirstName} {!New.Account.LastName}</td>
  <td>{!New.Account.PersonEmail}</td>
  <td>{!New.Account.Home_Phone__pc}</td>
  <td>{!New.Account.Work_Phone__pc}</td>
  <td>{!New.Account.PersonMobilePhone}</td>
  <td>{!New.StageName}</td>
  <td>{!New.Opportunity_Status__c}</td>
  <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" style="border:0px;">
                          <div class="modal-dialog" style="border:0px;">
                          <div class="modal-content" style="border:0px;">
                              <div class="modal-header text-left">
                                  <h4 style="color:#2d4366;">Providing contact feedback for {!New.Account.FirstName} {!New.Account.LastName} {!New.ID}</h4>
                              </div>
                              <div class="modal-body" style="border:0px;">
                                  <div class="col-md-12" style="border:0px;">
                                        
                                            <div class="panel-body" style="border:0px;">
                                                        
                                             </div>     
                                    </div>
                              </div>
                              <div class="modal-footer" style="border:0px;">
                                  <div class="col-md-12">
                                        <fieldset>                                              
                                             <apex:commandbutton styleclass="btn btn-lg btn-primary btn-block" value="Send My Password" />
                                         </fieldset>
                                  </div>    
                              </div> 
                          </div>
    </div></div>
  </tr>
  </apex:repeat></table>
<!-- <apex:pageBlockTable value="{!NewOpps}" var="New" border="1">
 <apex:column headerValue="Action"><div><a href="#" data-target="#pwdModal" data-toggle="modal">Forgot my password</a></div>   </apex:column>
  <div id="pwdModal" class="modal fade" tabindex="-1" role="dialog" style="border:0px;">
                          <div class="modal-dialog" style="border:0px;">
                          <div class="modal-content" style="border:0px;">
                              <div class="modal-header text-center">
                                  <p style="color:#2d4366;">A temporary password will be send to . You can reset your password by logging into the application with the provided temporary password.</p>
                              </div>
                              <div class="modal-body" style="border:0px;">
                                  <div class="col-md-12" style="border:0px;">
                                        
                                            <div class="panel-body" style="border:0px;">
                                                        <fieldset>                                                
                                                            <apex:commandbutton styleclass="btn btn-lg btn-primary btn-block" value="Send My Password" />
                                                        </fieldset>
                                             </div>     
                                    </div>
                              </div>
                              <div class="modal-footer" style="border:0px;">
                                  <div class="col-md-12">
                                  <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> 
                                  </div>    
                              </div> 
                          </div>
                          </div>
  </div>
  <apex:column value="{!New.ID}"  headerValue="Opp ID"/>  
  <apex:column value="{!New.Account.FirstName} {!New.Account.LastName}"  headerValue="Fullname"/>
  <apex:column value="{!New.Account.PersonEmail}"  headerValue="Email"/>
  <apex:column value="{!New.Account.Home_Phone__pc}"  headerValue="Home phone"/>
  <apex:column value="{!New.Account.Work_Phone__pc}"  headerValue="Work phone"/>
  <apex:column value="{!New.Account.PersonMobilePhone}"  headerValue="Mobile phone"/>
  <apex:column value="{!New.StageName}"  headerValue="Stage"/>
  <apex:column value="{!New.Opportunity_Status__c}"  headerValue="Status"/>
 </apex:pageBlockTable> -->
 </div><br></br><br></br>
 <div style="width:100%" class="container">
 <h4>Leads -  Second contact</h4><br></br><br></br>
 <apex:pageBlockTable value="{!SecondContactOpps}" var="second" border="1">
 <apex:column headerValue="Action"/>
  <apex:column value="{!second.ID}"  headerValue="Opp ID"/>  
  <apex:column value="{!second.Account.FirstName} {!second.Account.LastName}"  headerValue="Fullname"/>
  <apex:column value="{!second.Account.PersonEmail}"  headerValue="Email"/>
  <apex:column value="{!second.Account.Home_Phone__pc}"  headerValue="Home phone"/>
  <apex:column value="{!second.Account.Work_Phone__pc}"  headerValue="Work phone"/>
  <apex:column value="{!second.Account.PersonMobilePhone}"  headerValue="Mobile phone"/>
  <apex:column value="{!second.StageName}"  headerValue="Stage"/>
  <apex:column value="{!second.Opportunity_Status__c}"  headerValue="Status"/>
 </apex:pageBlockTable> 
 </div>
 </apex:pageBlock> 
 
 </apex:form>
</apex:page>

 
  • April 11, 2017
  • Like
  • 1