Thursday 13 July 2017

Tricky sales force Questions 

1. How to delete the User from Salesforce
  salesforce does not allow to delete any user, however you can deactivate the user.

2.If one object in Salesforce have 2 triggers which runs “before insert”. Is there any way to control the sequence of execution of these triggers?

 Salesforce.com has documented that trigger sequence cannot be predefined. As a best practice create one trigger per object and use comment blocks to separate different logic blocks. By having all logic in one trigger you may also be able to optimize on your SOQL queries.

3.How to enable truncate custom object feature in Salesforce ?
Ans : Navigate to “App Setup | User Interface” and select “Enable Custom Object Truncate”.

Sometimes while deleting record it gives error “Object cannot be Deleted”. What is the reason for this kind of error ?

This is generic error message prompted by Salesforce many times, which is not well informative. To get informative message, we can try to delete same record in “Developer Console”. In Developer Console Debug log, we will get exact error message.

Interesting !!!

Example:
Lets say there is one record which is parent of more than 2000 records and grand parent of 5000 records. In such scenario from developer console it gives error something like “record cannot be deleted because it has many associated objects” However in User Interface, it will just display that “Object cannot be deleted."


4.Why CSS is not working in PDF created by Visualforce ?

1.Use “apex:stylesheet” tag to import external CSS file
2.Wrap “Style” tag inside “Head” tag in Visualforce
You have to cross verify the things.If you mentions these propery your css should work

5.whats Test.isRunningTest() ?
Use Test.isRunningTest() in your code to identify that context of class is Test or not. You can use this condition with OR (||) to allow test classes to enter inside code bock. It is very handy while testing for webservices, we can generate fake response easily.


                                                                                                                          Continues ...

Converting Lowercase string to Uppercase & Upper case string to Lower case

/* Here I'am converting lower case to Uppercase  */

string x='ajay';
string uppercase=x.touppercase();     //Converting string to Upper case
system.debug('uppercase ====>'+uppercase);

/* Here I'am converting Uppercase to lower case */
string y='SACHIN';
string Lowercase=y.tolowercase();
system.debug('lowercase====>'+Lowercase);

How to get all Salesforce records even from recycle bin or Achieved Activities using SOQL query?


we cannot do it directly within the Query Editor of developer console.If I run the query in query editor what will happen?!!....I hope you got the answer. But there's a workaround for we can test it  in Developer Console. The workaround is to use the "Execute Anonymous Window".

1. Open "Enter Apex Code" window by selecting "Debug" -> "Open Execute Anonymous Window" menu
2. Enter your query there and output the result to the log. Check the "Open Log" checkbox.
List<contact> clist = [SELECT name FROM contact ALL ROWS];
System.debug(JSON.serialize(clist));
3. Click "Execute" to run your code and check the log file for your result.

Special Note:
               Deleted data is stored in the Recycle Bin for 15 days.


Interesting Link:
                  https://salesforce.stackexchange.com/questions/4020/whats-the-actual-meaning-of-all-rows-in-soql