Salesforce Developer

Salesforce Developer

Trending Questions and Lessons

Follow 3,700 Followers

Ask a Question

Feed

All

All

Lessons

Discussion

Answered on 29 Mar IT Courses/Salesforce Developer

Prabhat Bhushan

Hi, I am a Salesforce Professional working with cognizant in that role. I work as a freelance trainer with an established training institute in Sector 15, Noida. u may contact.
Answers 8 Comments 1
Dislike Bookmark

Lesson Posted on 09 Mar IT Courses/Salesforce Developer

Salesforce Certification Course

Mind Scripts Technologies

MindScripts is a leading IT training institute in Pune which has been successful in providing IT training...

Basics of Cloud Computing: Overview of each of three building blocks in cloud applications SAAS PAAS IAAS Different Cloud Service providers Salesforce Architecture: Introduction of MVC Architecture Model View Controller Feature of Salesforce Database Concepts: Overview... read more
Basics of Cloud Computing:
  • Overview of each of three building blocks in cloud applications
  •  SAAS
  •  PAAS
  • IAAS
  • Different Cloud Service providers
Salesforce Architecture:
  • Introduction of MVC Architecture
  •  Model
  •  View
  • Controller
  • Feature of Salesforce
Database Concepts:
  • Overview of Database Concepts
  • Database structure
  • Normal Database Vs. Relational Database
  • Database concept in Salesforce platform
Sales Cloud / Service Cloud:
  • Introducing the Force.com Platform
  • Understanding the basic of sales application with Standard Object
  • Understanding Service cloud
Objects and Fields:
  • Building a Simple App
  • Becoming familiar with the Force.com Setup Area
  • Introduction of Custom Objects
  • Introduction of Tabs
  • Understanding concept of Standard & custom field
  • Basics of External ID & different types of field data type
Relationships:
  • Utilizing different Types of Relationship
  • Understanding Lookup and Master-Detail relationship with Use case
  • Differentiation between One-to-Many and Many-to-Many
  • Introduction of Primary-Keys & Foreign-Keys (Conceptual Knowledge)
  • Roll-up Summary Field
  • Formula & Cross Object Formula Field
Data Management:
  • Data Management
  • Introduction to Import-Wizard
  • Use of External IDs
  • Introduction & Use of Apex Data-Loader
  • Use of different actions (Call) like Import, Update, Upsert, etc
  • Difference between Import-Wizard & Data-Loader
Security and Sharing:
  • Learn about factors to consider when designing applications for multiple users
  • Create profiles, understand what a profile controls (including data access), and customize profiles to manage the user experience
  • Create and customize permission sets to manage the user experience
  • Customize the user experience with record types and page layouts
  • Control access to records
  • Employ organization-wide defaults (OWDs), sharing rules and levels, roles, public groups, and manual share
  • Apply profiles, OWDs, role hierarchy, and sharing to restrict access to sensitive data
  • Apply OWDs, public groups, and manual sharing to create conditional access to data
  • Analyze suitability of field-level security, page layouts, types to satisfy business requirements
Validation, Workflow rules and Process Builder:
  • Business Logic Implementation
  • Rules for Automation
  • Validation Rule (Run on highest priority for the App)
  • Workflow (Time-Dependent & Time-Independent)
  • Assignment Rule
  • Auto-Response Rule (Live example with Web-to-Lead functionality) Escalation Rule
  • Introduction and use of Record Type
  • Introduction and use of Different Page-Layouts using Record-Type
  • Process Builder details overview and Use cases
Approval Process:
  • Approval Process :Single-step Approval ,Multi-steps Approval
  • Differentiation between Workflow rule & Approval process
  • Email to approve the request
  • Understanding the order of Execution of all these rules
Reports and Dashboards:
  • Report & Dashboard
  • Introduction of Types of Report
    • Tabular Report
    • Summary Report
    • Matrix Report
    • Join Report
  • Feature of the SFDC Report
  • Custom Summary Formula field
  • Bucket Filed
  • Condition High-lighting
  • Scheduling report for future run
  • Drill down to the source report while click on the graphs
  • Dashboards components
  • Dashboard Running User concept
Query Language in Salesforce:
  • Basics of SOQL & SOSL
  • Basics of Queries traversing from Child to Parent Object
  • Basics of Queries traversing from Parent to Child Object
  • Basics of Aggregate Queries
Apex & Trigger:
  • Complex Business Logic Implementation
  • Introduction of Apex
  • Implementation of Apex-Trigger
  • Understanding & Use of Trigger
VisualForce Pages:
  • Introduction of Visualforce Pages
  • Difference between Standard Controller & (Custom) Controller
Lightning Development:
  • Introduction to lightning framework
  • Creating lightning component
  • Using lightning in salesforce 1
  • Fixing performance warnings
Sites, Debug Logs:
  • Overview of other force.com capabilities
  • Different type of Sandboxes and their usage
  • Introduction of Site.Com and creation of site using it
  • Introduction of Debug Logs
Test Class:
  • Learning Apex & Deployment Tools
  • Introduction of Apex Classes
  • Invoke a class or its method via Triggers
  • Use as a Controller for a VF page
  • Introduction of test class & methods to cover Apex
Integration:
  • Integration using web service with real time business use cases.
  • One way Integration, Two-way integration
Deployment:
  • Manage Unmanaged Package
  • Uploading package with Namespace
  • Installing the package on Customer environment
 
Project:
Job Portal Management:
In the Project, students will be creating an app, helping them get a hold of the technology in its complete form. Some custom pages will be created in the project like Candidate information, Job Application details and interlink them. It will work as small job portal. The students will need to implement the project under the careful guidance of the faculty.
read less
Comments
Dislike Bookmark

Answered on 01 Mar IT Courses/Salesforce Developer

Kapavari Venkat Ramana

Salesforce Admin And Developer Real Time Trainer

1.update resume in Naukri. 2.Daily prepare. 3.Weekly twinc eattend the iNterview? 4.Avoid all mistakes 5.Daily Practice. All the best. Infinite Jobs are there, but need to do finite things Daily.
Answers 5 Comments
Dislike Bookmark

Looking for Salesforce Developer Training

Find best Salesforce Developer Training in your locality on UrbanPro.

FIND NOW

Lesson Posted on 05/08/2017 IT Courses/Salesforce Developer IT Courses/Salesforce Administrator IT Courses/IT Certifications/Salesforce Certification

What Is The Difference Between Non-Static And Static?

Kumar

I am a working professional in mnc company I have 3 years of experience in giving salesforce admin development...

By default all the variables and methods are non-static. Scope of the non-static variables or methods is within the scope of the same object. We can declare variables and methods as static by using static keyword. Scope of the static variables and methods is throughout the transaction. Static... read more

 

  • By default all the variables and methods are non-static.

  • Scope of the non-static variables or methods is within the scope of the same object.

  • We can declare variables and methods as static by using static keyword.

  • Scope of the static variables and methods is throughout the transaction.

  • Static variables and methods, we can directly call with class name (we cannot access static variables and methods with object name).

read less
Comments
Dislike Bookmark

Lesson Posted on 05/08/2017 IT Courses/Salesforce Developer IT Courses/IT Certifications/Salesforce Certification IT Courses/Salesforce Administrator

What Are The Map Methods Available In Apex?

Kumar

I am a working professional in mnc company I have 3 years of experience in giving salesforce admin development...

//Map holds key and value pair. //Syntax: Map mapName = new Map(); /*Map countryISTCodeMap = new Map(); countryISTCodeMap.put('India','91'); countryISTCodeMap.put('USA','001'); countryISTCodeMap.put('India','911');//replaces old value with new value.*/ Map countryISTCodeMap = new Map{'India'=>'91','USA'=>'001',... read more

//Map holds key and value pair.

//Syntax: Map mapName = new Map();

/*Map countryISTCodeMap = new Map();

countryISTCodeMap.put('India','91');

countryISTCodeMap.put('USA','001');

countryISTCodeMap.put('India','911');//replaces old value with new value.*/

Map countryISTCodeMap = new Map{'India'=>'91','USA'=>'001', 'India'=>'911'};

system.debug('countryISTCodeMap result: '+countryISTCodeMap+' with size '+countryISTCodeMap.size());

system.debug('countryISTCodeMap keys: '+countryISTCodeMap.keyset());

system.debug('countryISTCodeMap values: '+countryISTCodeMap.values());

system.debug('countryISTCodeMap search: '+countryISTCodeMap.containsKey('India'));

system.debug('countryISTCodeMap fetching value based on key: '+countryISTCodeMap.get('India'));

//map keys are case-sensitive.

keyset(): To fetch only keys from the map.

values(): To fetch only values from the map.

containsKey(value): To search a key from the map.

get(key): By supplying the key we can fetch the value.

put(key,value): To add key and value in a map.

read less
Comments
Dislike Bookmark

Answered on 18/07/2017 IT Courses/Salesforce Developer

Ritesh Kumar Singh

Tutor

Yes. SalesForce has a very good future at least for next 10 yrs. You will get a lot of opportunities as a SalesForce professional. There is not much SFDC professional available right now. Also, being a Java professional you will get added advantage while learning SalesForce.
Answers 6 Comments
Dislike Bookmark

Looking for Salesforce Developer Training

Find best Salesforce Developer Training in your locality on UrbanPro.

FIND NOW

Lesson Posted on 27/04/2017 IT Courses/Salesforce Developer

Trigger Best Practices

Rajiv

Triggers - Best Practices in Salesforce 1. Future methods, SOQL and DML: Avoid writing Future methods, SOQL and DML inside the "For" loop.2. Bulkify the trigger: Start developing the logic for the bulk of records getting inserted or updated or deleted. The trigger will be invoked when we... read more

Triggers - Best Practices in Salesforce

 
1. Future methods, SOQL and DML:

    Avoid writing Future methods, SOQL and DML inside the "For" loop.

2. Bulkify the trigger:

    Start developing the logic for the bulk of records getting inserted or updated or deleted. The trigger will be invoked when we insert bulk of records from any data loading tools or through Web services. So, we should not concentrate on 1 record, we have to concentrate on the bulk of records.

3. Larger sets of records:

    Use SOQL in For loop, to avoid 50001 limit error.

Account[] accts = [SELECT id FROM account];

Exception will be thrown, if there are more than 50000 records.

for (List<Account> acct : [SELECT id, name FROM account WHERE name LIKE 'Test']) {

    // Your logic here

    update acct;
}

The Force.com platform chunk your large query results into batches of 200 records by using this syntax where the SOQL query is in the for loop definition, and then handle the individual datasets in the for loop logic.

4. Make use of the Limits Apex Methods to check whether we are nearing Governor Limits.

Number of SOQL Queries allowed in this Apex code context - Limits.getLimitQueries()

Number of records that can be queried  in this Apex code context - Limits.getLimitDmlRows()

Number of DML statements allowed in this Apex code context - Limits.getLimitDmlStatements()

Number of CPU usage time (in ms) allowed in this Apex code context - Limits.getLimitCpuTime()

5. Never hardcode SFDC record ids.

Cheers!!!
read less
Comments
Dislike Bookmark

Lesson Posted on 15/12/2016 IT Courses/Salesforce Developer

Trigger Sceniors

Suresh Kumar Tavva

Trigger Scenarios:- (Prepared By Suresh Kumar tvs) Scenario one:- (All Opportunity Triggers) //Trigger to display error message when stage name is change from 'Order closed' to other values Part one 1 (While trigger.old) :- if(Trigger.isupdate && Trigger.isBefore){ for(Opportunity... read more

Trigger Scenarios:- (Prepared By Suresh Kumar tvs)

Scenario one:-  (All Opportunity Triggers)

//Trigger to display error message when stage name is change from 'Order closed' to other values

Part one 1 (While trigger.old) :- 

if(Trigger.isupdate && Trigger.isBefore){

          for(Opportunity oldOpportunity:trigger.old){

             if(oldOpportunity.StageName == 'Order Closed'){

                  trigger.new[0].addError('An Opportunity cannot be edited once the opportunity stage is Order Closed');

             }

          }

Part 2(While Trigger.new):-

if(Trigger.isupdate && Trigger.isBefore){

set<id> opplistid=new set<id>();

                for(Opportunity newopportunity:Trigger.new){

                    opplistid.add(newopportunity.id);

                }

                list<Quote> Qlist = [select OpportunityId,Customization_Payment_Criteria__c,Approval_Status_Quote__c from Quote where OpportunityId=:opplistid];

                for(Opportunity newopportunity: Trigger.new){

                 Opportunity old=trigger.oldmap.get(newopportunity.Id);

                    if(newopportunity.Record_Type_Name__c=='Watches' || newopportunity.Record_Type_Name__c=='Jewellery'||newopportunity.Record_Type_Name__c=='Lifestyle'){

                        if((old.StageName != newopportunity.StageName)){

                            for(Quote qq:Qlist){

                                if(qq.OpportunityId==newopportunity.id && qq.Customization_Payment_Criteria__c =='Free Of Cost' && qq.Approval_Status_Quote__c!='Approved'){

                                    newopportunity.addError('cannot change Stage as Quote Customization Payment Criteria is Free of cost and quote is not approved');

                                }

                            }

                        }

                    }

                }

     }

Scenario Two:-

//Trigger on checking attachment size and displaying error for different Record type

if(Trigger.isAfter && Trigger.isupdate){

        set<id> oppId=new set<id>();

        for(Opportunity newopportunity:Trigger.new){

            oppId.add(newopportunity.id);

        }

        Integer Vattachmentcount = 0;       

        Integer Invoicecount = 0; 

            List<Attachment> ca = [Select id,Name from Attachment where  ParentId=:oppId limit 99];

            for(Integer i=0;i<ca.size();i++){

                if(ca[i].Name.indexOfIgnoreCase('validated')>=0 ){

                    Vattachmentcount++;

                }

                if(ca[i].Name.indexOfIgnoreCase('invoice')>=0 ){

                    Invoicecount++;

                }

            }

        for(Opportunity newOpportunity:Trigger.new){

            if(newOpportunity.Record_Type_Name__c == 'Jewellery' && newOppor

tunity.Customization_Status__c == 'Validated' && (newOpportunity.StageName == 'Proforma Invoice'||newOpportunity.StageName == 'Received PO/Order Won' ||newOpportunity.StageName == 'Payment/Delivery' ||newOpportunity.StageName == 'Order Closed' )&& Vattachmentcount == 0){

                newOpportunity.addError('Please upload the appropriate file with the keyword "validated" included within the file name');

            }

            if((newOpportunity.Record_Type_Name__c == 'Lifestyle' || newOpportunity.Record_Type_Name__c == 'Watches') && newOpportunity.Customization_Status__c == 'Validated' && (newOpportunity.StageName == 'Proforma Invoice'||newOpportunity.StageName == 'Received PO/Order Won' ||newOpportunity.StageName == 'Payment/Delivery' ||newOpportunity.StageName == 'Order Closed' ) && Vattachmentcount == 0){

                newOpportunity.addError('Please upload the appropriate file with the keyword "validated" included within the file name');

            }

            if(newOpportunity.Delivery_Status__c == 'Completed' && newOpportunity.StageName == 'Payment/Delivery' && Invoicecount == 0){

                newOpportunity.addError('Please upload the appropriate file with the keyword "Invoice" included within the file name');

            }

        }

    } 

}

read less
Comments
Dislike Bookmark

Lesson Posted on 15/12/2016 IT Courses/Salesforce Developer

Trigger Sceniors - session 2

Suresh Kumar Tavva

Scenario3:- // Amount In Words before Insert, before update for(Quote qu : Trigger.New) { if(qu.amount_in_words__c!=null) { qu.Converted_Amount_In_Words__c = ConvertRupees.ConvertFun((qu.amount_in_words__c)); }} Scenario 4:- // Attachment in child (Attachment Is an object in... read more

Scenario3:-

// Amount In Words

before Insert, before update

for(Quote qu : Trigger.New)

{

    if(qu.amount_in_words__c!=null) {

    qu.Converted_Amount_In_Words__c  = ConvertRupees.ConvertFun((qu.amount_in_words__c));

    }}

Scenario 4:-

// Attachment in child     (Attachment Is an object in salesforce)

before Insert, before update

set<id> Oppid =new set<id>();

        for(Opportunity O : Trigger.new)

            {

            if(o.Record_Type_Name__c != 'Jewellery' && o.Record_Type_Name__c != 'Lifestyle' && o.Record_Type_Name__c != 'Watches')

                Oppid.add(O.id);

            }

List<Attachment> ca = [Select id from Attachment where  ParentId=:Oppid];

        for(Opportunity O: Trigger.new)

            {

             if(o.Record_Type_Name__c != 'Jewellery' && o.Record_Type_Name__c != 'Lifestyle' && o.Record_Type_Name__c != 'Watches')

                O.Total_No_of_Attachment__c = ca.size();

            }

Scerino 4:-

// NumberToWords ( Two objects Quote and QuoteLineitem)

before Insert, before update

If(TriggerMonitor.ExecutedTriggers.contains('NumberToWords'))

        return;

    TriggerMonitor.ExecutedTriggers.add('NumberToWords');

for(Quote qu:Trigger.New)

{

     if(qu.Quote_Currency__c!='INR')

     {

          if(qu.amount_in_words__c!=null)

        {

                   qu.Amount_converted_Words__c  =  EnglishNumberToWords.convert((qu.amount_in_words__c));

            qu.New_Total_Amount_in_Words__c=qu.Quote_Currency__c +' '+' '+ qu.Amount_converted_Words__c;

        }

        }

        else

        {

         if(qu.amount_in_words__c!=null)

        {

            qu.Amount_converted_Words__c  = ConvertRupees.ConvertFun((qu.amount_in_words__c));

            qu.New_Total_Amount_in_Words__c = qu.Quote_Currency__c +' '+' '+ qu.Amount_converted_Words__c;

        }

        }

Set<String> product_cat=new Set<String>();

       for(Integer j = 0; j < LN.size(); j++){

                //system.debug('PROOOOOOOOOOOOO'+cd[j].Product_Categeory__c);

               

                product_cat.add(LN[j].PricebookEntry.Product2.Product_Category__c);

              

            }

            system.debug('No of category...'+product_cat.size());

            system.debug('Name of category...'+product_cat);

            if(product_cat.size()<2 && product_cat.size()>0 )

            {

              List<Contract_Details__c> cd=[select id,Discount__c,Valid_From__c,Valid_To__c,Brand__c,Value_From__c,Value_To__c from Contract_Details__c

                where Contract_Number__c =: qu.Contract_Number__c and Brand__c=: LN[0].PricebookEntry.Product2.Product_Category__c

                         ];

                           

              system.debug('No of category...'+product_cat.size());

             for(Integer j = 0; j < cd.size(); j++){

             if(qu.Sent_to_Approval__c == false){

            if(qu.Discount_Corp__c <= cd[j].Discount__c){

                       system.debug('Valid Discount');

              

              if(qu.Price_After_Discount__c >= cd[j].Value_From__c && qu.Price_After_Discount__c <= cd[j].Value_To__c){

                       system.debug('Valid Values');

                     

                   if(qu.CreatedDate >= cd[j].Valid_From__c && qu.CreatedDate <= cd[j].Valid_To__c){

                       system.debug('valid date range');

                     

                       qu.Approval_Status_count_LineItem__c =' ';

                       qu.Approval_Status_Quote__c ='Approved';

                       qu.Quote_Status_watches_new__c =' ';

                       qu.Approved_QuoteLineItem__c = qu.Total_No_of_QuoteLineItem__c;

                       break;

                                     

                   } else{

                   qu.Approval_Status_count_LineItem__c ='Approval Required';

                   qu.Approval_Status_Quote__c ='Approval Required';

                   qu.Quote_Status_watches_new__c ='Approval Required';

               }

               } else{

                   qu.Approval_Status_count_LineItem__c ='Approval Required';

                   qu.Approval_Status_Quote__c ='Approval Required';

                   qu.Quote_Status_watches_new__c ='Approval Required';

               }

               }

               

                 else{

                   qu.Approval_Status_count_LineItem__c ='Approval Required';

                   qu.Approval_Status_Quote__c ='Approval Required';

                   qu.Quote_Status_watches_new__c ='Approval Required';

               }

               }

               }

            }

Scerino  5:-

//OpportunitySharingRule

After Update, After Insert

List<OpportunityShare> oppShareList = new List<OpportunityShare>();

    for(Opportunity o:Trigger.New) {

    if(o.Record_Type_Name__c != 'Jewellery' && o.Record_Type_Name__c != 'Lifestyle' && o.Record_Type_Name__c != 'Watches')

    {

        if(o.Member2__c != NULL) {

            OpportunityShare OppShare = New OpportunityShare (OpportunityId=O.Id,                                               

                                                  UserOrGroupId =O.Member2__c ,                                             

                                                  OpportunityAccessLevel = 'Edit'

                                                  );

            oppShareList.add(OppShare);

        }

    }}

    if(oppShareList.size() > 0 ) {

        insert oppShareList;

    }

Scerino 4:-

before insert, before update

//owner change (Opportunity Object)

List<RecordType> rtypes = [Select Name, Id From RecordType where sObjectType='Opportunity' and isActive=true];

        Map<String,String> Opprectype = new Map<String,String>{};

       

        for(RecordType rt: rtypes)

            {

                Opprectype.put(rt.Name,rt.Id);

            }

           

   

        List<User> Userlist = [Select Name, Id From User where  isActive=true];

        Map<String,String> Usermap = new Map<String,String>{};

        for(User u: Userlist)

            {

                Usermap.put(u.Name,u.Id);

            }

        for(Opportunity opp : Trigger.New)

            {

            if(opp.Record_Type_Name__c != 'Jewellery' && opp.Record_Type_Name__c != 'Lifestyle' && opp.Record_Type_Name__c != 'Watches')

            {

            {

                if(Trigger.isUpdate)

                    {

                        if(opp.CreatedDate.date() >= date.newInstance(2012, 2, 7))

                        {

&nb read less

Comments
Dislike Bookmark

Looking for Salesforce Developer Training

Find best Salesforce Developer Training in your locality on UrbanPro.

FIND NOW

Lesson Posted on 15/12/2016 IT Courses/Salesforce Developer

Trigger Sceniors - session 3

Suresh Kumar Tavva

Scenario 7:- //Checking the model number with the existence values while inserting or updating before insert,before update //Variable Declaration List<Product__c> allProducts = new List<Product__c>(); map<string,id> nameMap = new map<string,id>(); set<String>... read more

Scenario 7:-

//Checking the model number with the existence values while inserting or updating

before insert,before update

//Variable Declaration

    List<Product__c> allProducts = new List<Product__c>();

    map<string,id>  nameMap = new map<string,id>();

    set<String> productNameSet = new Set<String>();

    for(Product__c  prdEach:trigger.new){

        productNameSet.add(prdEach.name);

    }

   

    //Retrieving all the product records

    try{

        allProducts=[select Name,id from  Product__c where name in:productNameSet limit 50000];

    }Catch(Exception exep){

        System.debug('****Exception*****'+exep);

    }

   

    for(product__c prd:allProducts){

            nameMap.put(prd.name.toUppercase(),prd.id);   

        }

   

    //Iterating The list of all products and Identifying the Duplicates. If the Duplicates are existed Display the error message.

   

    for(Product__c newprd:trigger.new){

   

        if(nameMap.containsKey(newprd.name.toUppercase()) && (trigger.isinsert||(trigger.isupdate && nameMap.get(newprd.name.toUppercase())!=null&&nameMap.get(newprd.name.toUppercase())!=newprd.id))){

           

                newprd.name.adderror('The model is Already existed');

              

        }

   }

Scenario 8:-

//QtValueAfterCust

After update

if (!RecurciveTrigger.hasAlreadyCreatedFollowUpTasks()) {

    set<id> qid=new set<id>();

    for(quote q:trigger.new){

        if(q.Free_of_cost_Approved__c==true && q.Record_Type_Name__c == 'Jewellery'){

            qid.add(q.ID);

        }

    }

    List<QuoteLineItem> updatelineItem =new List<QuoteLineItem>();

    if(!qid.isempty()){

    

        for(QuoteLineItem qtl1:[select id,Sales_Price_c__c,QuoteId,TotalPrice from QuoteLineItem where QuoteId=:qid and Extra_Charges__c ='true' ]){

            qtl1.Sales_Price_c__c=0;

            qtl1.UnitPrice=0;

            updatelineItem.add(qtl1);

       

        }

      }

      RecurciveTrigger.setAlreadyCreatedFollowUpTasks();

        if(!updatelineItem.isempty())

        update updatelineItem;

        }

Scenario 8:-

// Can  not  delete an approved Quote

before delete

List<profile> pp = [Select Name From Profile  where Id = :UserInfo.getProfileId()];

   for(Quote q:trigger.old)

   {

  if(q.Opportunity.Record_Type_Name__c  != 'Jewellery' && q.Opportunity.Record_Type_Name__c != 'Lifestyle' && q.Opportunity.Record_Type_Name__c != 'Watches')

      {

   if(q.Approval_Status__c == 'Approved' && pp[0].name!='System Administrator'){

  

   q.addError('Can not delete an approved Quote');

   }

   }

Scenario 9:-

//QuoteLineItemBeforeInsetUpdate

after insert,after update,after delete

public static boolean flag = true;

    if(flag == true)

    {

        //added

        flag = false;

        Set<id> quotId = new Set<Id>();

        Decimal Sum = 0;

        Decimal optionalSum = 0;

        if(trigger.isInsert || trigger.isUpdate){

            for(Quote_Items__c q: trigger.new){

                quotId.add(q.Quote__c);

            }

        }

        if(trigger.isDelete){

            for(Quote_Items__c q: trigger.old){

                quotId.add(q.Quote__c);

            }

        }

        List<Quote_Items__c> LineItem =new List<Quote_Items__c>();

         List<Quote> QoutlIst =new List<Quote>();

        if(!Test.isRunningTest()){

                         LineItem = [Select id,Total_Value__c,Optional__c from Quote_Items__c Where Quote__c IN: quotId ];

                         QoutlIst = [Select id,Total_Value_PECSA_new__c,Opportunity.Amount,opportunityId from Quote where id In: quotId ];

        }

        list<opportunity> opplist = new list<opportunity> ();

        for(Quote_Items__c q : LineItem){

            if(q.Optional__c == true){

                optionalSum = optionalSum + q.Total_Value__c;  

                system.debug('+++++++++++++++optionalSum : '+optionalSum );

            }

            sum = sum + q.Total_Value__c;

            system.debug('+++++++++++++++sum : '+sum );

        }

        for(Quote q : QoutlIst){

            if(optionalSum != 0){

                q.Total_Value_PECSA_new__c = optionalSum;

                q.Opportunity.amount =q.Total_Value_PECSA_new__c;

                system.debug('+++++++++++++++q.Opportunity.amount : '+q.Opportunity.amount);

                opportunity obj = new opportunity(id =q.opportunityId,Amount =q.Opportunity.amount );

                opplist.add(obj);

               

            } 

            else{

                q.Total_Value_PECSA_new__c = Sum;

              q.Opportunity.Amount  =q.Total_Value_PECSA_new__c;

              opportunity obj = new opportunity(id =q.opportunityId,Amount =q.Opportunity.amount );

                opplist.add(obj);

            } 

        }

        

        Update QoutlIst;   

        system.debug('+++++++++++++++opplist: '+opplist);

        if(opplist.size()>0){

            update opplist;

        }

        //added

        //flag = true;

   }

 

read less
Comments
Dislike Bookmark

About UrbanPro

UrbanPro.com helps you to connect with the best Salesforce Developer Training in India. Post Your Requirement today and get connected.

Overview

Lessons 25

Total Shares  

Top Contributors

Connect with Expert Tutors & Institutes for Salesforce Developer

x

Ask a Question

Please enter your Question

Please select a Tag

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more