Salesforce Interview Questions – Part 5

Get articles everyday as a email directly to your inbox:
Click to publicize, if you like this article :


40. What is Master Detail relationship and look up relationship in Salesforce?
Ans:
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?
Ans:
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?
Ans:

  1. Visualforce page
  2. Trigger
  3. Web Services
  4. Email Services

43. Can we create Master Detail relationship on existing records?
Ans:
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?
Ans :
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 ?
Ans:
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)
Important Difference:

  • 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 ?
Ans:
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?
Ans:
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?
Ans :
Child record will be deleted.

read more in this article.


49. What is Difference in render, rerender and renderas attributes of visualforce?
Ans:
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?
Ans:
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 :

  1. Using UI
  2. 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.


You can leave a response, or trackback from your own site.
  • Mitul

    40. What is Master Detail relationship and look up relationship in Salesforce?
    Ans:

    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.

    In Master Detail relationship we can not calculate AVG.

  • Nurzum

    Great Posts on Salesforce, keep up the good work! :)

  • Jcharugundla

    How to write the error messages in the Triggers

    • JitendraZaa

      using objectName.addError(‘Your message here’);

  • Sai

    how to download these parts

    • JitendraZaa

      You cant!!!

      • Anonymous

        Hi Jitendra, My requirement is I have to do integration of salesforce with third party which is having REST API. This is kind of POC. I want to update accounts created in salesforce to be in the third party. Can you guide me ?

  • Anilvelaga555

    Can i delete the child records if the parent is deleted but relationship should be a Lookup relationship…is there any way ..please let me know

    Thanks in Advance

    • Chekuri Nari

       yes u can…. think well it’s very easy logic

    • Prakash Jain

      Use Isdelete Trigger and delete the lookup record in the Trigger!

  • Krk127487

    Hi ,
    This is ram. I am new to salesforce.I have good knowledge on java programming.Can we get other class reference in apex class with out using inner class(like in java new class reference or object by importing packages).

    Thanks for advance help.
    Thanks
    Ram

    • JitendraZaa

      Hi Ram,
      You can have access to other class like JAVA in Apex also.

      • Krk12787

        thanks for your response.
        how can i declare   packages , i am getting error .plz give any sample code  or any referece link

        • JitendraZaa

          You cannot declare package at class level in Apex

          • Krk12787

            thank you…………..

            How to import another class and another class fieds ,methods in our current class and how to access
            plz………
             give me sample code

    • Krk12787

      thanks for your response.

      how can i declare   packages , i am getting error .
      plz give any sample code  or any referece link

  • Pingback: Latest Salesforce Interview Questions - Part 6 | Shiva Blog

  • Manohar

    Difference between External ID and Unique ID?

  • Rare nick

    implementing functionality like Copy Billing Address to Shipping Address in accounts 

    Is it possible to implement  a functionality ????like Copy Billing Address to Shipping Address link (which is avilable in account object Address Information pageblock )  in my custom object

  • Vinayhnk60

    need more faqs…plzzzzzzzzzz

    • JitendraZaa

      Part6 added. Soon 7 will be released.

      • Rare nick

        subject:implementing functionality like Copy Billing Address to Shipping Address in accounts 
        Is it possible to implement  a functionality ????like Copy Billing Address to Shipping Address link (which is avilable in account object Address Information pageblock )  in my custom object

        • JitendraZaa

          Sure, But you will need to develop Custom Visual force page for your custom object. Javascript may be used here.

          • Nivasonline4u

            HI jitendra you have said previously that we dont need to have coding knowledge but as i have seen poeple asking you questions regarding methods, triggers and functions and OOPS concepts. so please help me as i am MBA graduate without any programming knowledge do u suggest me to learn this course.

          • JitendraZaa

            Hi, The salesforce is Big product. There are two career path here :
            1. Admin and Consultants
            2. Developers and Architects

            As you are MBA student you can choose first one.

          • manoj

            thanks Jitendra,please send me some useful document in my mail id mpmanojdas3@gmail.com
            I am a tecnical student and i chose the 2nd carrier path.please help me sir.

  • Pingback: Salesforce Interview Questions – Part 2 | Shiva Blog