Skip to main content

seller is custom object and product2  is standard object and product field is custom field like quantity__c showing error inside if condition then please help to solve this problem......

trigger SendEmailLessThan10Product on Seller__c (after insert , after update) {

    // Step 0: Create a master list to hold the emails we'll send

    List<Messaging.SingleEmailMessage> mails = 

        new List<Messaging.SingleEmailMessage>();

    

    for (Seller__c seller : Trigger.new) {

        if (seller.Product2.Quantity__c <= 10 ) {

            // Step 1: Create a new Email

            Messaging.SingleEmailMessage mail = 

                new Messaging.SingleEmailMessage();

            

            // Step 2: Set list of people who should get the email

            List<String> sendTo = new List<String>();

            sendTo.add(seller.Name);

            mail.setToAddresses(sendTo);

            

            // Step 3: Set who the email is sent from

            mail.setReplyTo('yessboss@gmail.com');

            mail.setSenderDisplayName('product manager');

            

            // (Optional) Set list of people who should be CC'ed

            List<String> ccTo = new List<String>();

            ccTo.add('noboss@gmail.com');

            mail.setCcAddresses(ccTo);

            

            // Step 4. Set email contents - you can use variables!

            mail.setSubject('URGENT BUSINESS PROPOSAL');

            String body = 'Dear ' + seller.Name + ', ';

            body += 'Please Increase the quantity of product '+Name+ ' , quantity is '+Quantity__c;

            body += 'Catogery :' +Catogery__c;

            body += 'Product Type :' +Product_Type__c;

            body += 'Price :' +Price__c;

        }

        // Step 6: Send all emails in the master list

        Messaging.sendEmail(mails);

        

    }

}

1 条评论
0/9000