• sherry peng
  • NEWBIE
  • 75 Points
  • Member since 2014

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 2
    Likes Given
  • 5
    Questions
  • 14
    Replies
Hi,

My first try of this didn't work, and I did a work around, but I'm really trying to understand why my first try didn't work.  Basically, I'm trying to pull the Account Name from one of' it's child objects.  So, I thought the syntatx should be something like sObject.Account__r.Name
 
trigger TastingEvent on Tasting__c (before insert, before update) {
List<Event> myEvent = new List<Event>();
    User u = [Select id, FirstName from User where id =: UserInfo.getUserId() LIMIT 1];
    for(Tasting__c taste:Trigger.New) {
		String acct = taste.Account__c;
        Account myAccount = [SELECT Name, Id FROM Account WHERE Id = :acct];
        Event e = new Event();
        
        // this doesn't work
        //e.Subject = taste.Account__r.Name;
        
        // but this does
        String subject = (myAccount.Name + ' ' + taste.Location__c) ;
        e.Subject = subject;
        date st = taste.Date_of_Tasting__c;
        DateTime dt_StartDate = datetime.newInstance(st.year(), st.month(), st.day(), 3,0,0);
        e.StartDateTime = dt_StartDate;
        datetime endDate =  dt_StartDate;
        endDate = endDate.addHours(2);
        e.EndDateTime = endDate;
        
       
        
        
        e.OwnerId = u.Id;
        myEvent.add(e);
        System.debug(taste.Account__r.Name);
    }
    insert(myEvent);
}

 
I got following error: 
The BoatReviews component doesn't have an event handler registered with aura:handler that reloads data from Apex any time the value of the component’s boat attribute is changed
In Lightning Component Framework Specialist SuperBadge - Challenge 8, I got following error:
The BoatReview component doesn't include a public attribute named boat of type BoatType__c.
hi, All,
I am trying to set default value for a text field using formula. When doing this, the system asks me to choose field type and there several choices of $Setup.objectName_Fields_Map__c. These fields type including standard and custom objects as shown in following picture.
User-added image
For example, I can insert $Setup.Aircraft_Product_Fields_Map__c.Aircraft_Product_Id__c __c.Aircraft_Product_Id__c field which is custom object with custom field. Do you have any idea on where I can set which objects can be shown on this drop down list. 
I want to write a code to modify data among all sandboxes. For example, my code will modify a user's first name on all sandboxes. It can be done manually, but if an org has 100+ sandboxes, it will be hard to do it manually.  Can I use APEX to do this? Does anyone have experience to implement similar function?
Does anyone know whether the trigger.new is ordered or not? If yes, does trigger.old is the same oder of trigger.new? that is: trigger.new[0].id == trigger.old[0].id ?


In Lightning Component Framework Specialist SuperBadge - Challenge 8, I got following error:
The BoatReview component doesn't include a public attribute named boat of type BoatType__c.
I got following error: 
The BoatReviews component doesn't have an event handler registered with aura:handler that reloads data from Apex any time the value of the component’s boat attribute is changed
In Lightning Component Framework Specialist SuperBadge - Challenge 8, I got following error:
The BoatReview component doesn't include a public attribute named boat of type BoatType__c.
Hi,

I'm currently working with the BULK API (upsert mode) in NodeJS. I would like to use the JSON content type for both requests and payloads for batches. Requests are created correctly as I receive job and batches details but when Salesforce reads the payload of my batch request, it returns the error "Unable to read request: No content to map to Object due to end of input".

I confirm that the JSON sent in the payload is valid (validated by JSONLint). I also correctly set the external ID on both job details and objects in the payload.

Someone already have this error message?

Thanks in advance for your help,
Jordane
hi, All,
I am trying to set default value for a text field using formula. When doing this, the system asks me to choose field type and there several choices of $Setup.objectName_Fields_Map__c. These fields type including standard and custom objects as shown in following picture.
User-added image
For example, I can insert $Setup.Aircraft_Product_Fields_Map__c.Aircraft_Product_Id__c __c.Aircraft_Product_Id__c field which is custom object with custom field. Do you have any idea on where I can set which objects can be shown on this drop down list. 
Hi,

My first try of this didn't work, and I did a work around, but I'm really trying to understand why my first try didn't work.  Basically, I'm trying to pull the Account Name from one of' it's child objects.  So, I thought the syntatx should be something like sObject.Account__r.Name
 
trigger TastingEvent on Tasting__c (before insert, before update) {
List<Event> myEvent = new List<Event>();
    User u = [Select id, FirstName from User where id =: UserInfo.getUserId() LIMIT 1];
    for(Tasting__c taste:Trigger.New) {
		String acct = taste.Account__c;
        Account myAccount = [SELECT Name, Id FROM Account WHERE Id = :acct];
        Event e = new Event();
        
        // this doesn't work
        //e.Subject = taste.Account__r.Name;
        
        // but this does
        String subject = (myAccount.Name + ' ' + taste.Location__c) ;
        e.Subject = subject;
        date st = taste.Date_of_Tasting__c;
        DateTime dt_StartDate = datetime.newInstance(st.year(), st.month(), st.day(), 3,0,0);
        e.StartDateTime = dt_StartDate;
        datetime endDate =  dt_StartDate;
        endDate = endDate.addHours(2);
        e.EndDateTime = endDate;
        
       
        
        
        e.OwnerId = u.Id;
        myEvent.add(e);
        System.debug(taste.Account__r.Name);
    }
    insert(myEvent);
}

 
Hi all-- My trial account was approved as a Salesforce Foundation account yesterday, and I am now unable to save or edit any Apex code or triggers. I understand that this is properly done in a sandbox, which I have created.

However, when I try to deploy an Inbound Change Set, I receive a fatal error because my current production code has 0% test coverage -- all done in my Trial account. (Obviously not the best development practice - I know - but was trying to quickly test and evaluate Salesforce for our needs.)

So I think I am now in a catch-22 situation where I can't edit my code to actually make it 75% test compliant and I can't import new tested Inbound sandbox code because my current code is not compliant.

Ideas for getting un-stuck?
I am getting below error while running testing .. recently i have updated Custom settings with additinal values and started getting the below error. please help if any one have idea.

Error Message System.LimitException: Too many SOQL queries: 101
Stack Trace Class.leadTriggerHandler.assignOwner: line 86, column 1
Class.leadTriggerHandler.onBeforeInsert: line 36, column 1
Trigger.LeadsTrigger: line 4, column 1

here is test class.
@isTest(SeeAllData=true)
private class LeadTriggerHandlerTest {
	
    public static Map<String,User> testUsersMap;

    static testMethod void leadOwnerAssignmentTest() {
        Lead testLead = new Lead();
        setupTestData();
        test.startTest();
	        // Test null or blank zip code - owner should be default lead owner KCI US User
	          testLead = createLead('ABThera','Acute','');
	          system.assertEquals(SystemIdUtility.KCIUSUserId, [select OwnerId from Lead where Id=:testLead.Id].OwnerId);
	          
        	// loop through all combinations as configured in Lead Assignment custom setting and create leads with the sample values
        	for(Lead_Assignment_Settings__c las : Lead_Assignment_Settings__c.getAll().values()){
	        	testLead = createLead(String.ValueOf(las.Product__c),String.ValueOf(las.Facility_Type__c),'63000');
	        	if(Limits.getQueries() < Limits.getLimitQueries()-20){
	        		if(testUsersMap.get(String.ValueOf(las.JCA__c)) != null){	
	        			system.assertEquals(testUsersMap.get(String.ValueOf(las.JCA__c)).Id, 
	        						[select OwnerId from Lead where Id=:testLead.Id].OwnerId);
	        		}
	        	}
        	}
        	// update Lead and test Owner assignment.
        	testLead.Products__c = 'Ulta';
        	testLead.Facility_Type__c = 'Acute';
        	update testLead;
        	
        	// Test multiple product
        	testLead = createLead('Specialty Dressing;GRAFTJACKET','Acute','63000');
        	
        	// Test non matching zipcode - then Lead Owner assigned should be KCI US User
        	testLead = createLead('ABThera','Acute','99999');
        	system.assertEquals(SystemIdUtility.KCIUSUserId, [select OwnerId from Lead where Id=:testLead.Id].OwnerId);
        	
        test.stopTest();
    }
    
    private static Lead createLead(String product, String facilityType, String zipCode){
    
    	Lead newLead = new Lead();
    	newLead.FirstName = 'FirstName';
    	newLead.LastName = 'LastName';
    	newLead.Email = 'test@kci1.com';
    	newLead.Products__c = product;
    	newLead.Facility_Type__c = facilityType;
    	newLead.Zip_Postal_Code__c = zipCode;
    	
    	insert newLead;
    	
    	return newLead;
    
    }
    
    private static void setupTestData(){
		//get test users
		testUsersMap = new Map<String,User>();
		list<User> testTMVUsers=[Select Id,JCA__C, Employee_Id__c from User where IsActive=true and Employee_Id__c!=null and JCA__C='TMV' and Id !=:Userinfo.getUserId() limit 1];
		if(testTMVUsers!= null && testTMVUsers.size()==1){
			testUsersMap.put('TMV',testTMVUsers[0]);
		}		
		list<User> testTSVUsers=[Select Id,JCA__C, Employee_Id__c from User where IsActive=true and Employee_Id__c!=null and JCA__C='TSV' and Id !=:Userinfo.getUserId() limit 1];
		if(testTSVUsers!= null && testTSVUsers.size()==1){
			testUsersMap.put('TSV',testTSVUsers[0]);
		}
		list<User> testSSMUsers=[Select Id,JCA__C, Employee_Id__c from User where IsActive=true and Employee_Id__c!=null and JCA__C='SSM' and Id !=:Userinfo.getUserId() limit 1];
		if(testSSMUsers!= null && testSSMUsers.size()==1){
			testUsersMap.put('SSM',testSSMUsers[0]);
		}	
		
		//create Territory and Zip code for test user
		
		//create territory 
	
    	KCI_Territory__c testTerrTMV=new KCI_Territory__c(Name='terr-01', KCI_Legacy_Id__c='terr-001',Sales_Rep_Id__c=testUsersMap.get('TMV').employee_id__c, 
    	Territory_Code__c='TMV-test terr code',Territory_Start_Date__c=System.date.Today()-5, OwnerId=testUsersMap.get('TMV').Id);
    	KCI_Territory__c testTerrTSV=new KCI_Territory__c(Name='terr-02', KCI_Legacy_Id__c='terr-002',Sales_Rep_Id__c=testUsersMap.get('TSV').employee_id__c, 
    	Territory_Code__c='TSV-test terr code',Territory_Start_Date__c=System.date.Today()-5, OwnerId=testUsersMap.get('TSV').Id);
    	KCI_Territory__c testTerrSSM=new KCI_Territory__c(Name='terr-03', KCI_Legacy_Id__c='terr-003',Sales_Rep_Id__c=testUsersMap.get('SSM').employee_id__c, 
    	Territory_Code__c='SSM-test terr code',Territory_Start_Date__c=System.date.Today()-5, OwnerId=testUsersMap.get('SSM').Id);
    	insert new list<KCI_Territory__c>{testTerrTMV,testTerrTSV,testTerrSSM};
    	
    	
		//create zip codes
    	ZIP_Code__c testZipTMV=new ZIP_Code__c(Name='63000', KCI_Legacy_Id__c='zip-001',KCI_Territory__c=testTerrTMV.Id,Zip_Start_Date__c=System.date.Today()-5);
    	ZIP_Code__c testZipTSV=new ZIP_Code__c(Name='63000', KCI_Legacy_Id__c='zip-002',KCI_Territory__c=testTerrTSV.Id,Zip_Start_Date__c=System.date.Today()-5);
    	ZIP_Code__c testZipSSM=new ZIP_Code__c(Name='63000', KCI_Legacy_Id__c='zip-003',KCI_Territory__c=testTerrSSM.Id,Zip_Start_Date__c=System.date.Today()-5);
    	insert new list<ZIP_Code__c>{testZipTMV,testZipTSV,testZipSSM};
    
    }
}

 
Does anyone know whether the trigger.new is ordered or not? If yes, does trigger.old is the same oder of trigger.new? that is: trigger.new[0].id == trigger.old[0].id ?


Hello All, 

I recently designed a trigger to update a Goals/Forecast custom object I built called Financial_Planning__c.  Basically, on the "before update" action of the object, the trigger goes out and finds all the Closed Won opportunities for that division and updates a field on the Financial_Planning__c object.

<pre>
trigger FinancialPlanningTrigger on Financial_Planning__c (before update) {

    List<Date> dtStart =  new List<Date>();
    List<Date> dtEnd =  new List<Date>();
    List<String> strSBU =  new List<String>();
    Double fpAmount = 0 ;
String strname;

      for(Financial_Planning__c fp : trigger.new){
      dtStart.add(fp.period_start_date__c);
      dtEnd.add(fp.period_End_date__c);
      strSBU.add(fp.Division__c);
      strname = fp.division__c + ' - (' + fp.Revenue_Type__c + ')';
    }
   
List<aggregateResult> fpresults = [select Sum(amount) Total from Opportunity
               where IsWon=True
               And Contract_Start_Date__c >= :dtStart
               And Contract_Start_Date__c <= :dtEnd
               And SBU__C in :strSBU];

for (AggregateResult ar : fpresults )  {
  
    fpAmount = (Double)ar.get('Total');
}
   
      for(Financial_Planning__c fp : trigger.new){
    fp.Realized_Revenue_Actual__c =  fpamount;
    fp.name = strname; // field on which Task count and event count needs to be updated
    }
   
}
</pre>

Based on some info I heard at a developers group, I want to take the code out of the trigger and put it in a class, then have the trigger call the class?  How would I do that?  I just figured out how to create a trigger, and have not really mastered classes yet.

Hi There,

 

Currently I am working on Exact Target .

 

In our org Exact target is configured and installed.

now what i have to do is i need to find out the status of exact target opend,soft bounce and hard bounce and update on the campaign member status.

 

the problem is how to identifie the exaxct target soft bounce and hard bounce status in salesforce .

 

If any worked on the Extact target and salesforce , please tell me how to identify the soft bounce and hard bounce status in salesforce.

 

  • January 07, 2013
  • Like
  • 0
Since WI15, SFDC allow deploying changes to batch jobs while they are running
We found out today a potential problem this raises:
We added a new field to a batch process. Post deployment, SFDC threw an 'SObject row was retrieved via SOQL without querying the requested field' error.

It seems that as the batch job was running at the same time as the code was deployed, a data subset has been queried using the old code, while the processing batch used the new code

luckily for us we reprocess failed records automatically, so no real issue , but it's something worth considering when releasing batch job changes

Posting this in order to help others who, months from now, might Google "OP_WITH_INVALID_USER_TYPE_EXCEPTION" and find this explanation.

 

We wrote an Apex trigger on the User object, to insert a custom object record anytime a user updates their Chatter status.  This was done to fulfill a client's requirement to audit all Chatter activity.

 

The trigger worked fine, until one day the client signed up some Chatter Free users.  When such a user tried to update their status, they got a pop-up with an OP_WITH_INVALID_USER_TYPE_EXCEPTION error.

 

We scratched our collective heads for awhile.  After all, Apex triggers run in "system mode," right?  That is supposed to mean that "object and field-level permissions of the current user are ignored."  And yet this trigger seemed like it was running in "user mode," enforcing restrictions based on who the current user was.

 

The root cause turned out to be that a Chatter Free user cannot be the owner of a custom object record, and SFDC by default sets the current user as a new record's first owner.  We discovered this when we realized, via experiment, that Apex triggers fired as the result of actions by Chatter Free users could definitely update an existing record, but were having problems creating records.

 

So the simple solution was to explicitly set the owner of the new record to some fully-licensed user prior to inserting it.