0

This question already has an answer here:

I have trigger Code:

Trigger AutoEmailsending on Order (after update) 
{
    Map<Id,Order> Orderdetail = new Map<Id,Order>();
    Set<Id> Accountid = new Set<Id>();
    for(order or1 : Trigger.new)
    {
        if(or1.Status == 'Submitted' && (or1.Subtype__c =='Offer' || or1.Subtype__c =='ASP'))
        {
            Orderdetail.put(or1.id,or1);
            Accountid.add (or1.accountid);
        }
    }
    List<Attachment> Attachmentlst = [Select Id,
                                             ParentId, 
                                             Name,
                                             BodyLength,
                                             Body,
                                             Description 
                                        From Attachment 
                                        where ParentId=:Orderdetail.keyset()];


    for (attachment attachmentlst1 : attachmentlst )
    {

        String Emailaddress = UserInfo.getUserEmail();
       Profile[] profiles = [select id from profile where name in ('Sales Rep - France','Sales Rep - Italy')]; 
        String[] values = new String[0]; 
        for(Profile Id: profiles)
        values.add(Order_Configuration__c.getInstance(id));

         //string SellingOfficePhone = Order_Configuration__c.getInstance().Selling_Office_Phone__c;
         String SellingOfficePhone = Order_Configuration__c.getInstance(UserInfo.getProfileId());
String Market = Accountmap.get(Orderdetail.get(attachmentlst1.ParentId).accountid).Market__c;
        CCaddress.add(emailaddress);
        if(CustomerServiceEmail !=null)
        CCaddress.add(CustomerServiceEmail);


        Messaging.SingleEmailMessage mail = new                   Messaging.SingleEmailMessage();
        mail.setToAddresses(Toaddress);
        mail.setCcAddresses(CCaddress);
        if(Orderdetail.get(attachmentlst1.ParentId).Subtype__c =='Offer' || Market=='FR')
        {
            mail.setSenderDisplayName('Trade Order-FR'); 
            ResourceName = 'TC_for_France';
            TCname = 'CONDITIONS_GENERALES_DEVENTE.pdf';




                strHtmlBody ='Hi,<br/><br/>';


                      strHtmlBody+=+SellingOfficePhone +
                      '


                 mail.setHtmlBody(strHtmlBody);
        }
        else
        {

                if(!String.isBlank(SellingOfficePhone))
                {
                    {
                      strHtmlBody += 

                      +SellingOfficePhone+

                    }
                }

                mail.setHtmlBody(strHtmlBody);
        }



        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
        efa.setFileName(attachmentlst1.Name);
        efa.setBody(attachmentlst1.Body);
        fileAttachments.add(efa);
        Messaging.Emailfileattachment efa1 = new Messaging.Emailfileattachment();
        efa1.setFileName(TCname);
        efa1.setBody(resources.get(resourceName));
        fileAttachments.add(efa1);
        mail.setFileAttachments(fileAttachments);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail}); 
    }
}

I have a order configuration Custom setting object is there and selling office phone field is there inside order configuration Custom setting object and the value is different for two profiles how do i access the profile value for selling office of custom setting in If and another profile value for selling office in else statement I have Tried so many times ,Anyone Guide me for the Answer

marked as duplicate by Tushar Sharma, Guy, Community Nov 25 '16 at 9:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Instead of posting a new question you should add more details to your existing question. – Tushar Sharma Nov 25 '16 at 9:09
  • @TusharSharma I did not get the answer for that question – SFDC Nov 25 '16 at 9:10
  • @tushar sharma update with trigger code – SFDC Nov 25 '16 at 9:11
  • You should wait for sometime. this question is only posted 2 hours before. also you can get CS based on profile Order_Configuration__c.getInstance(UserInfo.getProfileId()); this will work for you. – Tushar Sharma Nov 25 '16 at 9:13