-
ChatterFeed
-
1Best Answers
-
0Likes Received
-
0Likes Given
-
16Questions
-
20Replies
sforce connector error
When I try to do anything in the sforce connector add-in I get the error message:
sforce_connect11.xls cannot be found.
Does anyone know what's going on here?
Keith
- Keithlars
- February 18, 2009
- Like
- 0
- Continue reading or reply
Landing on correct Tab when using custom list button to add multiple contacts to a custom object
I the post for adding multiple contacts to a custom object from a list button:
http://forums.sforce.com/sforce/board/message?board.id=Visualforce&thread.id=8881
I am brought to the detail Tab in my custom object after the records are added.
Since I'm using Tabs for my related list I would like to bring the user to the Tab where we just
added the records.
Here is the page for displaying the related list tabs:
<apex:page standardController="Account_Plan__c" showHeader="true" tabStyle="Account_Plan__c" >
<apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
<apex:tab label="Details" name="AcctPlanDetails" id="tabdetails">
<apex:detail relatedList="false" relatedListHover="false" title="true"/>
</apex:tab>
<apex:tab label="Account Team" name="accountTeam" id="tabAT">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDpzMAG" />
</apex:tab>
<apex:tab label="Org Contacts" name="orgContacts" id="tabOC">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDpaMAG" />
</apex:tab>
<apex:tab label="Competitive Business" name="competitiveBusiness" id="tabCB">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDp2MAG" />
</apex:tab>
<apex:tab label="New Demand" name="newDemand" id="tabND">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDpGMAW" />
</apex:tab>
<apex:tab label="Strategic Messaging" name="strategicMessaging" id="tabSM">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QFn8MAG" />
</apex:tab>
<apex:tab label="Substantiation Plans" name="substantiationPlans" id="tabSP">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QFmaMAG" />
</apex:tab>
<apex:tab label="Strategic Goals" name="strategicGoals" id="tabSG">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDxPMAW" />
</apex:tab>
<apex:tab label="Objectives Tactics" name="objectivesTactics" id="tabOT">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QFjQMAW" />
</apex:tab>
<apex:tab label="Competitive Analysis" name="competitiveAnalysis" id="tabCA">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDzBMAW" />
</apex:tab>
<apex:tab label="Opp Plans" name="oppPlans" id="tabOP">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QS3cMAG" />
</apex:tab>
<apex:tab label="Open Activities" name="openActivities" id="tabOA">
<apex:relatedList subject="{!Account_Plan__c}" list="OpenActivities" />
</apex:tab>
<apex:tab label="Activity History" name="activityHistory" id="tabAH">
<apex:relatedList subject="{!Account_Plan__c}" list="ActivityHistories" />
</apex:tab>
<apex:tab label="Notest and Attachments" name="notesAttachments" id="tabNotes">
<apex:relatedList subject="{!Account_Plan__c}" list="NotesAndAttachments" />
</apex:tab>
</apex:tabPanel>
</apex:page>
Here is the code that adds the records to the related list on my custom object and then brings me to the detail tab in the try catch block:
public class contactSetExt {
List<Contact> contacts;
public contactSetExt(ApexPages.StandardSetController controller) {
contacts = (List<Contact>) controller.getSelected();
}
public Id planId { get; set; }
public List<ApexPages.SelectOption> getPlanOptions() {
List<ApexPages.SelectOption> options = new List<ApexPages.SelectOption>();
options.add(new ApexPages.SelectOption('','--SELECT--'));
for(Account_Plan__c p:[select name from account_plan__c order by name asc]) {
options.add(new ApexPages.SelectOption(p.id, p.name));
}
return options;
}
public PageReference createMembers() {
/* see if there are existing members for this plan */
Set<Id> existingMemberContactIds = new Set<Id>{};
for(Account_Team_Members__c m:[select id, contactid__c from account_team_members__c where account_plan_id__c = :planId and contactid__c in :contacts]) {
existingMemberContactIds.add(m.contactid__c);
}
List<Account_Team_Members__c> newMembers = new List<Account_Team_Members__c>();
for(Contact c:contacts) {
if(!existingMemberContactIds.contains(c.id)) {
newMembers.add(new Account_Team_Members__c(account_plan_id__c = planId, contactid__c = c.id));
}
}
PageReference p;
if(newMembers.size() > 0) {
try {
Database.insert(newMembers);
p = new ApexPages.StandardController(new Account_Plan__c(id = planId)).view();
} catch (System.DMLException e) {
ApexPages.addMessages(e);
}
}
return p;
}
}
So how would I bring the user to the tab id "tabAT" instead of the detail tab?
- Keithlars
- February 03, 2009
- Like
- 0
- Continue reading or reply
Too many SOQL queries: 21
Every once in a while I get the following error from my trigger:
Apex script unhandled trigger exception by user/organization: 00530000000fJTi/00D300000000beQ
Contact_Area_of_Interest: execution of BeforeUpdate
caused by: System.Exception: Too many SOQL queries: 21
Trigger.Contact_Area_of_Interest: line 18, column 9
Can anyone see where my problem is in the code below.
Thanks.
trigger Lead_Area_of_Interest on Lead(before insert, before update, after insert, after update) { String aoiValue = ''; // Set up list to hold unique IDs of all new or updated leads Set<Id> leadIds = New Set<Id>(); // Set up list to hold unique area of interests Set<String> interests = new Set<String>(); // Iterate through array of new or updated records for (Lead a : trigger.new){ //if (a.area_of_interest_landing__c != null && a.area_of_interest_landing__c != '') leadIds.add(a.id); } // Map the area of interest field values to ID Map<ID, Lead> aoi = new Map<Id, Lead>( [select area_of_interest__c, area_of_interest_landing__c from Lead where ID in : leadIds]); if (Trigger.isBefore) { if (Trigger.isDelete) { // In a before delete trigger, the trigger accesses the records that will be // deleted with the Trigger.old list. for (Lead a : Trigger.old) { if (a.firstname == 'delete') { a.addError('You cannot delete this record!'); } } } else { // In before insert or before update triggers, the trigger accesses the new records // with the Trigger.new list. for (Lead a : Trigger.new) { if (a.firstname == 'bad') a.firstname.addError('Bad name'); if (a.area_of_interest_landing__c != null && a.area_of_interest_landing__c != '') { if (a.area_of_interest__c != null && a.area_of_interest__c != '') { // if here then we have to merge both area of interest fields // Add all values from both fields into Set array which ensures uniqueness for (Lead aoiLanding : trigger.new) { String[] result1 = a.area_of_interest_landing__c.split(';'); for (String x : result1) { interests.add(x); } String[] result2 = a.area_of_interest__c.split(';'); for (String y : result2) { interests.add(y); } } // Populate variable to be used in update Integer i = 0; for (String s : interests) { if (i == 0) aoiValue = s; else aoiValue = aoiValue + ';' + s; i++; } try { a.area_of_interest__c = aoiValue; } catch (DmlException de) { for (Integer e = 0; E < de.getNumDml(); e++) { //NC a.area_of_interest__c.addError(de.getDmlMessage(e)); //NC } } } else { // area_of_interest__c is null and no record in aoi map so just copy values a.area_of_interest__c = a.area_of_interest_landing__c; } } else { // no exising values so just copy landing field values if not null TEST5 if (a.area_of_interest_landing__c != null && a.area_of_interest_landing__c != '') { // try { a.area_of_interest__c = aoi.get(a.id).area_of_interest_landing__c; //NC // } // catch (DmlException de) { // for (Integer e = 0; E < de.getNumDml(); e++) { //NC // a.area_of_interest__c.addError(de.getDmlMessage(e)); //NC // } // } } } } if (Trigger.isInsert) { // area_of_interest__c is null and no record in aoi map so just copy values for (Lead a : Trigger.new) { if (a.area_of_interest_landing__c != null && a.area_of_interest_landing__c != '') { // try { a.area_of_interest__c = a.area_of_interest_landing__c; // } // catch (DmlException de) { // for (Integer e = 0; E < de.getNumDml(); e++) { //NC // a.area_of_interest__c.addError(de.getDmlMessage(e)); //NC // } // } } } // If the trigger is not a before trigger, it must be an after trigger. } else { /* if (Trigger.isInsert) { List<Contact> contacts = new Contact[0]; for (Lead a : Trigger.new) { if(a.lastname == 'makeContact') { contacts.add(new Contact (firstname = a.firstname, lastname = a.lastname, accountId = a.id)); } } insert contacts; } */ } }}}
- Keithlars
- January 29, 2009
- Like
- 0
- Continue reading or reply
How to execute javascript from the onclick of a button
I have a VS page (below) that is populated with the contacts I've selected after clicking a custom button from a contact view.
On this page I have a lookup field to a custom object and I want to grap the value of this field and pass it to a javascript funtion (see below) when the user clicks the Next button on the form.
I currently, have the javascript in a custom button on the contact object so I need to figure out where to put it and how to call it.
Thanks.
<apex:page standardController="Contact" extensions="contactExtension" recordSetVar="Contacts"> <!-- Do I add it as a static resource like below? If so,how do I call the function inside? -->
<script type="text/javascript" src="{!$Resource.addToOrgContact}"></script>
<apex:form > <apex:pageBlock id="thePageBlock"> <apex:pagemessages /> <apex:pageBlockSection title="Select Account Plan" id="accountPlan" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Account Plan" for="ap"/> <apex:panelGrid columns="2"> <apex:outputText value="{!Contact.Account_Plan__c}" rendered="false"/> <apex:selectList id="ap" value="{!accountPlanID}" size="1" > <apex:selectOptions value="{!AccountPlanOptions}"/> </apex:selectList> </apex:panelGrid> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Selected Contacts"> <apex:pageBlockTable value="{!selected}" var="c" columnsWidth="300px, 300px, 100px"> <apex:column value="{!c.ID}" rendered="false" ></apex:column> <apex:column value="{!c.Firstname} {!c.Lastname}" headerValue="Name" ></apex:column> <apex:column value="{!c.Title}" headerValue="Title"></apex:column> <apex:column value="{!c.Region_Id__c}" headerValue="Region"></apex:column> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockButtons location="both">
<!-- <apex:commandButton value="Next" action="{!addToOrgContact}"> <apex:param name="acctPlanID" value="{!this.acctPlanID}"/> </apex:commandButton>-->
<apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Javascript:
function addToOrgContact (acctPlanId) { {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} var records= {!GETRECORDIDS($ObjectType.Contact)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one record") } else { for (var n=0; n<records.length; n++) { var c = new sforce.SObject("Org_Contact_Analysis__c"); c.ContactID__c = records[n]; c.Account_Plan_ID__c = acctPlanId"; newRecords.push(c); } var errors = []; var result = sforce.connection.create(newRecords); if (result && result.length){ var numFailed = 0; var numSucceeded = 0; for (var i = 0; i < result.length; i++){ var res = result[i]; if (res && res.success == 'true'){ numSucceeded++; } else { var es = res.getArray("errors"); if (es.length > 0) { errors.push(es[0].message); } numFailed++; } } if (numFailed > 0){ alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n")); } else { alert("Number of records added: " + numSucceeded); } } window.location.reload(); } }
- Keithlars
- January 27, 2009
- Like
- 0
- Continue reading or reply
Navigation problem in Tabbed Accounts in 30 seconds
I created tabs following the Tabbed Accounts in 30 seconds post and my problem is that whenever I perform an action on any tab other than the detail tab I'm returned to the detail tab after the action is completed instead of returning to the tab I was on.
I tried to find code samples that my lead me to an answer and I thought maybe I had to create an standard controller extension which I attached below. However, I'm very green at this so I don't really know how to continue so any direction and sample code would be greatly appreciated. I'm sure I'm not the only one who has implemented this cool technique and has run into this problem.
Keith
VS Page:
<apex:page standardController="Account" extensions="accountExt" id="p"
showHeader="true" tabStyle="account" >
<apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts__r" id="tabContact">
<apex:relatedList subject="{!account}" list="contacts__r" />
</apex:tab>
<apex:tab label="Invoices" name="Invoices" id="tabInvoice">
<apex:relatedList subject="{!account}" list="invoices__r" />
</apex:tab>
<apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
<apex:relatedList subject="{!account}" list="OpenActivities" />
</apex:tab>
<apex:tab label="Products Offered" name="ProductsOffered" id="tabProdOffer">
<apex:relatedList subject="{!account}" list="Products_Offered__r" />
</apex:tab>
<apex:tab label="Products Sold" name="ProductsSold" id="tabProdSold">
<apex:relatedList subject="{!account}" list="Product_Releases__r" />
</apex:tab>
</apex:tabPanel>
</apex:page>
Controller:
public class accountExt {
String aId;
String pId;
public accountExt(ApexPages.StandardController controller) {
aId = ApexPages.currentPage().getParameters().get('aId');
pId = ApexPages.currentPage().getParameters().get('pId');
}
public PageReference redirect(){
PageReference pageRef = new PageReference('/'+pId);
pageRef.setRedirect(true);
return pageRef;
}
public void setState(String n) {
state = n;
}
public String getState() {
return state;
}
public PageReference methodOne() {
return null;
}
private String state = 'no';
}
- Keithlars
- January 27, 2009
- Like
- 0
- Continue reading or reply
similar vs page works with standard object but not custom object
The first vs page using opportunity work fine when access page via list view button.
The second vs page using a custom object doesn't. Why not?
<apex:page standardController="Org_Contact_Analysis__c" recordSetVar="Org_Contacts"
tabStyle="Org_Contact_Analysis__c" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pagemessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Org_Contact_Analysis__c}" var="c">
<apex:column value="{!c.ContactID__c}"/>
<apex:column headerValue="Title">
<apex:inputField value="{!Org_Contact_Analysis__c.Title__c}"/>
</apex:column>
<apex:column headerValue="Local Owner">
<apex:inputField value="{!Org_Contact_Analysis__c.Local_Owner_ID__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="Opportunity" recordSetVar="opportunities"
tabStyle="Opportunity" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!opportunities}" var="opp">
<apex:column value="{!opp.name}"/>
<apex:column headerValue="Stage">
<apex:inputField value="{!opp.stageName}"/>
</apex:column>
<apex:column headerValue="Close Date">
<apex:inputField value="{!opp.closeDate}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
mtbclimber: Moved code into SRC Blocks
- Keithlars
- January 24, 2009
- Like
- 0
- Continue reading or reply
Cannot overwrite column title in pageBlockTable
Why doesn't the code below overwrite the column header.
<apex:column value="{!c.Firstname}" title="Name"></apex:column>
"First Name" is being displayed instead of "Name"
- Keithlars
- January 23, 2009
- Like
- 0
- Continue reading or reply
Using custom list button to add multiple contacts to a custom object
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var records= {!GETRECORDIDS($ObjectType.Contact)};
var newRecords = [];
if (records[0] == null) {
alert("Please select at least one record")
}
else {
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Account_Team_Members__c");
c.ContactID__c = records[n];
c.Account_Plan_ID__c = "a0YR0000000F5ls";
newRecords.push(c);
}
var errors = [];
var result = sforce.connection.create(newRecords);
if (result && result.length){
var numFailed = 0;
var numSucceeded = 0;
for (var i = 0; i < result.length; i++){
var res = result[i];
if (res && res.success == 'true'){
numSucceeded++;
}
else {
var es = res.getArray("errors");
if (es.length > 0) {
errors.push(es[0].message);
}
numFailed++;
}
}
if (numFailed > 0){
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n"));
}
else {
alert("Number of records added: " + numSucceeded);
}
}
window.location.reload();
}
- Keithlars
- January 17, 2009
- Like
- 0
- Continue reading or reply
Simple Visualforce page doesn't display data
<apex:page standardController="Contact"
recordSetVar="Contacts" tabstyle="Contact">
<apex:pageBlock id="thePageBlock">
<apex:pageblocktable value="{!Contact}" var="AC" id="acTable">
<apex:column value="{!AC.firstName}"/>
<apex:column value="{!AC.Department}"/>
<apex:column value="{!AC.Title}"/>
<apex:column headerValue="Country" value="{!AC.MailingCountry}"/>
<apex:column value="{!AC.Account}"/>
</apex:pageblocktable>
</apex:pageBlock>
</apex:page>
However, no records are being displayed. I've completed the example which show me the record set so I know there is data, its just not being displayed. I strip out all that extra code to make it simple for debugging. Anyone know what I'm doing wrong?
- Keithlars
- January 08, 2009
- Like
- 0
- Continue reading or reply
Duplicate values being added to SET
// Set up list to hold unique area of interests
Set<String> interests = new Set<String>();
...
for (Lead aoiLanding : trigger.new) {
interests.add(a.area_of_interest_landing__c);
interests.add(a.area_of_interest__c);
}
// Populate variable to be used in update
Integer i = 0;
for (String s : interests) {
if (i == 0)
aoiValue = s;
else
aoiValue = aoiValue + ';' + s;
i++;
}
a.area_of_interest__c = aoiValue;
- Keithlars
- November 19, 2008
- Like
- 0
- Continue reading or reply
Trigger error that record is read only
Record is read-only: Trigger.Area_of_Interest: line 21, column 9 which is this line:
a.area_of_interest__c = entries.get(a.id).area_of_interest_landing__c;
trigger Area_of_Interest on Lead (after update) {
// Set up list to hold unique IDs of all new or updated leads
Set<Id> leadIds = New Set<Id>();
// Set up list to hold unique area of interests
Set<String> interests = new Set<String>();
// Iterate through array of new or updated records
for (Lead a : trigger.new){
if (a.area_of_interest_landing__c != '')
leadIds.add(a.id);
}
// Map the area of interest field values to ID
Map<ID, Lead> entries = new Map<Id, Lead>(
[select area_of_interest_landing__c, area_of_interest__c from Lead where ID in : leadIds]);
for (Lead a : trigger.new){
a.area_of_interest__c = entries.get(a.id).area_of_interest_landing__c;
update a;
}
}
- Keithlars
- November 18, 2008
- Like
- 0
- Continue reading or reply
Merging values from 2 multiselect picklist in a trigger
The area_of_interest_landing__c field may or may not have all the value selected that the area_of_interest__c field has. I need to keep a complete set of values being selected over time in the area_of_interest__c field. My thought was to create a trigger that would update the area_of_interest__c field whenever the area_of_interest_landing__c field is updated. This is my first trigger and I haven't seen any examples of updating multiselect picklist so I'm kind of struggling here so I would like to know if I'm on the right track with the code below. Currently, I get a complie error on invalid type of "String".
trigger area_of_interest on Lead (after insert, after update){
Set<String> interests = new Set<String>();
for (area_of_interest_landing__c aoiLanding : trigger.new)
interests.add(aoiLanding.area_of_interest_landing__c);
for (area_of_interest__c aoi : trigger.new)
interests.add(aoi.area_of_interest__c);
for (area_of_interest__c aoi : trigger.new)
aoi.area_of_interest__c = entries.get(aoi.area_of_interest__c);
}
- Keithlars
- November 17, 2008
- Like
- 0
- Continue reading or reply
Profiles link not available under Admin Setup in new developer account
Keith Larsen
- Keithlars
- November 14, 2008
- Like
- 0
- Continue reading or reply
Trouble working with documentation for sample Recruiting app
The book says to search for the name of this book in http://developer.force.com/codeshare to get instructions on how to load metadata required, however there is no project there matching this name. The project "Developer's Guide to the Force.com Platform look like its what should be used. When you follow the instructions for loading the metadata using Ant InitUsers, it fails because there is no application called force_com, so I created it and tried again, however, then I get the error that there is no customer tab named Start_Here.
Does anyone know where to find the instructions for making this all work.
This is extremely frustrating to say the least.
Keith Larsen
- Keithlars
- November 14, 2008
- Like
- 0
- Continue reading or reply
Script files not in zip file for Advanced Programming Techniques for Cloud Computiong
Keith Larsen
- Keithlars
- November 12, 2008
- Like
- 0
- Continue reading or reply
Appending values to multi select picklist
- Keithlars
- November 06, 2008
- Like
- 0
- Continue reading or reply
sforce connector error
When I try to do anything in the sforce connector add-in I get the error message:
sforce_connect11.xls cannot be found.
Does anyone know what's going on here?
Keith
- Keithlars
- February 18, 2009
- Like
- 0
- Continue reading or reply
Landing on correct Tab when using custom list button to add multiple contacts to a custom object
I the post for adding multiple contacts to a custom object from a list button:
http://forums.sforce.com/sforce/board/message?board.id=Visualforce&thread.id=8881
I am brought to the detail Tab in my custom object after the records are added.
Since I'm using Tabs for my related list I would like to bring the user to the Tab where we just
added the records.
Here is the page for displaying the related list tabs:
<apex:page standardController="Account_Plan__c" showHeader="true" tabStyle="Account_Plan__c" >
<apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
<apex:tab label="Details" name="AcctPlanDetails" id="tabdetails">
<apex:detail relatedList="false" relatedListHover="false" title="true"/>
</apex:tab>
<apex:tab label="Account Team" name="accountTeam" id="tabAT">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDpzMAG" />
</apex:tab>
<apex:tab label="Org Contacts" name="orgContacts" id="tabOC">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDpaMAG" />
</apex:tab>
<apex:tab label="Competitive Business" name="competitiveBusiness" id="tabCB">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDp2MAG" />
</apex:tab>
<apex:tab label="New Demand" name="newDemand" id="tabND">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDpGMAW" />
</apex:tab>
<apex:tab label="Strategic Messaging" name="strategicMessaging" id="tabSM">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QFn8MAG" />
</apex:tab>
<apex:tab label="Substantiation Plans" name="substantiationPlans" id="tabSP">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QFmaMAG" />
</apex:tab>
<apex:tab label="Strategic Goals" name="strategicGoals" id="tabSG">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDxPMAW" />
</apex:tab>
<apex:tab label="Objectives Tactics" name="objectivesTactics" id="tabOT">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QFjQMAW" />
</apex:tab>
<apex:tab label="Competitive Analysis" name="competitiveAnalysis" id="tabCA">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QDzBMAW" />
</apex:tab>
<apex:tab label="Opp Plans" name="oppPlans" id="tabOP">
<apex:relatedList subject="{!Account_Plan__c}" list="R00NR0000000QS3cMAG" />
</apex:tab>
<apex:tab label="Open Activities" name="openActivities" id="tabOA">
<apex:relatedList subject="{!Account_Plan__c}" list="OpenActivities" />
</apex:tab>
<apex:tab label="Activity History" name="activityHistory" id="tabAH">
<apex:relatedList subject="{!Account_Plan__c}" list="ActivityHistories" />
</apex:tab>
<apex:tab label="Notest and Attachments" name="notesAttachments" id="tabNotes">
<apex:relatedList subject="{!Account_Plan__c}" list="NotesAndAttachments" />
</apex:tab>
</apex:tabPanel>
</apex:page>
Here is the code that adds the records to the related list on my custom object and then brings me to the detail tab in the try catch block:
public class contactSetExt {
List<Contact> contacts;
public contactSetExt(ApexPages.StandardSetController controller) {
contacts = (List<Contact>) controller.getSelected();
}
public Id planId { get; set; }
public List<ApexPages.SelectOption> getPlanOptions() {
List<ApexPages.SelectOption> options = new List<ApexPages.SelectOption>();
options.add(new ApexPages.SelectOption('','--SELECT--'));
for(Account_Plan__c p:[select name from account_plan__c order by name asc]) {
options.add(new ApexPages.SelectOption(p.id, p.name));
}
return options;
}
public PageReference createMembers() {
/* see if there are existing members for this plan */
Set<Id> existingMemberContactIds = new Set<Id>{};
for(Account_Team_Members__c m:[select id, contactid__c from account_team_members__c where account_plan_id__c = :planId and contactid__c in :contacts]) {
existingMemberContactIds.add(m.contactid__c);
}
List<Account_Team_Members__c> newMembers = new List<Account_Team_Members__c>();
for(Contact c:contacts) {
if(!existingMemberContactIds.contains(c.id)) {
newMembers.add(new Account_Team_Members__c(account_plan_id__c = planId, contactid__c = c.id));
}
}
PageReference p;
if(newMembers.size() > 0) {
try {
Database.insert(newMembers);
p = new ApexPages.StandardController(new Account_Plan__c(id = planId)).view();
} catch (System.DMLException e) {
ApexPages.addMessages(e);
}
}
return p;
}
}
So how would I bring the user to the tab id "tabAT" instead of the detail tab?
- Keithlars
- February 03, 2009
- Like
- 0
- Continue reading or reply
Navigation problem in Tabbed Accounts in 30 seconds
I created tabs following the Tabbed Accounts in 30 seconds post and my problem is that whenever I perform an action on any tab other than the detail tab I'm returned to the detail tab after the action is completed instead of returning to the tab I was on.
I tried to find code samples that my lead me to an answer and I thought maybe I had to create an standard controller extension which I attached below. However, I'm very green at this so I don't really know how to continue so any direction and sample code would be greatly appreciated. I'm sure I'm not the only one who has implemented this cool technique and has run into this problem.
Keith
VS Page:
<apex:page standardController="Account" extensions="accountExt" id="p"
showHeader="true" tabStyle="account" >
<apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts__r" id="tabContact">
<apex:relatedList subject="{!account}" list="contacts__r" />
</apex:tab>
<apex:tab label="Invoices" name="Invoices" id="tabInvoice">
<apex:relatedList subject="{!account}" list="invoices__r" />
</apex:tab>
<apex:tab label="Open Activities" name="OpenActivities" id="tabOpenAct">
<apex:relatedList subject="{!account}" list="OpenActivities" />
</apex:tab>
<apex:tab label="Products Offered" name="ProductsOffered" id="tabProdOffer">
<apex:relatedList subject="{!account}" list="Products_Offered__r" />
</apex:tab>
<apex:tab label="Products Sold" name="ProductsSold" id="tabProdSold">
<apex:relatedList subject="{!account}" list="Product_Releases__r" />
</apex:tab>
</apex:tabPanel>
</apex:page>
Controller:
public class accountExt {
String aId;
String pId;
public accountExt(ApexPages.StandardController controller) {
aId = ApexPages.currentPage().getParameters().get('aId');
pId = ApexPages.currentPage().getParameters().get('pId');
}
public PageReference redirect(){
PageReference pageRef = new PageReference('/'+pId);
pageRef.setRedirect(true);
return pageRef;
}
public void setState(String n) {
state = n;
}
public String getState() {
return state;
}
public PageReference methodOne() {
return null;
}
private String state = 'no';
}
- Keithlars
- January 27, 2009
- Like
- 0
- Continue reading or reply
similar vs page works with standard object but not custom object
The first vs page using opportunity work fine when access page via list view button.
The second vs page using a custom object doesn't. Why not?
<apex:page standardController="Org_Contact_Analysis__c" recordSetVar="Org_Contacts"
tabStyle="Org_Contact_Analysis__c" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pagemessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Org_Contact_Analysis__c}" var="c">
<apex:column value="{!c.ContactID__c}"/>
<apex:column headerValue="Title">
<apex:inputField value="{!Org_Contact_Analysis__c.Title__c}"/>
</apex:column>
<apex:column headerValue="Local Owner">
<apex:inputField value="{!Org_Contact_Analysis__c.Local_Owner_ID__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="Opportunity" recordSetVar="opportunities"
tabStyle="Opportunity" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!opportunities}" var="opp">
<apex:column value="{!opp.name}"/>
<apex:column headerValue="Stage">
<apex:inputField value="{!opp.stageName}"/>
</apex:column>
<apex:column headerValue="Close Date">
<apex:inputField value="{!opp.closeDate}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
mtbclimber: Moved code into SRC Blocks
- Keithlars
- January 24, 2009
- Like
- 0
- Continue reading or reply
Cannot overwrite column title in pageBlockTable
Why doesn't the code below overwrite the column header.
<apex:column value="{!c.Firstname}" title="Name"></apex:column>
"First Name" is being displayed instead of "Name"
- Keithlars
- January 23, 2009
- Like
- 0
- Continue reading or reply
Using custom list button to add multiple contacts to a custom object
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var records= {!GETRECORDIDS($ObjectType.Contact)};
var newRecords = [];
if (records[0] == null) {
alert("Please select at least one record")
}
else {
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("Account_Team_Members__c");
c.ContactID__c = records[n];
c.Account_Plan_ID__c = "a0YR0000000F5ls";
newRecords.push(c);
}
var errors = [];
var result = sforce.connection.create(newRecords);
if (result && result.length){
var numFailed = 0;
var numSucceeded = 0;
for (var i = 0; i < result.length; i++){
var res = result[i];
if (res && res.success == 'true'){
numSucceeded++;
}
else {
var es = res.getArray("errors");
if (es.length > 0) {
errors.push(es[0].message);
}
numFailed++;
}
}
if (numFailed > 0){
alert("Failed: " + numFailed + "\nSucceeded: " + numSucceeded + " \n Due to: " + errors.join("\n"));
}
else {
alert("Number of records added: " + numSucceeded);
}
}
window.location.reload();
}
- Keithlars
- January 17, 2009
- Like
- 0
- Continue reading or reply
Simple Visualforce page doesn't display data
<apex:page standardController="Contact"
recordSetVar="Contacts" tabstyle="Contact">
<apex:pageBlock id="thePageBlock">
<apex:pageblocktable value="{!Contact}" var="AC" id="acTable">
<apex:column value="{!AC.firstName}"/>
<apex:column value="{!AC.Department}"/>
<apex:column value="{!AC.Title}"/>
<apex:column headerValue="Country" value="{!AC.MailingCountry}"/>
<apex:column value="{!AC.Account}"/>
</apex:pageblocktable>
</apex:pageBlock>
</apex:page>
However, no records are being displayed. I've completed the example which show me the record set so I know there is data, its just not being displayed. I strip out all that extra code to make it simple for debugging. Anyone know what I'm doing wrong?
- Keithlars
- January 08, 2009
- Like
- 0
- Continue reading or reply
Duplicate values being added to SET
// Set up list to hold unique area of interests
Set<String> interests = new Set<String>();
...
for (Lead aoiLanding : trigger.new) {
interests.add(a.area_of_interest_landing__c);
interests.add(a.area_of_interest__c);
}
// Populate variable to be used in update
Integer i = 0;
for (String s : interests) {
if (i == 0)
aoiValue = s;
else
aoiValue = aoiValue + ';' + s;
i++;
}
a.area_of_interest__c = aoiValue;
- Keithlars
- November 19, 2008
- Like
- 0
- Continue reading or reply
Trigger error that record is read only
Record is read-only: Trigger.Area_of_Interest: line 21, column 9 which is this line:
a.area_of_interest__c = entries.get(a.id).area_of_interest_landing__c;
trigger Area_of_Interest on Lead (after update) {
// Set up list to hold unique IDs of all new or updated leads
Set<Id> leadIds = New Set<Id>();
// Set up list to hold unique area of interests
Set<String> interests = new Set<String>();
// Iterate through array of new or updated records
for (Lead a : trigger.new){
if (a.area_of_interest_landing__c != '')
leadIds.add(a.id);
}
// Map the area of interest field values to ID
Map<ID, Lead> entries = new Map<Id, Lead>(
[select area_of_interest_landing__c, area_of_interest__c from Lead where ID in : leadIds]);
for (Lead a : trigger.new){
a.area_of_interest__c = entries.get(a.id).area_of_interest_landing__c;
update a;
}
}
- Keithlars
- November 18, 2008
- Like
- 0
- Continue reading or reply
Merging values from 2 multiselect picklist in a trigger
The area_of_interest_landing__c field may or may not have all the value selected that the area_of_interest__c field has. I need to keep a complete set of values being selected over time in the area_of_interest__c field. My thought was to create a trigger that would update the area_of_interest__c field whenever the area_of_interest_landing__c field is updated. This is my first trigger and I haven't seen any examples of updating multiselect picklist so I'm kind of struggling here so I would like to know if I'm on the right track with the code below. Currently, I get a complie error on invalid type of "String".
trigger area_of_interest on Lead (after insert, after update){
Set<String> interests = new Set<String>();
for (area_of_interest_landing__c aoiLanding : trigger.new)
interests.add(aoiLanding.area_of_interest_landing__c);
for (area_of_interest__c aoi : trigger.new)
interests.add(aoi.area_of_interest__c);
for (area_of_interest__c aoi : trigger.new)
aoi.area_of_interest__c = entries.get(aoi.area_of_interest__c);
}
- Keithlars
- November 17, 2008
- Like
- 0
- Continue reading or reply
Trouble working with documentation for sample Recruiting app
The book says to search for the name of this book in http://developer.force.com/codeshare to get instructions on how to load metadata required, however there is no project there matching this name. The project "Developer's Guide to the Force.com Platform look like its what should be used. When you follow the instructions for loading the metadata using Ant InitUsers, it fails because there is no application called force_com, so I created it and tried again, however, then I get the error that there is no customer tab named Start_Here.
Does anyone know where to find the instructions for making this all work.
This is extremely frustrating to say the least.
Keith Larsen
- Keithlars
- November 14, 2008
- Like
- 0
- Continue reading or reply
Script files not in zip file for Advanced Programming Techniques for Cloud Computiong
Keith Larsen
- Keithlars
- November 12, 2008
- Like
- 0
- Continue reading or reply
Appending values to multi select picklist
- Keithlars
- November 06, 2008
- Like
- 0
- Continue reading or reply