• Keithlars
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 20
    Replies

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

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?

 

 

 

 

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; } */ } }}}

 

 

 

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(); } }

 

 

 

 

 

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';
}

 

 

 

 

 

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

 

Message Edited by mtbclimber on 01-24-2009 08:57 AM

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"

 

 

I'm trying to add multiple contacts to my Account_Plan__c custom object by using a custom list button on the Contact object.  I have this working with the code below however, I have the account_plan_id currently hardcoded.  How would I go about displaying a lookup field to user once they click my custom list button?

{!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();
}

I've followed the Chapter 9: Visualforce Pages and Data Sets example (p279) in Developer Guide, Advanced Programming Techniques for Cloud Computing and I'm trying to display contacts instead of Job Applicants in code below:

<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?
I'm merging the values from two multiselect picklist into a SET which I thought was suppose to prevent duplicate values from being added.  See code below.  However, after I run through the SET and update my variable the same value appears twice.  Am I missing something?

// 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;

I'm trying to copy the values from one multiselect picklist to another on the lead object and I get and error that the record is read only, yet I can update the record on the form. What am I doing wrong?

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;
     } 
 }
I have two multiselect picklist for area of interest, one is being updated from outside of salesforce which I call my area_of_interest_landing__c field, the other is area_of_interest__c. 

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);
}
Does anyone know how to enable the API for an Org on a developer account.  I just created a new one and I'm getting an error from the force migration tool that the API is not enabled for my org.  I also noticed that there is no "Profiles" link under Manage Users.  Why would that be?

Keith Larsen
I can't seem to get going with the sample recruiting app used in Developer Guide - Advanced programming techniques for Cloud Computing.

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
Does anyone know where I can get the script files that are suppose to be in zip file used for the recruiting app referenced in the  Developer Guide - Advanced Programming Techniques for Cloud Computing.

Keith Larsen

I'm new to Apex so this is going to be my first crack at it.
I have two multi select picklist, one with current values and one with historical values.  I need to add any values from the current picklist to the historical picklist that aren't already there. 
I assume I need to write a trigger that will do this.  I can find examples on updating fields, but none dealing with multi select picklist.  Any sample code you can share would be greatly appreciated.
 
Keith

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

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?

 

 

 

 

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';
}

 

 

 

 

 

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

 

Message Edited by mtbclimber on 01-24-2009 08:57 AM

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"

 

 

I'm trying to add multiple contacts to my Account_Plan__c custom object by using a custom list button on the Contact object.  I have this working with the code below however, I have the account_plan_id currently hardcoded.  How would I go about displaying a lookup field to user once they click my custom list button?

{!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();
}

I've followed the Chapter 9: Visualforce Pages and Data Sets example (p279) in Developer Guide, Advanced Programming Techniques for Cloud Computing and I'm trying to display contacts instead of Job Applicants in code below:

<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?
I'm merging the values from two multiselect picklist into a SET which I thought was suppose to prevent duplicate values from being added.  See code below.  However, after I run through the SET and update my variable the same value appears twice.  Am I missing something?

// 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;

I'm trying to copy the values from one multiselect picklist to another on the lead object and I get and error that the record is read only, yet I can update the record on the form. What am I doing wrong?

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;
     } 
 }
I have two multiselect picklist for area of interest, one is being updated from outside of salesforce which I call my area_of_interest_landing__c field, the other is area_of_interest__c. 

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);
}
I can't seem to get going with the sample recruiting app used in Developer Guide - Advanced programming techniques for Cloud Computing.

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
Does anyone know where I can get the script files that are suppose to be in zip file used for the recruiting app referenced in the  Developer Guide - Advanced Programming Techniques for Cloud Computing.

Keith Larsen

I'm new to Apex so this is going to be my first crack at it.
I have two multi select picklist, one with current values and one with historical values.  I need to add any values from the current picklist to the historical picklist that aren't already there. 
I assume I need to write a trigger that will do this.  I can find examples on updating fields, but none dealing with multi select picklist.  Any sample code you can share would be greatly appreciated.
 
Keith