• kevinedelmann
  • NEWBIE
  • 75 Points
  • Member since 2006

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 53
    Replies
Hello,

I have been trying to get a field on a Visualforce page (the Account ID - a custom field which is a standard lookup) to pre-populate from a query parameter in the url. It does *not* work.

The general use case is that we have a related list on the Account Page for a custom object called Checklist. When we use the standard New button to create a new record, the Account ID is pre-populated on the page since the ID and name are passed in as query parameters.

We had to create a small Visualforce page instead of using the standard page, and overrode the New button. Now when you select New, the page loads without the Account ID pre-populated even though the ID and name are still in the url as query parameters. I took some JavaScript code to pull out those values and have been trying for the past day to figure out how to pass them to the standard controller so it recognizes the Account. The point here is that the end user should not have to re-select the Account from a lookup field when they just came from the Account page.

Since you can't simply View Source on a Visualforce page to see what the field name "{!Checklist__c.Checklist_Template__c}" resolves to (it's just escaped yet not interpreted at that point) I was forced to use a program to view the post request. It would appear that the <apex:inputfield> tag when referring to a lookup actually generates 6 input fields for it.

So... I used those 6 fields, populated them exactly as the lookup field would populate them, and still no luck.
Here is the code:
Code:
<apex:page standardcontroller="Checklist__c" tabstyle="Checklist__c">

  <apex:sectionHeader title="Checklist" subtitle="Create Checklist"/>
  <apex:form id="form1">
    <apex:pageBlock >
  <apex:pageBlockButtons location="top" >
   <apex:commandButton action="{!save}" onclick=" gup();" value="Save" />
  </apex:pageBlockButtons>
  <apex:pageBlockSection >
   <apex:pageBlockSectionItem >
    <apex:outputLabel value="Checklist Template" />
    <apex:inputField value="{!Checklist__c.Checklist_Template__c}" required="true" /> 
   </apex:pageBlockSectionItem>
     </apex:pageBlockSection> 
    </apex:pageBlock>
  
<!-- Here are the 6 fields that are generated by the lookup field -->
  <input type="text" id="AccountID_lkid" name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lkid"  />
  <input type="text" id="AccountID_lkold" name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lkold"  />
  <input type="text"  name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lspf" value="0"  />
  <input type="text"  name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_mod" value="0"  />
  <input type="text"  name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lktp" value="001"  />
  <input type="text" id="AccountID" name="j_id0:form1:j_id2:j_id5:j_id6:AccountID"  />
  
<!-- Here is the code to pull the Account ID and Name out of the url. This definitely works -->
<script type="text/javascript">

   var regexS = "[\\—&]CF00NS0000000M2Je_lkid=([^&#]*)";
   var regex = new RegExp( regexS );
   var results = regex.exec( window.location.href );
   document.getElementById('AccountID_lkid').value = results[1];
 
 var regexS2 = "[\\–&]CF00NS0000000M2Je=([^&#]*)";
   var regex2 = new RegExp( regexS2 );
   var results2 = regex2.exec( window.location.href );
   document.getElementById('AccountID').value = results2[1];
   document.getElementById('AccountID_lkold').value = results2[1];
  </script>
  </apex:form>
</apex:page>

 
Now I realize I can override the Standard controller and just grab the ID out of the request and it would work just fine, but I really want to understand why this does not work with just the standard controller. This is a pretty big loss of functionality when the page used to pre-populate with the Account ID and then when you write a Visualforce page it no longer does.

Thanks,
Sara
  • October 13, 2008
  • Like
  • 0
Hi everyone,

I am attempting to use the Excel Connector to import a bunch of cases.  The connector appears to support "Contact ID" as a field for cases, but not "Account ID."  All of the cases I am importing need to be associated with specific accounts...  any ideas?

Thanks.

How do you show SUM aggregate values in a VF page.

 

First off I am not a full time programmer but can copy/modify code that I find online. The business case I have is that I need to show summary information from a custom object that is not related on an account using the external id of the account.  I.e. # of subscribers, total premiums, and the number of accounts.

 

I think I got the SOQL query correct but I cannot seem to get the information in a proper format to show up on my visualforce page.  I managed to do when I use COUNT but I cannot seem to get it to work correctly when I use SUM.

 

Also, I am using the standard Account Controller with an Extension.

 

Below is my Class & VF Page.

 

Thanks in advance for any and all help.


Kevin

 

CLASS

 

public class Agency_Client_Info
{
/*DECLARE VARIABLES */
public final Account acct;
public final Account acctINFO;
public list<AggregateResult> lstAR = new list<AggregateResult>();

/* 
Note that any query that includes an aggregate function returns its results in an array of 
AggregateResult objects. AggregateResult is a read-only sObject and is only used for query results. 
Aggregate functions become a more powerful tool to generate reports when you use them with a 
GROUP BY clause. For example, you could find the count of all opportunities for a CloseDate. 
*/  

public Agency_Client_Info(ApexPages.StandardController stdController)  
{
     /*Get the account information */
     this.acct = (Account)stdController.getRecord();
     acctINFO = [select External_ID__c from Account where ID =:acct.ID];
     
            lstAR=[ select count(ID) TotalSC, 
                    sum(Total_Subscribers__c) TotSubs,
                    sum(Earnedpremium_SUM__c) TotPrem
                    from Sub_Client__c where AOR1_TIN__c = :acctINFO.External_ID__c Or 
                                             AOR2_TIN__c = :acctINFO.External_ID__c
                                             ];
}

public list<AgencyInfoClass> getResults()
{
list<AgencyInfoClass> lstResult = new list<AgencyInfoClass>();  
for (AggregateResult ar: lstAR)  
{  
AgencyInfoClass objAgencyInfoClass = new AgencyInfoClass(ar);  
 lstResult.add(objAgencyInfoClass);  
}  
return lstResult;  
}  


//DEFINE CLASS TO HOLD THE INFORMATION TO BE PASSED
class AgencyInfoClass
{
public Decimal TotalSubs
{ get;set; }

public Decimal TotalPrem
{ get;set; }

public Integer TotalSC
{ get;set; }


//Convert the objects to type needed
public AgencyInfoClass(AggregateResult ar)
{
//Note that ar returns objects as results, so you need type conversion here
TotalSC =   (Integer)ar.get('TotalSC');
TotalSubs = (Decimal)ar.get('TotalSubs');
TotalPrem = (Decimal)ar.get('TotalPrem');

}
}

}

 

 

VF Page

 

<apex:page standardController="Account" extensions="Agency_Client_Info" standardStylesheets="true">

<apex:pageblocksection >
    <apex:pageBlockTable value="{!Results}" var="ar">
        <apex:column headerValue="# of Subs" value="{!ar.TotalSubs}"/>
        <apex:column headerValue="Earned Premium" value="{!ar.Totalprem}"/>

    </apex:pageBlockTable>
</apex:pageblocksection>
</apex:page>

 

 

Ihave a need to group and sum a custom object related list and show it in a standard page layout on the account page.

 

Related list items are as follows:

 

Order Widget Name  Qty

1        ABX                 5

2        ABX                 2

3        WWW              3

5        WWW              3

9        ABC                 3

 

Need it to show on the account page as follows:

 

Widget Name          Sum Qty

ABX                              10

WWW                             6

 

I am by no means a programmer but dabble in Apex/Visualforce.

 

Thanks for any help.


Kevin

We hae a look up field to Opportunites on the cases object.  I would like to update a field on the Opportunity when the Case is closed out.  I want to change the value from Sent for procesing, to Report Returned.

 

How can I get this done. 

 

FYI, I have no apex coding background so please take that into consideration in your answer.

 

Thanks in Advance.


Kevin Edelmann

Hello All Mighty & Powerful force.com developers :smileyhappy:
 
I beseach you to help this lowly Admin who knows little of the coding you all do and for me it would take forever to decipher how to go about doing what is needed whilst you will surely be able to rattle off the answer quickly.
 
I saw an example of how to show other won opportunities on the current opportunity where the Current Carrier field values are the same.  I was able to get the code to work in the sandbox but cannot transfer it over to the live environment as I need some tests before I can.  I have no idea how to create tests so need your help badly! 
 
Below is the controller and Apex page:
 
Controller

public class OpportunityCompetitionController {Opportunity opp;
    private Boolean show = false;
    private Boolean hasCompetitor = false;
    private Boolean hasQueried = false;
    private List<Opportunity> wins;
    private final Set<String> IGNORE_SET = new Set<String>{'Other', 'Unknown', 'No Competition','None - Existing Customer'};
                                                                                                                 
    public OpportunityCompetitionController(ApexPages.StandardController stdController) {
        this.opp = (Opportunity)stdController.getRecord();
        this.opp = [Select id, Current_Carrier__c from Opportunity where id = :opp.id];
        initCompetitiveWins();
    }
    
    //getters (no setters, we don't let anyone set our values)
    public Boolean getShow()
    {
        return show;    
    }
     
    public Boolean getHasCompetitor()
    {
        return hasCompetitor;   
    }   
    
    public Boolean getHasQueried()
    {
        return hasQueried;  
    }
    
    public Boolean getHasWins()
    {
        return (wins != null && wins.size() > 0);   
    }      
    
    public List<Opportunity> getWins () 
    {
        return wins;   
    }  
            
    public String getNoCompetitorText() 
    {
        return 'Fill in Current Carrier above to get a list of our biggest wins against that competitor.';   
    }
    
    public String getNoWinsText() 
    {
        return 'There are no matching competitive wins against '+opp.Current_Carrier__c+'.';   
    }        
        
    public void initCompetitiveWins() {
 
        if (opp.Current_Carrier__c == null || IGNORE_SET.contains(opp.Current_Carrier__c))
        {
            hasCompetitor = false;
        }
        else
        {
            hasCompetitor = true;
        }
     }
    public void queryOpportunityWins()
    {
        if (opp.Current_Carrier__c != null && !IGNORE_SET.contains(opp.Current_Carrier__c))
        {
            try 
            {
                wins = [select id,
                           OwnerId,
                           Owner.Name,
                           AccountId,
                           Account.Name,
                           Name,
                           Amount,
                           Effective_Date__c,
                           Current_Carrier__c,
                           Producer_Account__c 
                        from Opportunity 
                        where   Current_Carrier__c = :opp.Current_Carrier__c 
                        and id != :opp.Id 
                        and IsWon = TRUE 
                        order by Amount desc limit 15];
            }
            catch (Exception e)
            {
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 
                   'Error retrieving competitive wins: ' + e.getMessage());
                ApexPages.addMessage(myMsg);                
            }
            hasQueried = true;                  
        }            }     }

Apex Page
 
<apex:page standardController="Opportunity" extensions="OpportunityCompetitionController">
<apex:form id="form">
<apex:pageBlock id="message" rendered="{!NOT(hasCompetitor)}">
       <!-- <apex:image id="messageIcon" value="{!$Resource.icon_information}"/>-->
       <span>{!noCompetitorText}</span>

</apex:pageBlock>
<apex:commandLink rendered="{!AND(hasCompetitor,NOT(hasQueried))}"

                  value="View Competitive Wins" action="{!queryOpportunityWins}" reRender="form"

                  status="queryStatus"/>

<apex:actionStatus id="queryStatus" startText="Searching..."/>

<apex:messages />

<apex:pageBlock id="block" rendered="{!hasQueried}">

     <apex:panelGroup rendered="{!NOT(hasWins)}">

       <!--  <apex:image id="messageIcon" value="{!$Resource.icon_information}"/> -->

         <span>{!noWinsText}</span>

     </apex:panelGroup>

      <apex:pageBlockTable rendered="{!hasWins}" value="{!wins}" var="win">

           <apex:column >

           <apex:outputLink value="/{!win.Id}" target="_top">{!win.Name}</apex:outputLink>

           <apex:facet name="header">Opportunity Name</apex:facet>

           </apex:column>

           <!-- <apex:column >
           <apex:outputLink value="/{!win.AccountId}" target="_top">{!win.Account.Name}</apex:outputLink>
           <apex:facet name="header">Account Name</apex:facet>          
           </apex:column> -->

           <apex:column >

           <apex:outputLink value="/{!win.OwnerId}" target="_top">{!win.Owner.Name}</apex:outputLink>

           <apex:facet name="header">Owner Name</apex:facet>

           </apex:column>/>

           <apex:column ><apex:outputField value="{!win.Amount}" />

           <apex:facet name="header">Amount</apex:facet>

           </apex:column>

           <apex:column >

           <apex:outputField value="{!win.Current_Carrier__c}" />

           <apex:facet name="header">Competition</apex:facet>
           </apex:column>
           <apex:column ><apex:outputField value="{!win.Effective_Date__c}" />
           <apex:facet name="header">Eff. Date</apex:facet>
           </apex:column>
           <apex:column ><apex:outputField value="{!win.Producer_Account__c}" />
           <apex:facet name="header">Producer Co.</apex:facet>
           </apex:column>

       </apex:pageBlockTable>
</apex:pageBlock> 
</apex:form>    
</apex:page>

Again, I beseach thee for any and all help that can be bestowed up this humble admin. 

Thanks in advance,

Kevin

I don't have much Java/programing experience and I need some help to upgrade two s-controls that were created last year.

What would be the best way to go about getting help for this?  I can post the s-control if need be, but didn't want to clog things up at first.

Thanks,

Kevin

I have a list of opportunity IDs and want to just display data from the opportunity record for those IDs.  I can see how you read from Salesforce and get data out but how do I use a selective list of IDs and get data out for just those IDs.

We hae a look up field to Opportunites on the cases object.  I would like to update a field on the Opportunity when the Case is closed out.  I want to change the value from Sent for procesing, to Report Returned.

 

How can I get this done. 

 

FYI, I have no apex coding background so please take that into consideration in your answer.

 

Thanks in Advance.


Kevin Edelmann

Hello,

I'm hoping someone can tell me how to use Excel Connector to transfer accounts & contacts (including activity histories for each contact) from one salesforce account to another salesforce account. Any suggestions?

Thanks, Julie
hi everyone
 
I am designing excel template to upload opportunity by connector.
Actually we don't have any account in system, but it is easy to insert new account before uploading opportunity and then use vlookup to combine account ID.
 
However, I can't find product information when i download an opportunity already created in system with product information.
 
I know opportunity is a complicated object to use with excel connector, but adding product information by ID should not be so difficult.
 
I appreciate that if any friend can give me some advice.
Hi, Where can I download a copy of the Excel Connector for the Professional Edition of SFDC? I used EC at my previous company and love it, but can find it under the app exchange anylonger.
Thanks,
elizabeth
Hello,

I have been trying to get a field on a Visualforce page (the Account ID - a custom field which is a standard lookup) to pre-populate from a query parameter in the url. It does *not* work.

The general use case is that we have a related list on the Account Page for a custom object called Checklist. When we use the standard New button to create a new record, the Account ID is pre-populated on the page since the ID and name are passed in as query parameters.

We had to create a small Visualforce page instead of using the standard page, and overrode the New button. Now when you select New, the page loads without the Account ID pre-populated even though the ID and name are still in the url as query parameters. I took some JavaScript code to pull out those values and have been trying for the past day to figure out how to pass them to the standard controller so it recognizes the Account. The point here is that the end user should not have to re-select the Account from a lookup field when they just came from the Account page.

Since you can't simply View Source on a Visualforce page to see what the field name "{!Checklist__c.Checklist_Template__c}" resolves to (it's just escaped yet not interpreted at that point) I was forced to use a program to view the post request. It would appear that the <apex:inputfield> tag when referring to a lookup actually generates 6 input fields for it.

So... I used those 6 fields, populated them exactly as the lookup field would populate them, and still no luck.
Here is the code:
Code:
<apex:page standardcontroller="Checklist__c" tabstyle="Checklist__c">

  <apex:sectionHeader title="Checklist" subtitle="Create Checklist"/>
  <apex:form id="form1">
    <apex:pageBlock >
  <apex:pageBlockButtons location="top" >
   <apex:commandButton action="{!save}" onclick=" gup();" value="Save" />
  </apex:pageBlockButtons>
  <apex:pageBlockSection >
   <apex:pageBlockSectionItem >
    <apex:outputLabel value="Checklist Template" />
    <apex:inputField value="{!Checklist__c.Checklist_Template__c}" required="true" /> 
   </apex:pageBlockSectionItem>
     </apex:pageBlockSection> 
    </apex:pageBlock>
  
<!-- Here are the 6 fields that are generated by the lookup field -->
  <input type="text" id="AccountID_lkid" name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lkid"  />
  <input type="text" id="AccountID_lkold" name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lkold"  />
  <input type="text"  name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lspf" value="0"  />
  <input type="text"  name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_mod" value="0"  />
  <input type="text"  name="j_id0:form1:j_id2:j_id5:j_id6:AccountID_lktp" value="001"  />
  <input type="text" id="AccountID" name="j_id0:form1:j_id2:j_id5:j_id6:AccountID"  />
  
<!-- Here is the code to pull the Account ID and Name out of the url. This definitely works -->
<script type="text/javascript">

   var regexS = "[\\—&]CF00NS0000000M2Je_lkid=([^&#]*)";
   var regex = new RegExp( regexS );
   var results = regex.exec( window.location.href );
   document.getElementById('AccountID_lkid').value = results[1];
 
 var regexS2 = "[\\–&]CF00NS0000000M2Je=([^&#]*)";
   var regex2 = new RegExp( regexS2 );
   var results2 = regex2.exec( window.location.href );
   document.getElementById('AccountID').value = results2[1];
   document.getElementById('AccountID_lkold').value = results2[1];
  </script>
  </apex:form>
</apex:page>

 
Now I realize I can override the Standard controller and just grab the ID out of the request and it would work just fine, but I really want to understand why this does not work with just the standard controller. This is a pretty big loss of functionality when the page used to pre-populate with the Account ID and then when you write a Visualforce page it no longer does.

Thanks,
Sara
  • October 13, 2008
  • Like
  • 0
I have a custom object with a 1-to-1 relationship with the Contact object via a lookup field.  I want to create a Visualforce page that shows the Contact detail section on top and the customObj__c detail section below it.  I know that I could work around it by using the Contact standard controller for the page and then lay out my custom object's fields by hand, but it would be fantastic if it were possible to do this using standard controllers for both, since that would allow the page layout tool to be used (and different layouts per record type, etc).
 
I'm still pretty new to Visualforce and custom controllers, extensions, and components.  I thought maybe I could get this to work by putting an <apex:detail> section in a custom component.  The first problem is that it appears there's no way to have a component use a standard controller.  Secondly, when the component is included in the main Contact page, the <apex:detail> section takes on the scope of the Contact record, rather than pull from the controller of the component.
 
I guess I'm essentially trying to put together a sort of "Console" type of functionality where multiple detail sections are present and they relate to the main Contact record.  Is this possible using Visualforce?
 
Thanks,
Jeff
 
I have an issue with the Excel Connector.  I am trying to import some new leads in to Salesforce and it is failing with the above mentioned error on the Owner ID field.  I am putting the full username into the field.  ie. Alain Obrien in this example.  This is the same format I used when importing contacts and accounts etc and I had no issues.
 
The bizaar bit is if I use the wizard to extract leads into Excel, it shows the owner ID as I have described above.  If I change nothing, and try and use the update option, it fails with the same error.  So its failing to update with the data it has just extracted.
 
Any assistance would be most appreciated.
 
Thanks
 
 
Chris
  • September 10, 2008
  • Like
  • 0
Hi, i'm trying to import all the data from my previous crm into salesforce.
 
I have already imported all my leads, contact and accounts into sf, but now i need to import the opportunities, i have succeeded my tst batch of importing the opportunitie with the account related id.
but now i noticed that there is no contact role, so how would i import (in one shot if possible) all my opportunities with the related account & contact  id ?
 
 
Thanks
 
  • September 08, 2008
  • Like
  • 0
I'm trying to determine if there is a way to block certain users from exporting all the contacts in the system with this tool.  I saw a posting on this, but it was from 3 years ago, so I'm hoping that some progress has been made on this issue. 

An alternative solution (although less desirable) would be to track the history of use with this tool.  For example, if a user Joe Schmo uses the excel connector to grab all the contacts in the system, is there any history that gets stored showing this?

Does anyone have any experience with this issue? 

Thanks!
Is there an effective way to link Salesforce.com & Excel with a Mac

Our company uses an Excel based bidding form that needs to integrate with the customer information based on SFDC.

Thanks for any help.

Mark
Good afternoon.
 
I just bought one licence of salesforce Group Edition and I cant up load the previous comercial activity that I have in excel.
 
Does Excel Connector work for the group edition and it doesnt, do you know about any tool that does??
 
Thanks a lot for your answer.


Message Edited by lutor on 08-28-2008 10:10 AM
  • August 28, 2008
  • Like
  • 0
I´m new to this. I´m wondering if there is a way to import Contracts from Excel?

Thanks.


  • August 26, 2008
  • Like
  • 0
Is there any VF shortcut to getting Created By and Last Modified By to show up like they do in the regular UI?  You know, showing user full name with a link, followed by date and time?

Or do i need to construct those by hand from multiple fields?

Thanks!


  • August 07, 2008
  • Like
  • 0