• Makam Ruthvik
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 8
    Replies

Decimal d1 = 491345345.90;
        System.debug(d1);
        List<String> args = new String[]{'0','number','###,###,##0.00'};
String s = String.format(d1.format(), args);
System.debug(s);

Using this I was able to format the decimal.

Now I have to change to Netherlands currently i.e., replacing all the dots with commas and commas with dots.

How to change the string from 491,345,345.90 to 491.345.345,90 in one go

<messaging:emailTemplate subject="a"  recipientType="Contact" relatedToType="Account" >
<messaging:htmlEmailBody >

</messaging:htmlEmailBody>
</messaging:emailTemplate>

Above is the generic email content available when we create a new visualforce email template.

Here for my body I can use visualforce component and a controller and happily render the data in it dynamically.

But how to dynamically render the subject dynamically. I know we can {!IF(, , ,)} condition and do it but that do not suffice in my requirement.

Is it possible to call the controller in the messaging:emailsubject ?

Hi,

 

 
        try {
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });

}
        } catch (Exception e) {
            System.debug('Exception'+e.getMessage());
            throw e;
        }

I can' t get the code coverage for catch block.

 

Tried the below,

try {
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
            
            if(Test.isRunningTest()) {
    throw new EmailException('Email Exception occurred for testing'); 
}
        } catch (Exception e) {
            System.debug('Exception'+e.getMessage());
            throw e;
        }

Getting 100% coverage but the test class is failing.

 

Please help me out here

Hi All,

Please take a look at below lines.

<messaging:emailTemplate subject="{!$Label.SNL_018_EmailSubject}"  recipientType="Contact" relatedToType="Account"  >
<messaging:htmlEmailBody >
{!relatedTo.Payment_Reminders1__r}



</messaging:htmlEmailBody>
</messaging:emailTemplate>

Here Payment_Reminders1 is child relationship name. From Account I am getting related reminder Id's in a list. How to get the recently created Id from that list. I tried sort by, order by and size etc., None are working. Please help me in this.

Hi,
Can anyone tell me how to cover the get 100% coverage for the below class





global class SNL_002A_EmailAlert {

  @InvocableMethod
  public static void download(List<Order> OrderId) {
      
     set<id> ordId = new set<id>();
      for (Order s:OrderId){
          ordId.add(s.Id);
         } 
   
        List<Order> OrderList =[Select Id,BillToContactId from Order where Id IN : ordId];
      
         String templateId, whoId, whatId;

           Messaging.SingleEmailMessage email =  Messaging.renderStoredEmailTemplate( templateId, whoId, whatId);

    /**** Attach files to the message ****/
    
     List<Messaging.EmailFileAttachment> attachments = new List<Messaging.EmailFileAttachment>();
     List<id> ContentDocumentids = new List<id>();
      
      for(contentDocumentLink CDLink : [SELECT LinkedEntityid, ContentDocumentid FROM contentDocumentLink WHERE LinkedEntityid IN : ordId]){
               {
                   ContentDocumentids.add(CDLink.ContentDocumentid);  
                }
      
                 system.debug('ContentDocumentids'+ContentDocumentids);
                for ( ContentVersion cversion : [SELECT title, 
                                                        PathOnClient, 
                                                        versiondata 
                                                  FROM contentversion 
                                                  WHERE ContentDocumentId IN :ContentDocumentids  
                                                  ])
                 {
                  blob WOCFbody = cversion.versiondata;
                  system.debug('body : '+WOCFbody+'-----------'+cversion.title);
                  Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
                  efa.setFileName(cversion.title);
                  efa.setBody(WOCFbody);
                  attachments.add(efa); 
                 }
            }

    email.setFileAttachments(attachments);

    /******* Set the message template ******/
      
    String tempName  = String.valueOf(System.Label.SNL_002A_Template);
    List<EmailTemplate> templates = [SELECT Id, Subject,Markup,body, HtmlValue FROM EmailTemplate WHERE DeveloperName =:tempName];
    if (!templates.isEmpty()) {
        
          templateId = templates[0].Id;
          whoId = OrderList[0].BillToContactId;
          whatId = OrderId[0].Id;
      
          email.setTargetObjectId(whoId);
          email.setSubject(email.getSubject());
          email.sethtmlBody(email.gethtmlBody());
          email.saveAsActivity = false;
    }
 
    /*******Send the message  *******/
    try {
      Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
    } catch (Exception e) {
      throw e;
    }
  
  }

}
Hi All,

I have a pdf attached in files on related tab of my order records. How to query them and attach to my classic email template. Please help me here.
Thanks in advance
public Map<String,Object> con018{
        get{
            if(AccountId!=null){
                Map<String,Object> linkMap = new Map<String,Object>();
                  List<Account> or1 = [SELECT Id,Parent.Id FROM Account WHERE Id =:AccountId];
                List<Account> or2 = [SELECT Id,AccountReferenceNumber__c, (SELECT vlocity_cmt__DueDate__c,BillToContact.FirstName,SNL_ActualStartDate__c,Usage_Monthly_Total_Including_VAT__c  FROM orders) FROM Account WHERE Id =:or1[0].Parent.Id];

                         list<Order> OrderList = new List<Order>(); 
String ff;
                for(Account a : or2)
        {
           for(Order c : a.Orders)
            {
               OrderList.add(c);     //  assign contact to the list
            }
        }
        for(Order z : OrderList){
     ff=z.BillToContactId;
}
                        List<Contact> Con=[Select Firstname from Contact where Id=:ff];

                
                
                String refno='refno';
                String refnoval = String.valueOf(or2[0].get('AccountReferenceNumber__c'));
                linkMap.put(refno,refnoval);
                String fname = 'fname';
                String fnameval = String.valueOf(Con[0].get('FirstName'));
                linkMap.put(fname,fnameval);
                String asd = 'asd';
                DateTime asdval = OrderList[0].SNL_ActualStartDate__c;
                linkMap.put(asd,asdval);
                String amnt = 'amnt';
                String amntval = String.valueOf(OrderList[0].Usage_Monthly_Total_Including_VAT__c);
                linkMap.put(amnt,amntval);
                String dd = 'dd';
                DateTime ddval = OrderList[0].vlocity_cmt__DueDate__c;
                linkMap.put(dd,ddval);
                
                
                return linkMap;
            }else{
                return null;
            }
              

        }
        set;
    }
Hi All,

I have a pdf attached to files in Order records{PDF has a unique name so have to query based on it's name}. How to query it from the Order record and attach it to Classic Email Template. Please help me here. Thanks in Advance
Hi,

I have two pdf's (let A and B)stored in documents both in different languages. So according to my recepients language if it dutch it should attach pdf A and if it is English it should attach pdf B. How can we achieve it?

If the location is other than documents like suppose notes and attachments then how to fetch from there?

Please help me out...Thanks in Advance!
we have to languages in our Org English and Dutch. While testing out the email in classic email templates the translations are fine for both dutch and english contacts but when tested the same email template by workflow I am always getting english language even though my contact's preferred language is dutch. Please help me out


<messaging:emailTemplate subject="{!$Label.Art_Subject}"  recipientType="Contact" relatedToType="Order" language="{!recipient.Language__c}">
<messaging:htmlEmailBody >

<!--<span style="display: none !important; visibility: hidden; opacity: 0; color: transparent; height: 0; width: 0;">{!$Label.Art_Preheader}</span>-->



<c:Art OId="{!relatedTo.Id}"/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

Decimal d1 = 491345345.90;
        System.debug(d1);
        List<String> args = new String[]{'0','number','###,###,##0.00'};
String s = String.format(d1.format(), args);
System.debug(s);

Using this I was able to format the decimal.

Now I have to change to Netherlands currently i.e., replacing all the dots with commas and commas with dots.

How to change the string from 491,345,345.90 to 491.345.345,90 in one go

Hi All,

Please take a look at below lines.

<messaging:emailTemplate subject="{!$Label.SNL_018_EmailSubject}"  recipientType="Contact" relatedToType="Account"  >
<messaging:htmlEmailBody >
{!relatedTo.Payment_Reminders1__r}



</messaging:htmlEmailBody>
</messaging:emailTemplate>

Here Payment_Reminders1 is child relationship name. From Account I am getting related reminder Id's in a list. How to get the recently created Id from that list. I tried sort by, order by and size etc., None are working. Please help me in this.

Hi All,

I have a pdf attached in files on related tab of my order records. How to query them and attach to my classic email template. Please help me here.
Thanks in advance
public Map<String,Object> con018{
        get{
            if(AccountId!=null){
                Map<String,Object> linkMap = new Map<String,Object>();
                  List<Account> or1 = [SELECT Id,Parent.Id FROM Account WHERE Id =:AccountId];
                List<Account> or2 = [SELECT Id,AccountReferenceNumber__c, (SELECT vlocity_cmt__DueDate__c,BillToContact.FirstName,SNL_ActualStartDate__c,Usage_Monthly_Total_Including_VAT__c  FROM orders) FROM Account WHERE Id =:or1[0].Parent.Id];

                         list<Order> OrderList = new List<Order>(); 
String ff;
                for(Account a : or2)
        {
           for(Order c : a.Orders)
            {
               OrderList.add(c);     //  assign contact to the list
            }
        }
        for(Order z : OrderList){
     ff=z.BillToContactId;
}
                        List<Contact> Con=[Select Firstname from Contact where Id=:ff];

                
                
                String refno='refno';
                String refnoval = String.valueOf(or2[0].get('AccountReferenceNumber__c'));
                linkMap.put(refno,refnoval);
                String fname = 'fname';
                String fnameval = String.valueOf(Con[0].get('FirstName'));
                linkMap.put(fname,fnameval);
                String asd = 'asd';
                DateTime asdval = OrderList[0].SNL_ActualStartDate__c;
                linkMap.put(asd,asdval);
                String amnt = 'amnt';
                String amntval = String.valueOf(OrderList[0].Usage_Monthly_Total_Including_VAT__c);
                linkMap.put(amnt,amntval);
                String dd = 'dd';
                DateTime ddval = OrderList[0].vlocity_cmt__DueDate__c;
                linkMap.put(dd,ddval);
                
                
                return linkMap;
            }else{
                return null;
            }
              

        }
        set;
    }
Hi All,

I have a pdf attached to files in Order records{PDF has a unique name so have to query based on it's name}. How to query it from the Order record and attach it to Classic Email Template. Please help me here. Thanks in Advance
Hi,

I have two pdf's (let A and B)stored in documents both in different languages. So according to my recepients language if it dutch it should attach pdf A and if it is English it should attach pdf B. How can we achieve it?

If the location is other than documents like suppose notes and attachments then how to fetch from there?

Please help me out...Thanks in Advance!
I am working on sending an email with the opportunity files based on certain criteria. I am able to send an email with the 'versionData' as an email body which is queried from 'Contentversion'. 
Problem: When i try to open the attachment from email it says 'Preview not available' and also i am not able to open the downloaded attachment too.
Please find the code below and let me know where I am going wrong. Thanks!
List<id> ContentDocumentids = new List<id>();

for(contentDocumentLink CDLink : [SELECT LinkedEntityid, ContentDocumentid FROM contentDocumentLink WHERE LinkedEntityid=:'Object id'])
                {
                   ContentDocumentids.add(CDLink.ContentDocumentid);  
                }
                for ( ContentVersion cversion : [SELECT title, 
                                                        PathOnClient, 
                                                        versiondata 
                                                  FROM contentversion 
                                                  WHERE ContentDocumentId IN :ContentDocumentids  
                                                   AND title LIKE 'WOCF%'])
                 {
                  blob WOCFbody = cversion.versiondata;
                  system.debug('body : '+WOCFbody+'-----------'+cversion.title);
                  Messaging.Emailfileattachment efa1 = new Messaging.Emailfileattachment();
                  efa.setFileName(war2.opportunity__r.name+'-'+cversion.title);
                  efa.setBody(WOCFbody);
                  fileAttachments.add(efa); 
                 }

 
  • March 14, 2018
  • Like
  • 0

Hello,

I want to use property file like Java in Salesforce;
It is possible by custom field but i am not sure if this will serve my usecase.
My use case is
- I want to use all labels in a file instead of editing each label.
- I use two languages, french and english, so i want that language should be based on user selected language. It will be english or fench only.
- I want to translate in Visaulforce pages and Apex class as well.

How can i achieve this use case.

Thank you