• blueandgold
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
I’ve read a lot about using Lightning Data Packages, but I can’t find any examples or documentation about creating one for an external data service. Anyone have any resources for developing a Lightning Data service from an ISV perspective?

Hi folks,

 

We've got an application that is running through a bunch of job items in an Apex Batch execution.  We're wondering if there might be a general understanding on the relative speed at which Apex Batches are executed in sandbox environments versus production environments.  We're assuming that sandboxes probably get less resources thrown at them, and would likely be slower to process Apex Batches.

 

While I figure SFDC isn't going to have hard numbers on this, do other developers have a general sense based on experience? 

Hi folks,

 

We currently have a PHP script that sends a record to the Lead object, and include in that a campaign ID.  We then have built three triggers that do the following:

 

1) a trigger on insert on the Campaign Member, that when the lead record is created with a campaign ID, it creates a campaign member and then does an auto-conversion of the Lead

 

2) a trigger on insert on the Opportunity, which when the converted opportunity is created, updates the stage and closed date fields

 

3) a trigger on update on the Lead, which is fired when the lead conversion process finishes (which is the updating of the Lead record by the lead conversion process to associate the lead record in question to the newly created account, contact, etc)

 

What we'd like to do is have our PHP not only execute the request to create the new lead (which fires the chain of events above), but also catches a response from Salesforce that includes the newly created Lead record's ID.  Once we have that, we want to immediately have our PHP application hop into the Account that was just created in the lead conversion process and update a few fields (long story why we need to do it this way).

 

My questions are:

 

Based on the chain of events above, when would Salesforce provide our PHP application a success response on the Lead record creation?  Does that happen all the triggers above fire, and the lead is actually in its converted state due to the order of operations in SFDC?

 

Cheers!

Alright, as a newbie to bulkifying trigger code, I'm scratching my head on this one. I feel like I've read all I can on List collections, but I still can't figure how to get going in this situation.  Here's what we've got cooking.

 

Objects in play: CampaignMember, Campaign, Lead

 

Goal: after the insert of a new campaignmember record, convert the campaignmember's associated Lead record.

 

We created this without the bulkifying process, and as one would expect, when someone goes to add a bunch of campaignmembers to a campaign, our trigger fires, and often times quite quickly hits the SOQL governor limit due to queries within a loop.

 

Here's the core snippet of code we have created, unbulkified. I'm trying to learn how to get better at bulkifying things, and this one seems a bit complex.

 

trigger ECampaignMember on CampaignMember (after insert) {

    for(CampaignMember myCampaignMember: Trigger.new){

	        // Find the lead record related to this campaign member
    	    Lead l = [SELECT FirstName, LastName, Email, Street, City, State, PostalCode, RecordTypeId, IsConverted, RegistrationMatchReviewNeeded__c FROM Lead WHERE Id = :myCampaignMember.LeadId LIMIT 1];

	        // Find the name of the campaign that this campaign member is related to
    	    Campaign campaign = [SELECT Name FROM Campaign WHERE id = :myCampaignMember.CampaignId LIMIT 1];

        	// Find the RecordType ID for the Lead RecordType that has DeveloperName = Registration_Lead
	        RecordType rlrt = [SELECT Id FROM RecordType WHERE SobjectType = 'Lead' AND DeveloperName = 'Registration_Lead' LIMIT 1];

	        // Make sure this is a Registration lead record type. If not, don't do any of this.
    	    if(l.IsConverted==false && l.RecordTypeId == rlrt.id){

	            // Set the variables
    	        String c = '1';
        	    String a = '1';


	            Database.LeadConvert lc = new database.LeadConvert();
    	        lc.setLeadId(myCampaignMember.LeadId);

        	    // need to assign the conversion status to match the dropdown options
          	    lc.convertedStatus = 'Closed - Converted';

	            // If the lead is not already converted, AND if the lead record type has a DeveloperName = Registration_Lead. If not, don't create an opportunity record.
    	        if(l.IsConverted==false && l.RecordTypeId == rlrt.Id){

        	        // create a new opportunity upon conversion
            	    lc.setDoNotCreateOpportunity(false);

           		 } else {

            	    // create a new opportunity upon conversion
                	lc.setDoNotCreateOpportunity(true);

	            }

    	        // If the lead is not already converted, AND if the lead record type has a DeveloperName = Registration_Lead
        	    if((l.IsConverted==false && (l.RecordTypeId == rlrt.Id))){

            	    // name the opportunity in the format: "<firstname> <lastname> - <campaign_name> - Event Registration"
                	lc.setOpportunityName(l.FirstName + ' ' + l.LastName + ' - ' + campaign.Name + ' - Event Registration');

        	    }

	            // If there is an existing contact that matches on last name, first name, and email address...
    	        if(i>0){

        	        // set the contact ID
            	    lc.setContactId(c);

        	        // set the account ID
            	    lc.setAccountId(a);

	            }

    	    Database.LeadConvertResult lcr = Database.convertLead(lc);
        	System.assert(lcr.isSuccess());

        	}
		}
    }
}

 Now, I generally understand the following:

 

1) I need to get all the SOQL queries out from under the for loop

2) I need to build a list of the campaign members that I need to iterate through

 

The biggest challenge is that you can see down towards the bottom of the code, that I need to grab values in related objects (like the Campaign object), so that I can include them in the conversion process.  For instance, I need to get the name of the Campaign related to the current campaign member so that I can include that in the sting that will be used to create the new Opportunity record name upon conversion.

 

How the heck do I do that?

Thanks in advance for even the first step of help on this.  It's greatly appreciated.

 

Cheers! 

 

Hi folks,

 

We've got an application that is running through a bunch of job items in an Apex Batch execution.  We're wondering if there might be a general understanding on the relative speed at which Apex Batches are executed in sandbox environments versus production environments.  We're assuming that sandboxes probably get less resources thrown at them, and would likely be slower to process Apex Batches.

 

While I figure SFDC isn't going to have hard numbers on this, do other developers have a general sense based on experience? 

Alright, as a newbie to bulkifying trigger code, I'm scratching my head on this one. I feel like I've read all I can on List collections, but I still can't figure how to get going in this situation.  Here's what we've got cooking.

 

Objects in play: CampaignMember, Campaign, Lead

 

Goal: after the insert of a new campaignmember record, convert the campaignmember's associated Lead record.

 

We created this without the bulkifying process, and as one would expect, when someone goes to add a bunch of campaignmembers to a campaign, our trigger fires, and often times quite quickly hits the SOQL governor limit due to queries within a loop.

 

Here's the core snippet of code we have created, unbulkified. I'm trying to learn how to get better at bulkifying things, and this one seems a bit complex.

 

trigger ECampaignMember on CampaignMember (after insert) {

    for(CampaignMember myCampaignMember: Trigger.new){

	        // Find the lead record related to this campaign member
    	    Lead l = [SELECT FirstName, LastName, Email, Street, City, State, PostalCode, RecordTypeId, IsConverted, RegistrationMatchReviewNeeded__c FROM Lead WHERE Id = :myCampaignMember.LeadId LIMIT 1];

	        // Find the name of the campaign that this campaign member is related to
    	    Campaign campaign = [SELECT Name FROM Campaign WHERE id = :myCampaignMember.CampaignId LIMIT 1];

        	// Find the RecordType ID for the Lead RecordType that has DeveloperName = Registration_Lead
	        RecordType rlrt = [SELECT Id FROM RecordType WHERE SobjectType = 'Lead' AND DeveloperName = 'Registration_Lead' LIMIT 1];

	        // Make sure this is a Registration lead record type. If not, don't do any of this.
    	    if(l.IsConverted==false && l.RecordTypeId == rlrt.id){

	            // Set the variables
    	        String c = '1';
        	    String a = '1';


	            Database.LeadConvert lc = new database.LeadConvert();
    	        lc.setLeadId(myCampaignMember.LeadId);

        	    // need to assign the conversion status to match the dropdown options
          	    lc.convertedStatus = 'Closed - Converted';

	            // If the lead is not already converted, AND if the lead record type has a DeveloperName = Registration_Lead. If not, don't create an opportunity record.
    	        if(l.IsConverted==false && l.RecordTypeId == rlrt.Id){

        	        // create a new opportunity upon conversion
            	    lc.setDoNotCreateOpportunity(false);

           		 } else {

            	    // create a new opportunity upon conversion
                	lc.setDoNotCreateOpportunity(true);

	            }

    	        // If the lead is not already converted, AND if the lead record type has a DeveloperName = Registration_Lead
        	    if((l.IsConverted==false && (l.RecordTypeId == rlrt.Id))){

            	    // name the opportunity in the format: "<firstname> <lastname> - <campaign_name> - Event Registration"
                	lc.setOpportunityName(l.FirstName + ' ' + l.LastName + ' - ' + campaign.Name + ' - Event Registration');

        	    }

	            // If there is an existing contact that matches on last name, first name, and email address...
    	        if(i>0){

        	        // set the contact ID
            	    lc.setContactId(c);

        	        // set the account ID
            	    lc.setAccountId(a);

	            }

    	    Database.LeadConvertResult lcr = Database.convertLead(lc);
        	System.assert(lcr.isSuccess());

        	}
		}
    }
}

 Now, I generally understand the following:

 

1) I need to get all the SOQL queries out from under the for loop

2) I need to build a list of the campaign members that I need to iterate through

 

The biggest challenge is that you can see down towards the bottom of the code, that I need to grab values in related objects (like the Campaign object), so that I can include them in the conversion process.  For instance, I need to get the name of the Campaign related to the current campaign member so that I can include that in the sting that will be used to create the new Opportunity record name upon conversion.

 

How the heck do I do that?

Thanks in advance for even the first step of help on this.  It's greatly appreciated.

 

Cheers! 

 

I have a apex method within a class that has "with sharing". It is run by a user that has a profile very much like to a Read Only profile - i.e. doesn't have View All Data permission. The following code is attempted:

 

Schema.SObjectType obj = gd.get('Organization'); Map<String, Schema.SObjectField> M = obj.getDescribe().fields.getMap() ;

But fails on the second line with a "Attempt to de-reference a null object" - variable obj is null, the SObjectType for Organization was not retrieved. I change the class to "without sharing" and obj is no longer null but M is blank. No fields were retrieved. If I give the user View All Data permission, everything is fine.

Is this a bug? I was lead to believe that "without sharing" ensures that the sharing rules are not enforced. And I read that View All Data also circumvents records based sharing. But there's something not quite equal here. How are the permissions gained to be able to perform the field describe on the Organization object within an apex class without giving the user View All Data permission?

 

This is a little worrying, any help much appreciated. Thanks.


 

  • March 08, 2010
  • Like
  • 0
I am getting the following error for a Salesforce Standard User:

"System.Exception: No such column 'Name' on entity 'Organization'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."

For a Salesforce System Administrator, I do not get this error, which leads me to believe it is a permission issue.  However, when I go to Administration Setup -> Security Controls -> Field Accessibility, the 'Organization' object is not present with the other standard objects (Account, Contact, etc.).

Additionally, this error is occurring in a managed package.  In version 1.8 of my managed package, I did not receive this error with a Salesforce Standard User.  However, the error is occurring in version 1.9 of my managed package although the error-causing code did not change.  Maybe there was an error with the upgrade?

For completeness, here is the Apex code that is causing this error:

List<Organization> orgList = [Select o.Name, o.Id From Organization o];

Thanks in advance!