• scottj2
  • NEWBIE
  • 4 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 12
    Replies

Help!!

It looks like the Summer 2012 release broke something on a bunch of our apex component pages.

We have component pages with simple forms that can save data (usually custom fields on standard objects).  So for example, we have a "Billing" component which cantains a form where users can save Billing Information on an account.

The component looks like this:

 

<apex:component controller="billingController" allowDML="true" >
  
<apex:attribute name="acc"
description="The account"
type="Account"
required="true"
assignTo="{!acc}"/>
<apex:form >
       <apex:pageBlock title="Account Banking Info" mode="edit" id="thePageBlock">
                <apex:messages styleClass="errorMsg"  />
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save" disabled="false" />
        </apex:pageBlockButtons>
.....{all the form fields are here}......
</apex:form>

 


Then, our component controller (billingController.class), has a simple save method:

    public void save() {
      try{
       upsert(this.acc);
      } catch(DMLException ex) {
       ApexPages.addMessages(ex);
      }
      return;
    }

 



This code has worked without issue for over a year now.  Then, this morning after the 2012 summer release, this page does not work.  No error message is retrieved, and when I look in the debug logs, the save method is never called.  Our tests work fine, since they call the save method directly, but the component pages are never calling the method definied in the action attribute of the commandbutton.  I have also confirmed that this is broken for each and every one of our component pages.  We also have apex pages that also do save calls in the identical way, and those pages seem to work fine.  It only looks like it's broken for apex components.

Any ideas whats going on?

Hi All,

 

I have written some custom Apex code the converts leads into accounts, opportunities and contacts.  After converting, we updated some custom fields inside the converted contact and opportunity.

 

I'm having a problem with the LeadConvertResult.getContactId.  Something must have changed, as this code worked, and the unit test I have used to pass in this case, but it's failing now.

 

		Database.LeadConvertResult lcr = Database.convertLead(lc);
		if(lcr.isSuccess()){
			Account acc = [select id, name, bd_manager__c, Account_Executive__c from account where id = :lcr.getAccountId()];
			Contact convertedContact = [select id from contact where id = :lcr.getContactId()];
...

 

The first line after lcr.isSuccess works fine:  I can see the account just fine.  Unfortunately, the second line (getting the convertedContact) does not.  It seems lcr.getContactId returns null, and thus we cannot do anything with the convertedContact.  Afterwards, when I manually look at the converted lead, it shows the properly converted contact.

 

Has anyone else seen this behaviour?  Do I have to do anything different to retrieve the converted contact?

We are building a custom lead convert page, and am utilizing the apex ConvertLead operation.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm

 

One of the features we are giving our users is the ability to not only choose an account to merge the lead to, but also give the option to either create a new contact, or merge to an existing contact..

 

Here is the description from that page that I am confused with:

 

setContactId

Sets the ID of the contact into which the lead will be merged (this contact must be associated with the account specified with setAccountId, and setAccountId must be specified). This value is required only when updating an existing contact.

Important

If setContactID is specified, then the application creates a new contact that is implicitly associated with the account. 

 

The first sentence makes sense.  But the second does not...if you want to create a new contact, you can't possibly set the contact id, since it doesn't exist yet.  Should this read:

 

If setContactID is not specified, then the application creates a new contact that is implicitly associated with the account. 

Hi All,

 

I'd like to do something like this with APEX/SOQL:

 

Integer numDays = x;

List<Account> accs = [select id from account where createddate = LAST_N_DAYS::var];

 

 

Essentially, I want to pass the variable to the LAST_N_DAYS feature in SOQL.  Any ideas?

Do the trigger/validation steps have the same order of execution for the Bulk API vs. the regular API?  I have a trigger which does a lookup to populate a required realtionship field (ParentID on the Note object).  When using the regular API, the trigger fires before the validation, and the data is loaded properly.  But when using the Bulk API, I get the following error:

REQUIRED_FIELD_MISSING
Any ideas?

Sorry if this post seems confusing

Hi,

I'm seeing a strange error that I think has to do with the timing of events in salesforce's unit tests.

Essentially all I've built is a trigger that makes the original creator of a Lead auto-follow the chatter feed for the Account and Opportunity after the Lead is converted.

See the following trigger on the opportunity that performs this:

	trigger ChatterAutoFollowOpportunity on Opportunity (after insert) {

    List<ID> opportunityIds = new List<ID>();
    for (Opportunity opp : Trigger.new) {
    	System.debug('opp.Id: ' + opp.Id);
        opportunityIds.add(opp.Id);
    }
    List<EntitySubscription> followAccounts = new List<EntitySubscription>();
    List<EntitySubscription> followOpps = new List<EntitySubscription>();
    for(Lead lead : [SELECT ID, ConvertedOpportunityId, ConvertedAccountId, CreatedById FROM Lead where ConvertedOpportunityId IN :opportunityIds ]){
        EntitySubscription followAccount = new EntitySubscription (
                                 parentId = lead.ConvertedAccountId,
                                 subscriberid = lead.CreatedById);
                                 
        EntitySubscription followOpp = new EntitySubscription (
                                parentId = lead.ConvertedOpportunityId,
                                subscriberid = lead.CreatedById);
        followAccounts.add(followAccount);
        followOpps.add(followOpp); 

    }
    insert followAccounts;
    insert followOpps;
}

 

This trigger works great for us, and I've tested it manually.  The problem comes in when I wrote my unit test for this trigger:

@isTest
private class ProspectConvertTest {
    static testMethod void myUnitTest() {
    //User user = [select id from User where alias = 'itest'];
        Lead newLead = new Lead(Company='My Test Lead', LastName = 'UnitTest');
        //newLead.CreatedById = user.Id;
        insert newLead;
        
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(newLead.Id);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
//Lead has been converted.  Check the lead, account, and opportunity
 
 
Lead existingLead = [Select id, isConverted, ConvertedAccountId, ConvertedOpportunityId, createdbyid FROM Lead where id = :newLead.id];
 
List<EntitySubscription> esList = [Select parentId, SubscriberId from EntitySubscription where parentid in (:existingLead.ConvertedAccountId, :existingLead.ConvertedOpportunityId) and SubscriberId = :existingLead.createdbyid];
 
System.assert(existingLead.isConverted);
System.assert(existingLead.ConvertedAccountId != null);
System.assert(existingLead.ConvertedOpportunityId != null);
 
//this is the statement that fails
System.assertEquals(2, esList.size());
    }

 

The last line in that unit test does not assert properly.  When run in a unit test, the EntitySubscriptions that are created in the trigger dont exist.  When I look at the code coverage, it is missing all the lines inside the for loop...which essentially tells me that the ConvertedOpportunityId is not being populated in the trigger.  The odd thing is that the trigger works fine when I convert a Lead using the UI.  Even odder is that If I run this query in the Trigger, it succeeds:

Lead convertedLead = [SELECT ID, ConvertedOpportunityId, ConvertedAccountId, CreatedById FROM Lead where ConvertedOpportunityId = :existingLead.ConvertedOpportunityId ];
System.assert(convertedLead != null);

 

So my problem is, why is the convertedOpportunityId populated in the unit test after the trigger is executed, but not before, and also why does it work when not run in a unit test?
Sorry if this is confusing....I can clarify with any questions.

Why does this query not work:

 

"select type from task"

  • September 14, 2011
  • Like
  • 0

Hi All,

 

I have a need the need to make an edit page display slightly differently than the detail page, but the page layout editor does not allow this.  In this example, I have a formula field called "Full Name" that concatenates first and last name of an account, and that formula field is displayed on the Page Layout.  The problem is that, when a user clicks edit the "Full Name" field is hidden because obviously it's read only.  My problem is that I want them to be able to still edit the "First Name" and "Last Name" fields.  If I add those fields to the page layout, they're shown on the detail page...there doesn't seem to be a way to hide a field from the detail page, but show it on the edit page.  There is also no way of changing to a different page layout when the user clicks edit.

 

Any advice other than visualforce?  I've pretty much built visualforce pages for absolutely everything, and I want to steer clear of it in this case as it's the most basic page we have (ie. the Account page).

Help!!

It looks like the Summer 2012 release broke something on a bunch of our apex component pages.

We have component pages with simple forms that can save data (usually custom fields on standard objects).  So for example, we have a "Billing" component which cantains a form where users can save Billing Information on an account.

The component looks like this:

 

<apex:component controller="billingController" allowDML="true" >
  
<apex:attribute name="acc"
description="The account"
type="Account"
required="true"
assignTo="{!acc}"/>
<apex:form >
       <apex:pageBlock title="Account Banking Info" mode="edit" id="thePageBlock">
                <apex:messages styleClass="errorMsg"  />
        <apex:pageBlockButtons >
            <apex:commandButton action="{!save}" value="Save" disabled="false" />
        </apex:pageBlockButtons>
.....{all the form fields are here}......
</apex:form>

 


Then, our component controller (billingController.class), has a simple save method:

    public void save() {
      try{
       upsert(this.acc);
      } catch(DMLException ex) {
       ApexPages.addMessages(ex);
      }
      return;
    }

 



This code has worked without issue for over a year now.  Then, this morning after the 2012 summer release, this page does not work.  No error message is retrieved, and when I look in the debug logs, the save method is never called.  Our tests work fine, since they call the save method directly, but the component pages are never calling the method definied in the action attribute of the commandbutton.  I have also confirmed that this is broken for each and every one of our component pages.  We also have apex pages that also do save calls in the identical way, and those pages seem to work fine.  It only looks like it's broken for apex components.

Any ideas whats going on?

We are building a custom lead convert page, and am utilizing the apex ConvertLead operation.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_convertLead.htm

 

One of the features we are giving our users is the ability to not only choose an account to merge the lead to, but also give the option to either create a new contact, or merge to an existing contact..

 

Here is the description from that page that I am confused with:

 

setContactId

Sets the ID of the contact into which the lead will be merged (this contact must be associated with the account specified with setAccountId, and setAccountId must be specified). This value is required only when updating an existing contact.

Important

If setContactID is specified, then the application creates a new contact that is implicitly associated with the account. 

 

The first sentence makes sense.  But the second does not...if you want to create a new contact, you can't possibly set the contact id, since it doesn't exist yet.  Should this read:

 

If setContactID is not specified, then the application creates a new contact that is implicitly associated with the account. 

Hi All,

 

I'd like to do something like this with APEX/SOQL:

 

Integer numDays = x;

List<Account> accs = [select id from account where createddate = LAST_N_DAYS::var];

 

 

Essentially, I want to pass the variable to the LAST_N_DAYS feature in SOQL.  Any ideas?

Hi,

 

I had quite a harrowing weekend trying to deploy a lot of code from a full sandbox to production.  One of the problems I had was slowness.  Using Eclipse and deploying to live took as much as 45 minutes, only to come back with a failure.  I found this particularly frustrating because when everything works in a full copy sandbox, you expect it to work in production.

 

A deployment whose steps took 20 minutes against a full sandbox took 9 hours against production because of errors.  So I'd take four or five minutes to try something to resolve the error and then I'd have to wait another 40 for the deployment to fail.  Even when I was loading only one small class with one small unit test, it still took a long time.

 

I was wondering if I'm the only one experiencing this, and if it's an Eclipse thing or a Salesforce thing.

 

Any tips would be most appreciated.

Do the trigger/validation steps have the same order of execution for the Bulk API vs. the regular API?  I have a trigger which does a lookup to populate a required realtionship field (ParentID on the Note object).  When using the regular API, the trigger fires before the validation, and the data is loaded properly.  But when using the Bulk API, I get the following error:

REQUIRED_FIELD_MISSING
Any ideas?

Sorry if this post seems confusing

Hi,

I'm seeing a strange error that I think has to do with the timing of events in salesforce's unit tests.

Essentially all I've built is a trigger that makes the original creator of a Lead auto-follow the chatter feed for the Account and Opportunity after the Lead is converted.

See the following trigger on the opportunity that performs this:

	trigger ChatterAutoFollowOpportunity on Opportunity (after insert) {

    List<ID> opportunityIds = new List<ID>();
    for (Opportunity opp : Trigger.new) {
    	System.debug('opp.Id: ' + opp.Id);
        opportunityIds.add(opp.Id);
    }
    List<EntitySubscription> followAccounts = new List<EntitySubscription>();
    List<EntitySubscription> followOpps = new List<EntitySubscription>();
    for(Lead lead : [SELECT ID, ConvertedOpportunityId, ConvertedAccountId, CreatedById FROM Lead where ConvertedOpportunityId IN :opportunityIds ]){
        EntitySubscription followAccount = new EntitySubscription (
                                 parentId = lead.ConvertedAccountId,
                                 subscriberid = lead.CreatedById);
                                 
        EntitySubscription followOpp = new EntitySubscription (
                                parentId = lead.ConvertedOpportunityId,
                                subscriberid = lead.CreatedById);
        followAccounts.add(followAccount);
        followOpps.add(followOpp); 

    }
    insert followAccounts;
    insert followOpps;
}

 

This trigger works great for us, and I've tested it manually.  The problem comes in when I wrote my unit test for this trigger:

@isTest
private class ProspectConvertTest {
    static testMethod void myUnitTest() {
    //User user = [select id from User where alias = 'itest'];
        Lead newLead = new Lead(Company='My Test Lead', LastName = 'UnitTest');
        //newLead.CreatedById = user.Id;
        insert newLead;
        
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(newLead.Id);
LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
lc.setConvertedStatus(convertStatus.MasterLabel);
Database.LeadConvertResult lcr = Database.convertLead(lc);
//Lead has been converted.  Check the lead, account, and opportunity
 
 
Lead existingLead = [Select id, isConverted, ConvertedAccountId, ConvertedOpportunityId, createdbyid FROM Lead where id = :newLead.id];
 
List<EntitySubscription> esList = [Select parentId, SubscriberId from EntitySubscription where parentid in (:existingLead.ConvertedAccountId, :existingLead.ConvertedOpportunityId) and SubscriberId = :existingLead.createdbyid];
 
System.assert(existingLead.isConverted);
System.assert(existingLead.ConvertedAccountId != null);
System.assert(existingLead.ConvertedOpportunityId != null);
 
//this is the statement that fails
System.assertEquals(2, esList.size());
    }

 

The last line in that unit test does not assert properly.  When run in a unit test, the EntitySubscriptions that are created in the trigger dont exist.  When I look at the code coverage, it is missing all the lines inside the for loop...which essentially tells me that the ConvertedOpportunityId is not being populated in the trigger.  The odd thing is that the trigger works fine when I convert a Lead using the UI.  Even odder is that If I run this query in the Trigger, it succeeds:

Lead convertedLead = [SELECT ID, ConvertedOpportunityId, ConvertedAccountId, CreatedById FROM Lead where ConvertedOpportunityId = :existingLead.ConvertedOpportunityId ];
System.assert(convertedLead != null);

 

So my problem is, why is the convertedOpportunityId populated in the unit test after the trigger is executed, but not before, and also why does it work when not run in a unit test?
Sorry if this is confusing....I can clarify with any questions.

when a lead is converted we want to create a new record in a custom object  in addition to account, contact and oppurtunity. Can anyone advise how to achieve this?? We also want to use a logic for account type. When the account type is "A" we want to create account,contact and oppurtunity, If the account type is "B" we want to create account, contact, oppurtunity and a custom object

 

Thanks

Why does this query not work:

 

"select type from task"

  • September 14, 2011
  • Like
  • 0

Hi All,

 

I have a need the need to make an edit page display slightly differently than the detail page, but the page layout editor does not allow this.  In this example, I have a formula field called "Full Name" that concatenates first and last name of an account, and that formula field is displayed on the Page Layout.  The problem is that, when a user clicks edit the "Full Name" field is hidden because obviously it's read only.  My problem is that I want them to be able to still edit the "First Name" and "Last Name" fields.  If I add those fields to the page layout, they're shown on the detail page...there doesn't seem to be a way to hide a field from the detail page, but show it on the edit page.  There is also no way of changing to a different page layout when the user clicks edit.

 

Any advice other than visualforce?  I've pretty much built visualforce pages for absolutely everything, and I want to steer clear of it in this case as it's the most basic page we have (ie. the Account page).

Hello,

 

I'm attaching a custom button to the account page that opens a new window which is Visual Force.  I want the user to enter in information, click a submit button, and then update the account and refresh the account page.  Is there anyway I can do this?

 

I've tried some Javascript but I get a  permission denied error.