• Subramani_SFDC
  • SMARTIE
  • 609 Points
  • Member since 2013
  • Technology Analyst
  • Infosys


  • Chatter
    Feed
  • 19
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 8
    Questions
  • 247
    Replies
Hello All

I'm sending an HTML email via Apex. But when opening the email in Outllok is empty. Eventhough in the preview I see there is text.
Can you please help?
 
Hi Experts,

i wrote below code after order is created , i need to update the case status 'New'  after any field is updated on case  and i wrote the code like below but  lot of errors, i am not sure how to take case and to update. can you help me pls i wrote the code its totally wrong kindly need a help on this

i am not sure how to use the case here Map<Id, Case> oldMap

if(Trigger.isInsert && Trigger.isAfter){
        OrderHandler.OnAfterInsert(Trigger.new, Trigger.newMap);
}
public static void OnAfterInsert(List<order> lstObject, Map<Id, Case> oldMap)
  {
    
    set<id> caseIds = new set<id>();
    for(order ord : lstObject)
    {
     if(ord.Case__c!= null)
     {
       caseIds.add(ord.Case__c);
     }
     }
     if(caseIds != null)
     {
      
      for(Case obj : caseIds)
        {
            for (String fieldName: schemaFieldMap.keySet())
                {
                 if((obj.get(fieldName) != oldMap.get(obj.Id).get(fieldName)))
                {
                    (obj.status=='Partially Complete')) ? obj.status : 'New';
                    break;
                }
            
                
        }
        }
      
      }
      }
Hi All,

I am getting the below Error for my Template - VF_Quote Email Template :

Error occurred trying to load the template for preview: List has no rows for assignment to SObject. Please try editing your markup to correct the problem.

Code for VF_Quote Email Template (Visualforce Template):
 
<messaging:emailTemplate subject="Dear Approver, Quote Number {!relatedTo.QuoteNumber} {!relatedTo.Name} was sent for your approval {!relatedTo.Urgent_Text__c}" recipientType="Contact" relatedToType="Quote">

<messaging:htmlEmailBody >
   
   
<html>

    <img src="http://photos.prnewswire.com/prnvar/20120528/535447?max=400" width="250" height="30"/>
    
    
    

  <head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
    <meta name="Template" content="Response"/>
    
    <style>
    td {
        text-align: right;
        font-family: Verdana;
    }
    
    p{
        text-align: left;
        font-family: Verdana;
    }
    
    h3 {
        font-family: Verdana;
    }
    
    </style>

  </head>
    <body>
        
        <br/>
        <p> <h3><b> Dear Approver, </b> </h3> </p>
        
        <br/>
        
        <p> <b> Quote {!relatedTo.QuoteNumber} {!relatedTo.Name} was sent for your approval . <font color="#FF9900"> <apex:outputText value="Urgent" rendered="{!relatedTo.Urgent__c}"/> </font></b> </p>

        <p> <u> <b> Opportunity Owner : </b> </u>  <c:QuoteEmailTemplate2 theQuoteId="{!relatedTo.Id}"/> </p>
        
        <p> <u> <b> Opportunity Territory : </b> </u>  <c:QuoteEmailTemplate3 theQuoteId="{!relatedTo.Id}"/> </p>
        
        <p> <u> <b> Account : </b> </u>   {!relatedTo.BillingName} (#{!relatedTo.Account_Number__c })</p>
       
        <p> <u> <b>Sales Type:</b> </u>  {!relatedTo.bl_Sales_Type__c}   </p>
        
        <p> <u> <b> Upgrade/Traded : </b> </u>  {!relatedTo.Upgrade_Traded_In_Equipment_Type__c}   </p>
        
        <p> <u> <b>Comments for Approval : </b> </u>  {!relatedTo.Comments_For_Approval__c}   </p>
        
        <p> <u> <b> Payment Method </b> </u>: {!relatedTo.Payment_Method__c} <c:QuoteEmailTemplate4 theQuoteId="{!relatedTo.Id}"/> 
        
        
          {!relatedTo.Number_Of_Installments__c}, 
        
         <u> <b> Payment Notes : </b> </u> {!relatedTo.Payment_Notes__c}  </p>
         <p> <u> <b> Payment Notes in English : </b> </u> {!relatedTo.Payment_Note__c}  </p>
          <p> <u> <b>Payment Type : </b> </u>  {!relatedTo.Payment_Type__c }   </p> 
         
          <p> <u> <b> Special Instructions :</b> </u>  {!relatedTo.Special_Instructions__c}   </p>
          
          <p> <u> <b> Obligation : </b> </u> {!relatedTo.Obligation__c}   </p>
          
           <p> <u> <b> Amount for the Obligation : </b> </u> {!relatedTo.Amount_for_the_Obligation__c}   </p>
          
          
        
        <table BORDERCOLOR="blue" style="solid">
                <tr>
                  
                    <th bgcolor="blue"> <font color="#fff"> <b> Product Name</b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> Part/KIT Code</b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> List Price</b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> Quantity</b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> Sales Price</b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> Total Sales Price</b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> Line Discount </b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> GM</b> </font> </th>
               <!-- <th bgcolor="blue"> <font color="#fff"> <b> Target Price </b> </font> </th>
                    <th bgcolor="blue"> <font color="#fff"> <b> Discount from Target price </b> </font> </th> -->
                    
                </tr>
                <apex:repeat var="item" value="{!relatedTo.QuoteLineItems}">
                <tr>
                 
                    <td bgcolor="#E2E1E1" text="alignright;"> <p>{!item.Product2.Name} </p> </td>
                    <td bgcolor="#E2E1E1">{!item.Part_KIT_Code__c}</td>  
                    <td bgcolor="#E2E1E1">{!item.VF_Total_Line_List_Price__c}</td>
                    <td bgcolor="#E2E1E1">{!item.Quantity}</td>
                    <td bgcolor="#E2E1E1"> {!item.VF_Sales_Price_After_Discount__c}</td>
                    <td bgcolor="#E2E1E1"> {!item.VF_Total_Sales_Price__c}</td> 
                    <td bgcolor="#E2E1E1">  {!item.Line_Discount_Calculated__c} </td>
                    <td bgcolor="#E2E1E1">  {!item.QLI_Gross_Margin__c} </td>
              
                </tr>
                </apex:repeat> 
          </table> 
          
          <p> <u> <b> Opportunity Currency :</b> </u> {!relatedTo.Opp_Currency__c}   </p>
                    
          <p> <u> <b> Total Deal :</b> </u> {!relatedTo.VF_TotalPrice__c}   </p>   
          
          <p> <u> <b> Customer Discount :</b> </u> {!relatedTo.Customer_Discount__c}%   </p>   
          
          <p> <u> <b>  Internal Discount :</b> </u> <c:QuoteEmailTemplate1 theQuoteId="{!relatedTo.Id}"/>*(after target,promotion) </p>

          <p> <u> <b> Gross Margin  :</b> </u>  {!relatedTo.Quote_Gross_Margin__c}%  </p>
          
          <p> <u> <b> Billing Address : </b> </u> {!relatedTo.BillingStreet}, {!relatedTo.BillingCity}, {!relatedTo.BillingState}, {!relatedTo.BillingCountry}, {!relatedTo.BillingPostalCode}  </p>
        
          <p> <u> <b> Shipping Address : </b> </u>: {!relatedTo.ShippingStreet}, {!relatedTo.ShippingCity}, {!relatedTo.ShippingState}, {!relatedTo.ShippingCountry}, {!relatedTo.ShippingPostalCode} </p>        
        
          <p> <u> <b>For further info on the quote </b> </u>: <a href="https://syneron-candela.my.salesforce.com/{!relatedTo.Id}">Link</a> </p>  
          
          <p> <u> <b> Please approve or reject using one of the following options </b> </u> : </p> 
          
          <p> <b> 1.  Through the approval request page: </b> </p> <a href="https://Test.my.salesforce.com/home/home.jsp"> Home Page </a>
          
          <p> <b> 2.   Reply this mail with the one of the following key words: </b> </p>
          
          <p>  <b>  Approve / Approved / Reject / Rejected / Yes / No </b> </p>
          
          
          <p> <b> Thank you,  &nbsp; <c:QuoteEmailTemplateOppOwnerName theQuoteId="{!relatedTo.Id}"/> </b> </p>
          
        
     </body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 
how to create apex trigger using email message in email to case (automatically task sholud created notification have to come using salesforce lightind)uisng apex trigger ,can anyone tell me this requiremnt as soon as possible?
can you please me to write test class on below code:
Apex code:

public class copycontact {
    public list<selectoption>account1{set;get;}
    public list<selectoption>account2{set;get;}
    public list<contact>contacts{set;get;}
    public String getListOfAccounts { get; set; }
    public id selectedaccountId1 {set;get;}
    public id selectedaccountId2 {set;get;}
    public list<id>selected ;
    public List<SelectOption> getListOfAccounts1()
    {
        List<Account> AccountList1 = [select id,Name from Account] ;
        System.debug('Accounts'+AccountList1.size());
        account1 = new List<SelectOption>();
        account1.add(new SelectOption( ' ' ,'---Select---'));
        for(Account acc : AccountList1 )
        {
            account1.add(new SelectOption(acc.id , acc.Name));
        }
        return account1 ;         
    }
    public List<SelectOption> getListOfAccounts2()
    {
        List<Account> AccountList2 = [select id,Name from Account] ;
        System.debug('Accounts'+AccountList2.size());
        account2 = new List<SelectOption>();
        account2.add(new SelectOption( ' ' ,'---Select---'));
        for(Account acc : AccountList2 )
        {
            account2.add(new SelectOption(acc.id , acc.Name));  
        }
        system.debug('java');
        return account2 ;  
    } 
    public  void clonecontacts(){
        system.debug('gsvdd');
        if(selectedaccountId1!=null){
            contacts=new list<contact>([select id,lastname from contact where accountid=:selectedaccountId1]);
            if(contacts.size()==0){
                system.debug('gsg'   );
               ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'No contacts to display'));
            }
            else{
                system.debug('dhg');
                list<contact>clist=new list<contact>();
                for(Contact con:contacts){
                    contact c=new contact();
                    c.lastname=con.LastName;
                    c.AccountId=selectedaccountId2;
                    clist.add(c);
                }
                insert clist;
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'successfully copied'));
            }
        }
    }
}
vf page:

<apex:page controller="copycontact">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="from Account" >
                <apex:OutputPanel >
                    <apex:selectList value="{!selectedaccountId1}" size="1" multiselect="false" >
                        <apex:selectOptions value="{!ListOfAccounts1}"  />
                    </apex:selectList>
                </apex:OutputPanel>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock >
            <apex:pageBlockSection title="to account">
                <apex:selectList value="{!selectedaccountId2}" size="1" multiselect="false"  >
                    <apex:selectOptions value="{!ListOfAccounts2}" />
                </apex:selectList>
            </apex:pageBlockSection> >
        </apex:pageBlock>
        <apex:commandButton value="clone" action="{!clonecontacts}"/>
        <apex:pageMessages ></apex:pageMessages>
    </apex:form>
</apex:page>
Hi,

I have a user with Consulting-Sr.manager as profile. I have given all the access permission that a User should need and able to run and schedule reports. Still I am getting warning message as below;
However I tried giving access to "Manage Public Reports" permission , then the issue is resolved . But problem is the User got the rights to modify other public reports as well which I dont need. He should be able to have access only to his reports. Please suggest

User-added image
Hi All,
my requirement is given below:-
Need a Tab Configure History Tracking
It will open a view where user will see a DropDown Select Object, all Native and Custom Objects will be listed on it
Upon selection it will show list of all fields for that object, this screen should match to native screen.
i am trying to build a visualforce page can anyone guide me?

Here's what I've been staring at for 16 minutes so far. 

User-added image

Deployed via SFDX, specifying a single apex test to run, which has less than 40 lines of code. Takes only a fraction of a second to run in scratch org or sandbox.

But when I deploy to Production, all components are validated within a minute or two, then the status switches to 'Running {testname}'.... and stays that way. For literally 15 minutes or more. Before the test is even started. 

I'm not finding a lot of posts on this issue. Plenty of people talking about the time it takes to actually run the test. But I'm talking about the time it takes to start running the tests. This isn't a one time thing, but it also isn't consistent. Sometimes the tests will begin running pretty much immediately. Sometimes I'll end up cancelling and redeploying because a 30 minute delay to START testing seems ridiculous even given Salesforce's standards. And when I do cancel and redeploy? Good chance it'll take a fifth of the time, for no apparent reason.

What I'd really like is some better communication during this process. Why is my test run delayed? What was prioritized ahead of it? How can I anticipate deployment times so it's not a complete crapshoot regardless of build size? 

Field (1) How_did_you_hear_about_us__c has the following values and it is a multi picklist field

Brochure
Bus Advert
EDM [Email]
Events
Facebook
Instagram
Others
Parent Forum
Search Engine
Twitter
Website
Word of Mouth

Field 2 Others_How_did_you_hear_about_us__c is a text field (50 characters)

I am having trouble in writing a validation rule, if 'Others' is selected from field 1, field 2 need to be manadatory.  and if rest of the values are choosen, the Field 2 is not mandatory.  I have a situation if the user select 'Others' and some other options, the record is not able to save, I need some help on this, for example if I choose (Instagram, Others, Parent Forum), I cannot save the record

 
Hi, I have created an approval process and to access that we are using custom approval page, reassign page and recall page. I want to add "comments" field in Reassign page the same way it exists in standard functionality. But when I tried to add it on custom page then I got an error message "field is not writable". We have used workbench as well to access it but no luck. Can anyone help in that if it is a possibility!
Guys,

We have a custom field on case obj called email address.
I want to show the list of cases that have same email address on a case record.

Something like,

A related list on the case record that shows the list of cases(previous inquiries) that are from same email address.

Right now enhanced lookup is not available on the case object,  and also
we dont want to create contacts from these cases.

I couldn't get started on this.

Are there any other ways to do this other than using apex?
If not, how to code this via apex?

Appreciate your help!
Hello,

I have a connection to external webservices, how can i track the erros and the execution order of this 
?