Tuesday, August 19, 2014

Links for useful bolgs

Hi All,

Here I am providing you some links of important blogs. It took my much time to find out the solution of some problems now I don't want some other to suffer with the same things. So its an effort to consolidate all the links together :

Blog on how to customize blog : 


  • How to add code snippet in your blog :     http://kasun86.blogspot.in/2011/07/posting-code-snippets-to-blogger.html
  • http://www.salesforcehacker.com/2014/06/choose-your-own-adventure-with-custom.html - custom permission

Tuesday, May 20, 2014

How Parent and Child record can be inserted in Single Statement : Use of External id field

Date dt = Date.today().addDays(7);
2Opportunity newOpportunity = new Opportunity(Name = 'shivasoft', StageName ='Prospecting', CloseDate = dt);
3
4/*
5Create the parent reference. Used only for foreign key reference  and doesn't contain any other fields. If we provide any other value it will give following error
6
7System.DmlException: Insert failed. First exception on row 1; first error: INVALID_FIELD, More than 1 field provided in an external foreign key reference in entity: Account: []
8*/
9
10Account accountReference = new Account(MyExtID__c = 'SHIVA1234567');
11newOpportunity.Account = accountReference;
12
13//  Create the Account object to insert.  Same as above but has Name field.  Used for the insert.
14Account parentAccount = new Account(Name = 'Shiva', MyExtID__c = 'SHIVA1234567');
15
16Database.SaveResult[]
17    results = Database.insert(new SObject[] {  parentAccount, newOpportunity });
Note : parent object should be included before the child object in list otherwise you will get following error : 
 INVALID_FIELD, Foreign key external ID: SHIVA1234567 not found for field  MyExtID__c  in entity Account: []

Friday, January 3, 2014

Salesforce Tips

If we remove "Modify All Data" permission from a user then there is some other permissions are also removed with this.
Ex - after removing modify all data user can not edit apex classes. Even after applying modify all data still user can not edit apex classes.

Reason : Apex Author permission is also removed from the profile when we remove Modify all data.
Solution : check Apex author checkbox on profile level then you are able to edit apex classes again.