Click to publicize, if you like this article :
40. What is Master Detail relationship and look up relationship in Salesforce?
Master Detail relationship is the Parent child relationship. In which Master represents Parent and detail represents Child. If Parent is deleted then Child also gets deleted. Rollup summary fields can only be created on Master records which will calculate the SUM, AVG, MIN of the Child records.
Look up relationship is something like “has-a” (Containership) relationship. Where one record has reference to other records. When one record is deleted then there is no impact on other records.
41. Can we convert the lookup relationship to Master Detail relationship?
We can convert the lookup relationship to master detail relationship if and only if all the existing record has valid lookup field.
42. In How many way we can invoke the Apex class?
- Visualforce page
- Web Services
- Email Services
43. Can we create Master Detail relationship on existing records?
No. As discussed above, first we have to create the lookup relationship then populate the value on all existing record and then convert it.
44. How validation rules executed? is it page layout / Visualforce dependent?
The validation rules run at the data model level, so they are not affected by the UI. Any record that is saved in Salesforce will run through the validation rules.
45. What is the difference between database.insert and insert ?
insert is the DML statement which is same as databse.insert. However, database.insert gives more flexibility like rollback, default assignment rules etc. we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions)
- If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop and Apex code throws an error which can be handled in try catch block.
- If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML operation will be done.
46. What is the scope of static variable ?
When you declare a method or variable as static, it’s initialized only once when a class is loaded. Static variables aren’t transmitted as part of the view state for a Visualforce page.
Static variables are only static within the scope of the request. They are not static across the server, or across the entire organization.
47. Other than SOQL and SOSL what is other way to get custom settings?
Other than SOQL or SOSL, Custom seting have there own set of methods to access the record.
For example : if there is custom setting of name ISO_Country,
SO_Country__c code = ISO_Country__c.getInstance(‘INDIA’); //To return a map of data sets defined for the custom object (all records in the custom object), //you would use: Map<String,ISO_Country__c> mapCodes = ISO_Country__c.getAll(); // display the ISO code for India System.debug(‘ISO Code: ‘+mapCodes.get(‘INDIA’).ISO_Code__c); //Alternatively you can return the map as a list: List<String> listCodes = ISO_Country__c.getAll().values();
48. What happen if child have two master records and one is deleted?
Child record will be deleted.
49. What is Difference in render, rerender and renderas attributes of visualforce?
render – It works like “display” property of CSS. Used to show or hide element.
rerender – After Ajax which component should be refreshed – available on commandlink, commandbutton, actionsupport etc.
renderas – render page as pdf, doc and excel.
50. What is Scheduler class in Apex?
The Apex class which is programed to run at pre defined interval.
Class must implement schedulable interface and it contains method named execute().
There are two ways to invoke schedular :
- Using UI
- Using System.schedule
The class which implements interface schedulable get the button texted with “Schedule”, when user clicks on that button, new interface opens to schedule the classes which implements that interface.
To see what happened to scheduled job, go to “Monitoring | Scheduled jobs “
Example of scheduling :
scheduledMerge m = new scheduledMerge(); String sch = '20 30 8 10 2 ?'; system.schedule('Merge Job', sch, m);
To see how to make crone job string – refer this URL.