• maddy27
  • NEWBIE
  • 45 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 24
    Replies
Hi,
Can someone help how can i find when the records were created in DE through sync.
We have dynamic CRM where it is conencted to Salesforce marketing cloud , and through automation it picks up the data from DE.
how can i know when the records are dumped into marketing cloud.
thanks
Hi,

I'm trying to create records for Work Order where it will create multiple work order line item based on Parent Work Type and Child Work Type.
Please help me, stuck!

This logic is already creating Parent Work type - WOLI
But i have to create Chid Work Type - WOLI
Work Order
Hi ,

I have 2000 lines of code -

this is one of the methods and condition for but irs not covering the code.
 
public static Boolean validateStreet(string name) {
        Boolean flag = true;
        if(Site.getName() != NULL && Site.getName() != '') {
          return flag;
        }
        if (util.nullCheck(name)) {
            //updated by DYU 04-15-2015 - Update pattern to include "_" for matching
            //String patternName = '([a-zA-Z0-9\\-&\' ]+)';
            String patternName = '([a-zA-Z0-9_\\-&\' ]+)';
            Pattern namePattern = Pattern.compile(patternName);

            Matcher nameMatcher = namePattern.matcher(name.trim());
            flag = nameMatcher.matches();
            
        }
        return flag;
    }
 
Boolean validationResult = true;
     System.debug('***Applicant:' + applicant);
        if (applicant.Title__c == 'Select') {
            this.errorTitle = true;
            this.errorTitleMsg = 'Error: Please select your title.';
            validationResult = false;
        }

 
I have business requirement for for validating email address and confirm email address.
I used jquery to validate both the fields and created confirmEmail adress on wrapper class.
There are 2 applicants in one page, it is working correctly for applicant 1 but when i move to tab applicant 2, confirm email value disappears.
Please help.
Thanks
 
<div class="{!if($site.Name!='Aussie', 'span12', 'span6')} removelmargin lfsTextInputXLge input100pct">
                    <label class="removelmargin labeldark">Email address</label><br />
                    <apex:inputText value="{!applicantWrapper.applicant.Email_Address__c}" onfocus="checkPhoneNumbersOnEmail()" id="Applicant__c___Email_Address__c"
                                    html-onpaste="return false;"
                                    styleClass="input-block-level isMaxLength40 marginbottom10 {!IF(applicantNo==2,'isEmail2','isEmail')}  " />
                    <div class="clearfix"></div>
                    <apex:outputText rendered="{!applicantWrapper.errorEmail}" value="{!applicantWrapper.errorEmailMsg}" styleClass="warningMessage" />
                    <apex:outputText rendered="{!brokerchannel}" value="Please make sure to enter customer's email address." styleClass="warningMessage" />
                </div>
              
       
              
               <div class="{!if($site.Name!='Aussie', 'span12', 'span6')} removelmargin lfsTextInputXLge input100pct" id="result" >                   
                    <label class="removelmargin labeldark">Confirm Email address</label><br />
                    <apex:inputText rendered="true"  value="{!applicantWrapper.confirmEmailAddress}"  id="Applicant__c__Confirm_Email_Address__c"  onblur="$j(this).valid();"  
                                    styleClass="input-block-level {!IF(applicantNo==2,'isConfirmEmail2','isConfirmEmail')}"   html-onpaste="return false;"
                                   />
                    <div class="clearfix"></div>
                    <apex:outputText rendered="{!applicantWrapper.errorConfirmEmail}" value="{!applicantWrapper.errorConfirmEmailMsg}" styleClass="warningMessage" />
                </div>

JQuery
 
$j.validator.addMethod("vConfirmEmail", function(value, element, arg){
      var result = false;
      var emailadr = $j(".isEmail").val();
		console.log(emailadr);
        console.log(value);
        if(emailadr ==value ){
            return true;            
        }
    }, "Email addresses do not match - please review and confirm your email address");
    
     //Check email confirmation for applicant 2
     $j.validator.addMethod("vConfirmEmail2", function(value, element) {
        var result = false;
              var emailadr = $j(".isEmail2").val();
                console.log(emailadr);
                console.log(value);
                if(emailadr ==value ){
                    return true;            
                }
            }, "Email addresses do not match - please review and confirm your email address");

​​​​​​​
How can i access community builder to update community pages?
I checked all the settings in my profile(System Admin) but still cannot see builder.
 
Hi
I'm unable to find users created under Customer Community Login License.
When i login as System Administrator also i cannot search for users under People tab to send message or add them in group.
However when i invite using email ID , new user is created under Salesforce Chatter license which i want to avoid.
Can someone help with solution for this.
Thanks
  static testMethod void TestcreateNewRecords(){
        
        //Declare Variables and Objects
        Decimal ST = 12;
        Date StartQuote = Date.today();
        SBQQ__Quote__c q = new SBQQ__Quote__c();
        
        //Create Account Record
        Account a = new Account();
        a.Name = 'TestAccount';
        insert a;
        update a;
        
        //Create Opporunity
        Opportunity o = new Opportunity();
        o.Name = 'Test Opp';
        o.AccountId = a.Id;
        o.Type = 'Variable';
        o.Billing_Account__c = a.Id;
        o.Client_Relationship__c = 'Direct Client';
        o.StageName = 'Owned Lead';
        // o.SBQQ__PrimaryQuote__c =  q.id; 
        o.CloseDate= date.today();
        insert o;
        
        system.debug('++ Opp' + o);
        
        //Create Quote Line Records
        
        Product2 p = new product2(name='unittest');
        p.Family = 'Media';
        p.IsActive = true;
        insert p;
        system.debug('++ Prod'+ p);
        
        Id pricebookId = Test.getStandardPricebookId();
        
        PricebookEntry stdPBE = new PriceBookEntry(
            Product2Id=p.Id,
            Pricebook2Id=pricebookId,
            UnitPrice = 3000000.00,
            UseStandardPrice = false,
            IsActive=true
        );
        
        insert stdPBE;
        system.debug('++ stdPBE'+ stdPBE);
        
        PriceBook2 customPriceBook = new PriceBook2();
        customPriceBook.Name='Custom Pricebook';
        customPriceBook.IsActive=true;
        customPriceBook.Effective_From__c = date.today();
        customPriceBook.Effective_To__c= date.today()+60;
        insert customPriceBook;
        system.debug('++ customPriceBook'+ customPriceBook);
        
        PricebookEntry pbe = new PriceBookEntry(
            Product2Id=p.Id,
            Pricebook2Id=customPriceBook.Id,
            UnitPrice = 5000000.00,
            UseStandardPrice = false,
            IsActive=true
        );
        
        insert pbe;
        system.debug('++ pbe'+ pbe);
        
        
        
        //Create OpportunityLineItem Records 
        /*   OpportunityLineItem item=new OpportunityLineItem();
item.OpportunityId = o.Id;
item.PricebookEntryId = pbe.Id;
item.Quantity = 2;
item.TotalPrice = 10.0;

insert item;
system.debug('++ item'+ item);*/
        
        //Create Quote Record
        
        q.SBQQ__Account__c = a.Id;
        q.SBQQ__Opportunity2__c = o.Id;
        q.SBQQ__Status__c = 'Draft';
        q.SBQQ__Type__c = 'Quote';
        q.SBQQ__StartDate__c = StartQuote;
        q.SBQQ__EndDate__c = StartQuote + 60;
        q.SBQQ__Primary__c = True;
        q.SBQQ__SubscriptionTerm__c = ST;
        q.SBQQ__SalesRep__c = UserInfo.getUserId();
        // q.SBQQ__PriceBook__c = [select id from Pricebook2 where IsActive = true limit 1].id;
        insert q;
        
        System.debug('++ Quote' + q);
        
        SBQQ__QuoteLine__c qlRec = new SBQQ__QuoteLine__c();
        qlRec.SBQQ__Quote__c = q.Id;
        qlRec.SBQQ__StartDate__c = date.today();
        qlrec.SBQQ__EndDate__c = date.today() + 60;        
        qlrec.SBQQ__Product__c = p.id;
        qlRec.SBQQ__Quote__r.SBQQ__Opportunity2__r.Probability = 90;
        
        
        // qlRec.SBQQ__Pri = [select id from Pricebook2 where IsActive = true limit 1].id;
        insert qlRec;


    }
    ---- 
Actual Class 

public class QuoteReportTriggerHandler  {
    
    public QuoteReportTriggerHandler() {}
    
    public static void createNewRecords(List<SBQQ__Quote__c> rec){
        
        List<SBQQ__QuoteLine__c> qLine = new List<SBQQ__QuoteLine__c>();  
        List<Quote_Report__c> reportList = new List<Quote_Report__c>();        
        Set<Id> quoteId = new Set<Id>();
        
        // Get the quote ID 
        for(SBQQ__Quote__c quote : rec){          
            if(quote.SBQQ__Primary__c== true){ 
                quoteId.add(quote.Id) ;
            }   
        }  
        
        // Check the Quote Id and fetch all the fields from QuoteLine
        if(!quoteId.isEmpty()){
            
            qline = [ SELECT SBQQ__Quote__c , SBQQ__ProductName__c , SBQQ__ProductCode__c , 
                     ProductProduct_Type__c,SBQQ__Quote__r.SBQQ__SalesRep__r.Name,
                     SBQQ__Quote__r.SBQQ__SalesRep__r.ID,
                     SBQQ__Quote__r.SBQQ__StartDate__c , SBQQ__Quote__r.SBQQ__EndDate__c ,
                     SBQQ__StartDate__c , SBQQ__EndDate__c,
                     SBQQ__CustomerTotal__c,SBQQ__Quote__r.SBQQ__Opportunity2__r.Probability,
                     SBQQ__NetTotal__c,SBQQ__ListPrice__c,SBQQ__NetPrice__c, 
                     SBQQ__Quote__r.SBQQ__Opportunity2__c, SBQQ__Quote__r.Client_Relationship__c,  
                     ProductCentre__c , ProductState__c
                     From SBQQ__QuoteLine__c 
                     where SBQQ__Quote__c IN :  quoteId and 
                     (NOT (SBQQ__SegmentLabel__c like 'Instal%' or SBQQ__SegmentLabel__c like 'Print%' ))
                    ];
            
        }
        
        System.debug(' Check the query result' + qline);
        
        if(qline.size() > 0) {
            
            Integer i = 0;
            Date endDate;
            Date startDate;
            
            // Caluclate the start date and end date
            for (SBQQ__QuoteLine__c quoteLine : qline){  
                if( quoteLine.SBQQ__StartDate__c == null){
                    startDate = quoteLine.SBQQ__Quote__r.SBQQ__StartDate__c;
                } else {
                    startDate = quoteLine.SBQQ__StartDate__c;
                }
                if( quoteLine.SBQQ__EndDate__c == null){
                    endDate = quoteLine.SBQQ__Quote__r.SBQQ__EndDate__c;
                } else {
                    endDate = quoteLine.SBQQ__EndDate__c;
                }
                
                if(startDate!=null && endDate!=null){
              
                Integer  calculateMonths = startDate.monthsBetween(endDate);    
                System.debug(' Calculate Date = ' + calculateMonths);
                Integer calculateDays = startDate.daysBetween(endDate) +1;
                System.debug(' Calculate Days = ' + calculateDays);
                
                
                for(i = 0 ; i <= calculateMonths ; i++) {
                    Integer numberOfDays = Date.daysInMonth(startDate.year(), startDate.month());
                    Date lastDayOfMonth = Date.newInstance(startDate.year(), startDate.month(), numberOfDays); 
                    Integer  daysInMonths = startDate.daysBetween(lastDayOfMonth)+1;
                    
                    Integer  lastMonth = endDate.month();
                    Integer  lastYear = endDate.year();
                    String opportunityId =  quoteLine.SBQQ__Quote__r.SBQQ__Opportunity2__c;
                    String salesRep = quoteLine.SBQQ__Quote__r.SBQQ__SalesRep__r.Name;
                    String salesRepID = quoteLine.SBQQ__Quote__r.SBQQ__SalesRep__r.Id;
                    String clientRelation = quoteLine.SBQQ__Quote__r.Client_Relationship__c;
                    Double probability = quoteLine.SBQQ__Quote__r.SBQQ__Opportunity2__r.Probability;
                    
                    if(lastDayOfMonth > = endDate){
                        daysInMonths = startDate.daysBetween(endDate) +1;
                        lastDayOfMonth = endDate;
                    }
                    while(startDate < lastDayOfMonth)
                    {   
                        
                        Double calculatePrice = ((quoteLine.SBQQ__NetTotal__c/ calculateDays) * daysInMonths) * probability/100  ; 
                        ForecastingQuota fq ;
                        System.debug(' Net price=' +quoteLine.SBQQ__NetTotal__c + ' CalculatetotalDays = ' +calculateDays + ' DaysinMonths =' +daysInMonths+ ' Probablility=' +probability);
                        System.debug(' startDate= ' +startDate+ ' daysInMonths = ' + daysInMonths+ ' calculatePrice = ' +calculatePrice+ ' lastDayOfMonth =' +lastDayOfMonth);
                        system.debug('Product Type = ' + quoteLine.SBQQ__ProductName__c + ' Quote Line =' +quoteLine.id); 
                        Quote_Report__c qReport = new Quote_Report__c();
                        try{
                            date stdate = date.newInstance(startdate.year(), startDate.month(), 01);
                            fq = [Select QuotaAmount from ForecastingQuota where 
                                  startdate =: stdate                                                 
                                  AND QuotaOwnerId =: salesRepID];
                            System.debug('++Fq' + fq);
                            qReport.Quota_amount__c = fq.QuotaAmount;
                        } catch(exception e){
                            system.debug('Exception') ;
                        }
                        
                        qReport.Quote_ID__c = quoteLine.SBQQ__Quote__c;
                        qReport.Quote_Line__c = quoteLine.id;
                        qReport.Opporunity_Id__c = opportunityId;
                        qReport.Status__c = true;
                        qReport.Start_Date__c = startDate ;
                        qReport.End_Date__c = lastDayOfMonth;
                        qReport.Net_Amount__c = quoteLine.SBQQ__NetTotal__c ;
                        qReport.Price_Per_Month__c =calculatePrice ;
                        qReport.Product_Name__c = quoteLine.SBQQ__ProductName__c;
                        qReport.Product_Type__c=quoteLine.ProductProduct_Type__c;
                        qReport.Sales_Rep__c=salesRep;
                        qReport.Client_Relationship__c= clientRelation;
                        qReport.State__c = quoteLine.ProductState__c;
                        qReport.Centre__c = quoteLine.ProductCentre__c;
                        qReport.Pipeline__c = probability;
                        reportList.add(qReport);
                        
                        startDate  = startDate.toStartOfMonth();
                        startDate = startDate.AddMonths(1);                    
                    } 
                } 
            } 
           }
            List<Quote_Report__c> deletelist = new List<Quote_Report__c> ();
            for( SBQQ__QuoteLine__c quoLine : qline) {
                
                String oppId =  quoLine.SBQQ__Quote__r.SBQQ__Opportunity2__c;                
                deletelist = [Select Quote_id__c , Quote_line__c
                              from Quote_Report__c 
                              where Opporunity_Id__c =: oppId];
                
            }
            
            if(deletelist.size()>0){
                delete deletelist;                
            }
            
            insert reportList;
        }
    }  
}
  • September 10, 2018
  • Like
  • 0
 //Create Quote Line Records
        
        Product2 p = new product2(name='unittest');
        p.Family = 'Media';
        p.IsActive = true;
        insert p;
        system.debug('++ Prod'+ p);
        
        // Id pricebookId = Test.getStandardPricebookId();
        
        Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true,Effective_From__c = date.today() , Effective_To__c= date.today()+60);
        insert pb;
        // First insert a price for the standard price book
        PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pb.id, Product2Id = p.Id,
            UnitPrice = 10000, IsActive = true,UseStandardPrice = false, Id = Test.getStandardPricebookId());

        insert standardPrice; 
          system.debug('standardPrice' + standardPrice);
        Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
        PricebookEntry standardPBE = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = p.Id, UnitPrice = 1000, IsActive = true);
        insert standardPBE;
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = p.Id, UnitPrice = 1000, IsActive = true);
        insert pbe;
        system.debug('pbe' + pbe);
  • September 10, 2018
  • Like
  • 0
 // Caluclate the start date and end date
            for (SBQQ__QuoteLine__c quoteLine : qline){  
                if( quoteLine.SBQQ__StartDate__c == null){
                    startDate = quoteLine.SBQQ__Quote__r.SBQQ__StartDate__c;
                } else {
                    startDate = quoteLine.SBQQ__StartDate__c;
                }
                if( quoteLine.SBQQ__EndDate__c == null){
                    endDate = quoteLine.SBQQ__Quote__r.SBQQ__EndDate__c;
                } else {
                    endDate = quoteLine.SBQQ__EndDate__c;
                }
                
                if(startDate!=null && endDate!=null){
              
                Integer  calculateMonths = startDate.monthsBetween(endDate);    
                System.debug(' Calculate Date = ' + calculateMonths);
                Integer calculateDays = startDate.daysBetween(endDate) +1;
                System.debug(' Calculate Days = ' + calculateDays);
                
                
                for(i = 0 ; i <= calculateMonths ; i++) {
                    Integer numberOfDays = Date.daysInMonth(startDate.year(), startDate.month());
                    Date lastDayOfMonth = Date.newInstance(startDate.year(), startDate.month(), numberOfDays); 
                    Integer  daysInMonths = startDate.daysBetween(lastDayOfMonth)+1;
                    
                    Integer  lastMonth = endDate.month();
                    Integer  lastYear = endDate.year();
                    String opportunityId =  quoteLine.SBQQ__Quote__r.SBQQ__Opportunity2__c;
                    String salesRep = quoteLine.SBQQ__Quote__r.SBQQ__SalesRep__r.Name;
                    String salesRepID = quoteLine.SBQQ__Quote__r.SBQQ__SalesRep__r.Id;
                    String clientRelation = quoteLine.SBQQ__Quote__r.Client_Relationship__c;
                    Double probability = quoteLine.SBQQ__Quote__r.SBQQ__Opportunity2__r.Probability;
                    
                    if(lastDayOfMonth > = endDate){
                        daysInMonths = startDate.daysBetween(endDate) +1;
                        lastDayOfMonth = endDate;
                    }
                    while(startDate < lastDayOfMonth)
                    {   
                        
                        Double calculatePrice = ((quoteLine.SBQQ__NetTotal__c/ calculateDays) * daysInMonths) * probability/100  ; 
                        ForecastingQuota fq ;
                        System.debug(' Net price=' +quoteLine.SBQQ__NetTotal__c + ' CalculatetotalDays = ' +calculateDays + ' DaysinMonths =' +daysInMonths+ ' Probablility=' +probability);
                        System.debug(' startDate= ' +startDate+ ' daysInMonths = ' + daysInMonths+ ' calculatePrice = ' +calculatePrice+ ' lastDayOfMonth =' +lastDayOfMonth);
                        system.debug('Product Type = ' + quoteLine.SBQQ__ProductName__c + ' Quote Line =' +quoteLine.id); 
                        Quote_Report__c qReport = new Quote_Report__c();
                        try{
                            date stdate = date.newInstance(startdate.year(), startDate.month(), 01);
                            fq = [Select QuotaAmount from ForecastingQuota where 
                                  startdate =: stdate                                                 
                                  AND QuotaOwnerId =: salesRepID];
                            System.debug('++Fq' + fq);
                            qReport.Quota_amount__c = fq.QuotaAmount;
                        } catch(exception e){
                            system.debug('Exception') ;
                        }

                        
                        qReport.Quote_ID__c = quoteLine.SBQQ__Quote__c;
                        qReport.Quote_Line__c = quoteLine.id;
                        qReport.Opporunity_Id__c = opportunityId;
                        qReport.Status__c = true;
                        qReport.Start_Date__c = startDate ;
                        qReport.End_Date__c = lastDayOfMonth;
                        qReport.Net_Amount__c = quoteLine.SBQQ__NetTotal__c ;
                        qReport.Price_Per_Month__c =calculatePrice ;
                        qReport.Product_Name__c = quoteLine.SBQQ__ProductName__c;
                        qReport.Product_Type__c=quoteLine.ProductProduct_Type__c;
                        qReport.Sales_Rep__c=salesRep;
                        qReport.Client_Relationship__c= clientRelation;
                        qReport.State__c = quoteLine.ProductState__c;
                        qReport.Centre__c = quoteLine.ProductCentre__c;
                        qReport.Pipeline__c = probability;
                        reportList.add(qReport);
                        
                        startDate  = startDate.toStartOfMonth();
                        startDate = startDate.AddMonths(1);                    
                    } 
                } 
            } 
           }
  • September 10, 2018
  • Like
  • 0
how to retrieve community url on non community triggered emails ?
How to get {!Community_Url} merge field on Email template - ( Note: This template is not used for New User or Forgot Password template)
Do we need to use only Standard object in setTargetObjectId ? or we can use both custom/Standard ?
I have business requirement for for validating email address and confirm email address.
I used jquery to validate both the fields and created confirmEmail adress on wrapper class.
There are 2 applicants in one page, it is working correctly for applicant 1 but when i move to tab applicant 2, confirm email value disappears.
Please help.
Thanks
 
<div class="{!if($site.Name!='Aussie', 'span12', 'span6')} removelmargin lfsTextInputXLge input100pct">
                    <label class="removelmargin labeldark">Email address</label><br />
                    <apex:inputText value="{!applicantWrapper.applicant.Email_Address__c}" onfocus="checkPhoneNumbersOnEmail()" id="Applicant__c___Email_Address__c"
                                    html-onpaste="return false;"
                                    styleClass="input-block-level isMaxLength40 marginbottom10 {!IF(applicantNo==2,'isEmail2','isEmail')}  " />
                    <div class="clearfix"></div>
                    <apex:outputText rendered="{!applicantWrapper.errorEmail}" value="{!applicantWrapper.errorEmailMsg}" styleClass="warningMessage" />
                    <apex:outputText rendered="{!brokerchannel}" value="Please make sure to enter customer's email address." styleClass="warningMessage" />
                </div>
              
       
              
               <div class="{!if($site.Name!='Aussie', 'span12', 'span6')} removelmargin lfsTextInputXLge input100pct" id="result" >                   
                    <label class="removelmargin labeldark">Confirm Email address</label><br />
                    <apex:inputText rendered="true"  value="{!applicantWrapper.confirmEmailAddress}"  id="Applicant__c__Confirm_Email_Address__c"  onblur="$j(this).valid();"  
                                    styleClass="input-block-level {!IF(applicantNo==2,'isConfirmEmail2','isConfirmEmail')}"   html-onpaste="return false;"
                                   />
                    <div class="clearfix"></div>
                    <apex:outputText rendered="{!applicantWrapper.errorConfirmEmail}" value="{!applicantWrapper.errorConfirmEmailMsg}" styleClass="warningMessage" />
                </div>

JQuery
 
$j.validator.addMethod("vConfirmEmail", function(value, element, arg){
      var result = false;
      var emailadr = $j(".isEmail").val();
		console.log(emailadr);
        console.log(value);
        if(emailadr ==value ){
            return true;            
        }
    }, "Email addresses do not match - please review and confirm your email address");
    
     //Check email confirmation for applicant 2
     $j.validator.addMethod("vConfirmEmail2", function(value, element) {
        var result = false;
              var emailadr = $j(".isEmail2").val();
                console.log(emailadr);
                console.log(value);
                if(emailadr ==value ){
                    return true;            
                }
            }, "Email addresses do not match - please review and confirm your email address");

​​​​​​​
How can i access community builder to update community pages?
I checked all the settings in my profile(System Admin) but still cannot see builder.
 
Hi
I'm unable to find users created under Customer Community Login License.
When i login as System Administrator also i cannot search for users under People tab to send message or add them in group.
However when i invite using email ID , new user is created under Salesforce Chatter license which i want to avoid.
Can someone help with solution for this.
Thanks
 //Create Quote Line Records
        
        Product2 p = new product2(name='unittest');
        p.Family = 'Media';
        p.IsActive = true;
        insert p;
        system.debug('++ Prod'+ p);
        
        // Id pricebookId = Test.getStandardPricebookId();
        
        Pricebook2 pb = new Pricebook2(Name = 'Standard Price Book 2009', Description = 'Price Book 2009 Products', IsActive = true,Effective_From__c = date.today() , Effective_To__c= date.today()+60);
        insert pb;
        // First insert a price for the standard price book
        PricebookEntry standardPrice = new PricebookEntry(
            Pricebook2Id = pb.id, Product2Id = p.Id,
            UnitPrice = 10000, IsActive = true,UseStandardPrice = false, Id = Test.getStandardPricebookId());

        insert standardPrice; 
          system.debug('standardPrice' + standardPrice);
        Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];
        PricebookEntry standardPBE = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = p.Id, UnitPrice = 1000, IsActive = true);
        insert standardPBE;
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = p.Id, UnitPrice = 1000, IsActive = true);
        insert pbe;
        system.debug('pbe' + pbe);
  • September 10, 2018
  • Like
  • 0
 // Caluclate the start date and end date
            for (SBQQ__QuoteLine__c quoteLine : qline){  
                if( quoteLine.SBQQ__StartDate__c == null){
                    startDate = quoteLine.SBQQ__Quote__r.SBQQ__StartDate__c;
                } else {
                    startDate = quoteLine.SBQQ__StartDate__c;
                }
                if( quoteLine.SBQQ__EndDate__c == null){
                    endDate = quoteLine.SBQQ__Quote__r.SBQQ__EndDate__c;
                } else {
                    endDate = quoteLine.SBQQ__EndDate__c;
                }
                
                if(startDate!=null && endDate!=null){
              
                Integer  calculateMonths = startDate.monthsBetween(endDate);    
                System.debug(' Calculate Date = ' + calculateMonths);
                Integer calculateDays = startDate.daysBetween(endDate) +1;
                System.debug(' Calculate Days = ' + calculateDays);
                
                
                for(i = 0 ; i <= calculateMonths ; i++) {
                    Integer numberOfDays = Date.daysInMonth(startDate.year(), startDate.month());
                    Date lastDayOfMonth = Date.newInstance(startDate.year(), startDate.month(), numberOfDays); 
                    Integer  daysInMonths = startDate.daysBetween(lastDayOfMonth)+1;
                    
                    Integer  lastMonth = endDate.month();
                    Integer  lastYear = endDate.year();
                    String opportunityId =  quoteLine.SBQQ__Quote__r.SBQQ__Opportunity2__c;
                    String salesRep = quoteLine.SBQQ__Quote__r.SBQQ__SalesRep__r.Name;
                    String salesRepID = quoteLine.SBQQ__Quote__r.SBQQ__SalesRep__r.Id;
                    String clientRelation = quoteLine.SBQQ__Quote__r.Client_Relationship__c;
                    Double probability = quoteLine.SBQQ__Quote__r.SBQQ__Opportunity2__r.Probability;
                    
                    if(lastDayOfMonth > = endDate){
                        daysInMonths = startDate.daysBetween(endDate) +1;
                        lastDayOfMonth = endDate;
                    }
                    while(startDate < lastDayOfMonth)
                    {   
                        
                        Double calculatePrice = ((quoteLine.SBQQ__NetTotal__c/ calculateDays) * daysInMonths) * probability/100  ; 
                        ForecastingQuota fq ;
                        System.debug(' Net price=' +quoteLine.SBQQ__NetTotal__c + ' CalculatetotalDays = ' +calculateDays + ' DaysinMonths =' +daysInMonths+ ' Probablility=' +probability);
                        System.debug(' startDate= ' +startDate+ ' daysInMonths = ' + daysInMonths+ ' calculatePrice = ' +calculatePrice+ ' lastDayOfMonth =' +lastDayOfMonth);
                        system.debug('Product Type = ' + quoteLine.SBQQ__ProductName__c + ' Quote Line =' +quoteLine.id); 
                        Quote_Report__c qReport = new Quote_Report__c();
                        try{
                            date stdate = date.newInstance(startdate.year(), startDate.month(), 01);
                            fq = [Select QuotaAmount from ForecastingQuota where 
                                  startdate =: stdate                                                 
                                  AND QuotaOwnerId =: salesRepID];
                            System.debug('++Fq' + fq);
                            qReport.Quota_amount__c = fq.QuotaAmount;
                        } catch(exception e){
                            system.debug('Exception') ;
                        }

                        
                        qReport.Quote_ID__c = quoteLine.SBQQ__Quote__c;
                        qReport.Quote_Line__c = quoteLine.id;
                        qReport.Opporunity_Id__c = opportunityId;
                        qReport.Status__c = true;
                        qReport.Start_Date__c = startDate ;
                        qReport.End_Date__c = lastDayOfMonth;
                        qReport.Net_Amount__c = quoteLine.SBQQ__NetTotal__c ;
                        qReport.Price_Per_Month__c =calculatePrice ;
                        qReport.Product_Name__c = quoteLine.SBQQ__ProductName__c;
                        qReport.Product_Type__c=quoteLine.ProductProduct_Type__c;
                        qReport.Sales_Rep__c=salesRep;
                        qReport.Client_Relationship__c= clientRelation;
                        qReport.State__c = quoteLine.ProductState__c;
                        qReport.Centre__c = quoteLine.ProductCentre__c;
                        qReport.Pipeline__c = probability;
                        reportList.add(qReport);
                        
                        startDate  = startDate.toStartOfMonth();
                        startDate = startDate.AddMonths(1);                    
                    } 
                } 
            } 
           }
  • September 10, 2018
  • Like
  • 0
how to retrieve community url on non community triggered emails ?