CRM system Salesforce Customer Bill Trigger

Source: Internet
Author: User
Trigger Accountbilltrigger on Account__c (after update,after insert) {Account__c bill = trigger.new[0]; The payment method in the service order is not in cash, and the service order produces a receivable, and the status of the receivable is not clear, and the receivable after the production of a week still no receivables tracking record if (bill.createweek__c== ' 1 ' &&bill.statue__ c== ' not cleared ') {if (bill.servicenumber__c!=null) {customerservicelist__c cusser =[select id,name,paymentmeth
            Od__c,createdbyid from Customerservicelist__c WHERE Id=:bill.servicenumber__c];
            System.debug (' Cusser: ' +cusser); if (cusser.paymentmethod__c!= ' cash ') {list<debtrecord__c> deb =[select ID from Debtrecord__c WHERE ser
                Vicenumber__c=:bill.servicenumber__c]; if (Deb.size () ==0) {String msg = ' +cusser.name+ ' service order generated receivables by the end of the week there is no Dunning records, please prompt and follow up the situation recorded in the system, thank you.
                    ';
                    Chattersender.send (cusser.createdbyid,msg,cusser.id);
                    User U=[select Phone from user WHERE Id=:cusser.createdbyid];
          Sms.dofuturesend (U.PHONE,MSG);      }}}}else if (bill.createweek__c== ' 2 ' &&bill.statue__c== ' not cleared ') {if (Bill.serv Icenumber__c!=null) {Customerservicelist__c cusser =[select Id,name,paymentmethod__c,createdbyid from Customer
            Servicelist__c WHERE Id=:bill.servicenumber__c];
            System.debug (' Cusser: ' +cusser); if (cusser.paymentmethod__c!= ' cash ') {list<debtrecord__c> deb =[select ID from Debtrecord__c WHERE ser
                Vicenumber__c=:bill.servicenumber__c]; if (Deb.size () <2) {String msg = ' +cusser.name+ ' service order generated receivables by the end of two weeks, but did not meet the requirements of the company two weeks followed by two times the system, please prompt and will follow up the situation in mind Recorded in the system, thank you.
                    ';
                    Chattersender.send (cusser.createdbyid,msg,cusser.id);
                    User U=[select Phone from user WHERE Id=:cusser.createdbyid];
                Sms.dofuturesend (U.PHONE,MSG); }}}//Cash more than 7 days without emptying reminder technician if (bill.remind__c==true&&trigger.old[0].remind__c!=True) {if (bill.servicenumber__c!=null) {customerservicelist__c cus=[select Id,name,createdbyid from CU
            Stomerservicelist__c WHERE Id=:bill.servicenumber__c]; User U=[select Phone from user WHERE Id=:cus.
            Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list for cash collection, currently more than seven days of outstanding, please timely payment to the financial to write off, thank you.
            ';
        Sms.dofuturesend (U.PHONE,MSG); }//Cash more than 4000 remind technician if (bill.statue__c== ' &&bill.price3__c>=4000) {if (Bill.servicenu Mber__c!=null) {Customerservicelist__c cus=[select id,name,createdbyid,paymentmethod__c from Customerserviceli
            St__c WHERE Id=:bill.servicenumber__c];
                if (cus.paymentmethod__c== ' cash ') {Boolean issendsms = true;
                if (trigger.isinsert) {issendsms = true; } if (trigger.isupdate) {if (trigger.old[0].statue__c== ' not cleared ' &&trigger.old[0].pri
                 ce3__c>=4000) {       issendsms = false;//update will not relapse SMS}} if (Issendsms) { User U=[select Phone from user WHERE Id=:cus.
                    Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list for cash collection and the amount of payment to meet 4000, please timely make money to the financial verification, thank you.
                    ';
                Sms.dofuturesend (U.PHONE,MSG);
        }}}}//Receivables and reminders (30 days) if (bill.dealline1__c&&bill.dealline1__c!=true) { if (bill.servicenumber__c!=null) {Customerservicelist__c cus=[select Id,name,createdbyid from Customerservic
            Elist__c WHERE Id=:bill.servicenumber__c]; User U=[select Phone from user WHERE Id=:cus.
            Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list of receivables generated by the current 30 days have not been cleared, please prompt, thank you.
            ';
        Sms.dofuturesend (U.PHONE,MSG); }}//Receivables and reminders (50 days) if (bill.deadline2__c&&bill.deadline2__c!=true) {if (bill.servicenumber__c!= NULL) {Customerservicelist__c cus=[sElect Id,name,createdbyid from Customerservicelist__c WHERE Id=:bill.servicenumber__c]; User U=[select Phone from user WHERE Id=:cus.
            Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list of receivables generated by the current 50 days have not been cleared, please prompt, thank you.
            ';
        Sms.dofuturesend (U.PHONE,MSG); }}//Receivables and reminders (70 days) if (bill.deadline3__c&&bill.deadline3__c!=true) {if (bill.servicenumber__c!= NULL) {Customerservicelist__c cus=[select Id,name,createdbyid from Customerservicelist__c WHERE Id=:bill.servi
            Cenumber__c]; User U=[select Phone from user WHERE Id=:cus.
            Createdbyid]; String msg= ' number is: ' +cus. Name+ ' Service list of receivables generated by the current 70 days have not been cleared, please prompt, thank you.
            ';
        Sms.dofuturesend (U.PHONE,MSG); } 
    }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.