• Maulik D Shah
  • NEWBIE
  • 100 Points
  • Member since 2017
  • Founder & CEO
  • CRMJetty


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 19
    Replies
Hi i want to display the data in newline and i tried with <br/> and </n> but it was not working. And my code is

for( Opportunity oppLst : [Select Id,Name,Cart_Grand_Total__c, (Select Product_SKU__c,DeliveryDate__c from  Shopping_cart_line_items__r where DeliveryDate__c >Today )
                                 from Opportunity where AccountId =:accountId  and  StageName='Closed Won' ])
       {
             for(Shopping_cart_line_item__c scL : oppLst.Shopping_cart_line_items__r){
              DateTime DeliveryDate = scL.DeliveryDate__c;
              upcmngDeleviries += DeliveryDate.format('MM/dd/yyyy')+'\n';
          }
           upcmngDeleviries +='$'+oppLst.Cart_Grand_Total__c +'\n';
       }
       return upcmngDeleviries ;

Actual Output: 01/23/2020 $660.29 01/22/2020 01/22/2020 $1373.84

Expected Output : 01/23/2020 $660.29
                              01/22/2020 01/22/2020 $1373.84
Hello Developers

need small Assistance with the apex class

My requirement is that when i create a lead with country as 'india', there is a custom field named 'India_Auto_Number__c' where it should update as 1, and again when i create a lead with country name 'india' it should increment to 2...like this it should keep on incrementing till 5th lead, when i try to insert 6th lead, it should again update as 1
how do i achive this functionality
 
public class IncrementonLead {
    public void onInsert( list<Lead> newList){

    List<Lead> lstld = [SELECT Id,India_Auto_Number__c FROM Lead];
    Integer intCounter = lstld.size() != 0 ? lstld[0].India_Auto_Number__c : 0;
    for(Lead objLead: newList)
    {
        intCounter ++;
        objLead.India_Auto_Number__c = intCounter;
    }

    }
}

This is what i have  come up with so far
I have custom object Resource__c with custom field Total_Allocated_Paid_Leaves__c .I want to update this field with existing value + New value.
Please Help me!
 
Hello Folks,
 
When i try to create a case using a apex class, assignment rule working fine but no email notification sent to the queue member?
 
I have try below code when insert the the case.
 
Database.DMLOptions dlo = new Database.DMLOptions(); dlo.EmailHeader.triggerUserEmail = true; Database.SaveResult sr = database.insert(obj, dlo);
 
Any one facing similar issue?
 
Please help to resolve this issue.
Hello Folks,
 
When i try to create a case using a apex class, assignment rule working fine but no email notification sent to the queue member?
 
I have try below code when insert the the case.
 
Database.DMLOptions dlo = new Database.DMLOptions(); dlo.EmailHeader.triggerUserEmail = true; Database.SaveResult sr = database.insert(obj, dlo);
 
Any one facing similar issue?
 
Please help to resolve this issue.
ApexClass
public class OpportunityTriggerClass{
  public static void opportunityCount(List<SObject> newRecords, List<SObject> oldRecords) {
    Map<Id,Account> AccountMap=new Map<Id,Account>();
            set<String> updateOpportunityCount= new Set<String>();
            set<String> accId=new Set<String>();
            for(SObject newObj :newRecords) {
                Opportunity newOppObj = (Opportunity)newObj;//type casting
                Opportunity oldOppObj = null;
                if(newOppObj.Id!=null && oldRecords!=null) {
                    newOppObj = (Opportunity)newObj;//type casting
                }
                if(newOppObj.AccountId!=null){
                accId.add(newOppObj.AccountId);
                }
            }

                for(Account ac:[Select Id,Opportunity_Count__c,(select Id from Opportunities) from Account where Id IN:accId]){
                    ac.Opportunity_Count__c=ac.Opportunities.size(); 
                    AccountMap.put(ac.Id,ac);
                }

            update AccountMap.values();
    }
}



Trigger

trigger OpportunityTrigger on Opportunity (After Insert,After update,After Delete,After Undelete) {
 List<Opportunity> Opportunities = Trigger.isDelete ? Trigger.old : Trigger.new;
    System.debug('Opportunities----'+Opportunities);
    OpportunityTriggerClass.opportunityCount(Opportunities,Opportunities);//calling Apex class method
}
Hi i want to display the data in newline and i tried with <br/> and </n> but it was not working. And my code is

for( Opportunity oppLst : [Select Id,Name,Cart_Grand_Total__c, (Select Product_SKU__c,DeliveryDate__c from  Shopping_cart_line_items__r where DeliveryDate__c >Today )
                                 from Opportunity where AccountId =:accountId  and  StageName='Closed Won' ])
       {
             for(Shopping_cart_line_item__c scL : oppLst.Shopping_cart_line_items__r){
              DateTime DeliveryDate = scL.DeliveryDate__c;
              upcmngDeleviries += DeliveryDate.format('MM/dd/yyyy')+'\n';
          }
           upcmngDeleviries +='$'+oppLst.Cart_Grand_Total__c +'\n';
       }
       return upcmngDeleviries ;

Actual Output: 01/23/2020 $660.29 01/22/2020 01/22/2020 $1373.84

Expected Output : 01/23/2020 $660.29
                              01/22/2020 01/22/2020 $1373.84
Hello Developers

need small Assistance with the apex class

My requirement is that when i create a lead with country as 'india', there is a custom field named 'India_Auto_Number__c' where it should update as 1, and again when i create a lead with country name 'india' it should increment to 2...like this it should keep on incrementing till 5th lead, when i try to insert 6th lead, it should again update as 1
how do i achive this functionality
 
public class IncrementonLead {
    public void onInsert( list<Lead> newList){

    List<Lead> lstld = [SELECT Id,India_Auto_Number__c FROM Lead];
    Integer intCounter = lstld.size() != 0 ? lstld[0].India_Auto_Number__c : 0;
    for(Lead objLead: newList)
    {
        intCounter ++;
        objLead.India_Auto_Number__c = intCounter;
    }

    }
}

This is what i have  come up with so far
Why Account and Contact objects internally have Master-Detail relation even though they were in Lookup relation. Can anyone explain why?
  • January 16, 2020
  • Like
  • 0
Please can someone explain why this wouldn't work?
 the error im receiving is:
Error: Engineer_Returns_Contact line 24, column 23: The element type "apex:outputPanel" must be terminated by the matching end-tag "</apex:outputPanel>"
Error: The element type "apex:outputPanel" must be terminated by the matching end-tag "</apex:outputPanel>".





<messaging:emailTemplate subject="RAM Cameras to Return" recipientType="Contact" relatedToType="Case">

<messaging:htmlEmailBody >
<html>
<body>


kdmksmda
djbaskns
sjdnsaokdna

<table>
       <apex:repeat Value="{!relatedto.Service_Bookings__r}" var="SVC">
                   <apex:outputPanel rendered="{!AND(SVC.Work_Type__c = "Service Call"), SVC.Camera_Returned__c = False)}">
                    <tr>
                   <td style="color: #EB690B; text-align: Center; padding-left: 10%; padding-right: 10%;"><b>{!SVC.Case_Owner__c}</b></td>


                   <!-- <td>{!SVC.Account_name__c}</td> -->

                   <!-- <td>{!SVC.Case_ID__c}</td> -->

                    </tr>
                    </apex:outputPanel>
             </apex:repeat>
</table>
</body>
</html>
I have custom object Resource__c with custom field Total_Allocated_Paid_Leaves__c .I want to update this field with existing value + New value.
Please Help me!
 
I have created a test class for one of my controller but after so many trial it is still showing me 73. please suggest .

 
Can anyone help me to write the test class for following apex class

public class QuoteApexClass {
    public Id testId {get;set;}
    private Quotes__c quoteObj;
    public String renderAs { get; set; }
     
    public QuoteApexClass(ApexPages.standardController con){
        if(con.getId()!=NULL){
            testId = con.getId();
            quoteObj =  [select id,Name,Email__c,ContactId__c from Quotes__c where id =:testId];
        }
    }
    public PageReference saveQuoteAsPDFandEmail()
    {    
        PageReference pr = Page.QuoteTemplate;
        Attachment attachmnt = new Attachment();
        Blob pdfBlob;
        try {
            pdfBlob = pr.getContentAsPDF();
        }
        catch (VisualforceException e) {
            pdfBlob = Blob.valueOf('Some Text');
        }
        
        attachmnt.parentId = testId;
        attachmnt.Name = 'V - '+ system.Now() + '.pdf';
        attachmnt.body = pdfBlob;
        insert attachmnt;
        
        
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        
        attach.setFileName(attachmnt.Name);
        attach.setBody(attachmnt.body);
        attach.setContentType('application/pdf');
        semail.setSubject('Quote template '+quoteObj.Name);
        List <String> listEmailMembers = new List<String>();
        listEmailMembers.add('chandra.s@proseraa.com');
        listEmailMembers.add(UserInfo.getUserEmail());
        semail.setToAddresses(listEmailMembers);
        semail.saveAsActivity = true;
        semail.setPlainTextBody('As Discussed over the phone.Please find the quotation attached.Also sign the document and send us back.');
        semail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
        Messaging.SendEmailResult [] r1 = Messaging.sendEmail(new messaging.SingleEmailMessage[] {semail});
        
         if (r1[0].success) 
        {
            System.debug('The email was sent successfully.');
        } else 
        {
            System.debug('The email failed to send: ' + r1[0].errors[0].message);
        }
        
        Task tk = new Task();
        tk.ActivityDate = system.today();
        tk.Subject = 'Email has been sent with subject name as '+'Quote template '+quoteObj.Name;
        tk.Description ='Email has been sent with subject name as '+'Quote template" '+quoteObj.Name + ' " along with an attachment "'+attachmnt.Name+ ' " at '+system.now();
        tk.Status = 'completed';
        tk.WhatId = testId;
        insert tk;
        
        attachment att = new attachment();
        att.Name = 'V - '+ system.Now() + '.pdf';
        att.body = pdfBlob;
        att.ParentId = tk.Id;
        insert att;
        
        PageReference pageRef = new PageReference('https://proseraa.lightning.force.com/lightning/r/Quotes__c/'+testId+'/view');
        pageRef.setRedirect(true);
        return pageRef;  
    }
    
    public void attachPDF() {
        PageReference pdfPage = Page.QuoteTemplate;
        Attachment attach = new Attachment();
        Blob pdfBlob;
        try {
            pdfBlob = pdfPage.getContent();
        }
        catch (VisualforceException e) {
            pdfBlob = Blob.valueOf('Some Text');
        }
        
        attach.parentId = ApexPages.currentPage().getParameters().get('id');
        attach.Name = 'Letter - '+ system.Now() + ' .pdf';
        attach.body = pdfBlob;
        insert attach;
    }
    
    public Boolean getShowPrintLink() {
        return ( (renderAs == null) || ( ! renderAs.startsWith('PDF')) );
    }
   
    public PageReference print() {
        renderAs = 'PDF';
        PageReference pdfPage = Page.QuoteTemplate;
        Attachment attach = new Attachment();
        Blob pdfBlob;
        try {
            pdfBlob = pdfPage.getContentAsPDF();
        }
        catch (VisualforceException e) {
            pdfBlob = Blob.valueOf('Some Text');
        } 
        
        attach.parentId = testId;
        attach.Name = 'V - '+ system.Now() + '.pdf';
        attach.body = pdfBlob;
        insert attach;
        
        PageReference pageRef = new PageReference('https://proseraa.lightning.force.com/lightning/r/Quotes__c/'+testId+'/view');
        pageRef.setRedirect(true);
        return pageRef;  
    }
}