You need to sign in to do that
Don't have an account?
Vincent van Drunen Littel
sdf
I have a script here that I found and is almost perfect for what I need.. although when pressing the button "add competition" i need it to be added to a different object "Test Competitors" which is a related list shown in page of "Account" (related list).
Could anybody "tweak"/ adjust this script accordingly!?
Also I need this VF page to be popping up when clicking "new test competition" on the related list as picture below
If need anymore info please let me know.. I really appreciate the help!!
Thanks Vincent
Could anybody "tweak"/ adjust this script accordingly!?
Also I need this VF page to be popping up when clicking "new test competition" on the related list as picture below
If need anymore info please let me know.. I really appreciate the help!!
Thanks Vincent
All Answers
here is the script and controller.
When clicking the button "add competition" i would like it to create a new record in object "new test competition" which then is shown in the related list on Accounts.
The records shown on the page are already existing accounts but can be competition as well (if that makes sense)
thank you for your help!!
<apex:page controller="AccountSelectClassController" sidebar="false">
<script type="text/javascript">
function selectAllCheckboxes(obj,receivedInputID){
var inputCheckBox = document.getElementsByTagName("input");
for(var i=0; i<inputCheckBox.length; i++){
if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
inputCheckBox[i].checked = obj.checked;
}
}
}
</script>
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Add to Competition" action="{!processSelected}" rerender="table2"/>
</apex:pageBlockButtons>
<apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
<apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
</apex:facet>
<apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
</apex:column>
<apex:column value="{!accWrap.acc.Name}" />
<apex:column value="{!accWrap.acc.BillingState}" />
<apex:column value="{!accWrap.acc.Phone}" />
</apex:pageBlockTable>
<apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
<apex:column value="{!c.Name}" headerValue="Account Name"/>
<apex:column value="{!c.BillingState}" headerValue="Billing State"/>
<apex:column value="{!c.Phone}" headerValue="Phone"/>
</apex:pageBlockTable>
</apex:pageblockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class AccountSelectClassController {
//Our collection of the class/wrapper objects wrapAccount
public List<wrapAccount> wrapAccountList {get; set;}
public List<Account> selectedAccounts{get;set;}
public AccountSelectClassController(){
if(wrapAccountList == null) {
wrapAccountList = new List<wrapAccount>();
for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 50]) {
// As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
wrapAccountList.add(new wrapAccount(a));
}
}
}
public void processSelected() {
selectedAccounts = new List<Account>();
for(wrapAccount wrapAccountObj : wrapAccountList) {
if(wrapAccountObj.selected == true) {
selectedAccounts.add(wrapAccountObj.acc);
}
}
}
Amazing dedication to a problem that has nothing to do with him!
You dont know how thankful I am for the help... this man deserves a reward!