• Shubham Sinha 43
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 2
    Replies
Hello Everyone,
I have a requirement where i need to create a lightning button which updates the subject of email message of  a case. How to cater this requirement . Please help .Thanks in advance
hello ,
I am trying to call a future method from after insert but getting some error, below is the code piece  
 
@future
     public static void updateEmailTemplateId(List<ID> recordIds){
      List<Case> cassesList = [SELECT id,THA_Case_Language__c,THA_Source__c, NPR_Member_Segment__c,Subject,
                              Email_Template__c from case WHERE id IN :recordIds];

         List<String> IdCase = new List<String>();
         //for(Case caseIters :casesList){
       //    IdCase.add(caseIters.id);
     //  } 
     List<Case> lst = new List<Case>();
       
       for(Case c :[select Id,Email_Template__c from case where Id IN :Trigger.New]){
      String templateName = 'THA_Tmp_' + DateTime.now().getTime();
        System.debug('templateName=' + templateName);
        
        c.Email_Template__c = 'hey bro';

  lst.add(c);
       {
       update lst;

       }

     
     }
     
   }

calling this method from after inset trigger like ;-

 if(Trigger.isAfter && Trigger.isInsert){   
    

    THA_Case_Trigger_Cx.updateEmailTemplateId(Trigger.NEW);
     
   }
Error is - 
Method does not exist or incorrect signature: void updateEmailTemplateId(List<Case>) from the type THA_Case_Trigger_Cx at line 65 column 25.

Can anyone please help me out to know why I am getting this error and how to solve it .
I need to convert my method to future method . How to do that below is the code piece :-
global ID getDefaultEmailTemplateId() {
        
        String templateName = 'THA_Tmp_' + DateTime.now().getTime();
        System.debug('templateName=' + templateName);
        
        String emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_EN__c;
        if(UserInfo.getProfileId() == THA_Utils.getProfileIdByName('CCU Support') || UserInfo.getProfileId() == THA_Utils.getProfileIdByName('CCU Support Manager')) {
            if(caseLanguage == 'FR') {
                emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_CCU_Template__c;
            } else if(caseLanguage == 'NL') {
                emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_CCU_Template_NL__c;
            } else if(caseLanguage == 'DE') {
                emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_CCU_Template_DE__c;
            } else if(caseLanguage == 'EN') {
                emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_CCU_Template_EN__c;
            }
            
        } else if(caseSource == 'Izy') {
            if(caseLanguage == 'FR') {
                emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_Izy_FR__c;
            } else if(caseLanguage == 'NL') {
                emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_Izy_NL__c;
            } else {
                emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_Izy_EN__c;
            }
        } else {
            if(caseTTC == 'No') {
                if(caseLanguage == 'FR') {
                    emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_FR__c;
                } else if(caseLanguage == 'DE') {
                    emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_DE__c;
                } else if(caseLanguage == 'NL') {
                    emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_NL__c;
                }
            } else {
                if(caseLanguage == 'FR') {
                    emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_TTC_FR__c;
                } else if(caseLanguage == 'DE') {
                    emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_TTC_DE__c;
                } else if(caseLanguage == 'NL') {
                    emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_TTC_NL__c;
                } else if(caseLanguage == 'EN') {
                    emailTemplateId = THA_Thalys_Variables__c.getInstance().THA_Id_EmailTemplate_TTC_EN__c;
                }
            }
        }
        
        EmailTemplate source = [SELECT description, encoding, HtmlValue, subject, TemplateStyle, TemplateType, BrandTemplateId 
                                FROM EmailTemplate 
                                WHERE id = :emailTemplateId];
        
        EmailTemplate clone = source.clone();
        clone.developerName = templateName;
        clone.Name = templateName ; 
        
        clone.folderId=THA_Thalys_Variables__c.getInstance().THA_Id_TmpEmailTemplate_Folder__c;
        clone.IsActive=true;
        System.debug('STL : caseId: ' + caseId);
        if(new THA_TemplateGenerator_Cx(caseId).generateEmailTemplateText() != NULL ){
            clone.HtmlValue = clone.HtmlValue.replace('##dynamic_content##', new THA_TemplateGenerator_Cx(caseId).generateEmailTemplateText());
            //clone.HtmlValue += '</br><div>{!Case.THA_TECH_Ref_Email2Case__c}</div>';
            System.debug('SMARTLOADER TEMPLATE :' + clone.HtmlValue);
        } else {
            Case caseTmp = [SELECT THA_Case_Language__c, THA_Source__c 
                            FROM Case 
                            WHERE Id=:caseId];
        }
        
        Database.SaveResult res = Database.insert(clone);
        System.debug('EmailTemplate inserted in the getDefaultEmailTemplateId method : ' + res);
        
        //We delete the temporary email template as soon as it's used
        //futureDeleteTmpEmailTemplate(res.Id);
        
        return res.getId(); 
    }
and above method is passing as a perameter of another method,
like this .
sendEmailDefaults.setTemplateId(getDefaultEmailTemplateId())
how to convert this . Please help.
I am trying to encrypt  an 'auto number'  custom field but i am getiing the errro "void valueOf(Schema.SObjectField) from the type Blob".
Public static string getToken(){
    
        String userIdKey = ('U' + UserInfo.getUserId()).left(16);
                    Blob salt = Blob.valueOf(userIdKey);
                    Blob key = Crypto.generateAesKey(128);
                    Blob data = Blob.valueOf(BIIB_Remote_Consent_Initiator__c.Name);// I am getting error here.
                    Blob encrypted = Crypto.encrypt('AES128', key, salt, data);
                    String encryptedItemCode = EncodingUtil.urlEncode(EncodingUtil.base64Encode(encrypted), 'UTF-8');
                    String encryptedPublicKey = EncodingUtil.urlEncode(EncodingUtil.base64Encode(key), 'UTF-8'); 

 

                    String reportid = EncodingUtil.urlEncode(encryptedItemCode + '+' + encryptedPublicKey, 'UTF-8');
                    system.debug('reportID ' +reportid);

                   reportid = EncodingUtil.urlDecode(reportid, 'UTF-8');
        
            String parameterValue = reportid;
            String encodedItemCode = parameterValue.split('\\+')[0];
            String encodedKey = parameterValue.split('\\+')[1];
                        
             userIdKey = ('U' + UserInfo.getUserId()).left(16);
             salt = Blob.valueOf(userIdKey);
             key = EncodingUtil.base64Decode(EncodingUtil.urlDecode(encodedKey, 'UTF-8'));
             encrypted = EncodingUtil.base64Decode(EncodingUtil.urlDecode(encodedItemCode, 'UTF-8'));
            Blob decrypted = Crypto.decrypt('AES128', key, salt, encrypted);
            String itemCode = decrypted.toString();

system.debug('itemcode ' +itemCode);
return reportid;
    
    }

 
I have a hierarchical custom  setting called Audience__C and i have a checkbox field 'Booking__c'. now i have a requirement if booking__c is checked then update a field. So, how to query and put if condition on custom setting.We are using "Default Organization Level Value".

Please help on this.
I have a requirement where I need to show two different message according to the selected value of custom setting record. Like if I unchecked the record "some message" and if i checked the record "different message".  How can i do this.Please help
HI,
How to write test class for the below code. Please help me on this.
public class BIIB_ADU_ManageConsent_Controller{
    static Id recordTypeId = BIIB_Utility_Class.getRecordTypeId(BIIB_Adu_Constant.CONSENT_OBJECT, BIIB_Adu_Constant.CONSENT_RECORDTYPE );
    
    /**
* Method Name :     getConsentManagement
* @author:
* @description:     Aura Method to get consent management record 

**/
    @AuraEnabled
    public static List<BIIB_Consent_Management__c> getConsentManagement(){
        //Map<String,BIIB_Consent_Management__c> mapConsent = new Map<String,BIIB_Consent_Management__c>();
        User us = [Select id, accountId from User where Id = :UserInfo.getUserId()];
        List<BIIB_Consent_Management__c> consentList = new List<BIIB_Consent_Management__c>();
        system.debug ('User name' + us);
        ID AccountId = us.accountID;
        System.debug ('account name ' + AccountId );
        consentList= [SELECT ID,BIIB_Consent_Type__c,BIIB_SignatureFirstName__c,BIIB_SignatureLastName__c,BIIB_Status__c,BIIB_Effective_Date__c,CreatedDate 
                      FROM BIIB_Consent_Management__c WHERE 
                      BIIB_Patient_Account__c =: AccountId AND
                      BIIB_Status__c = :BIIB_Adu_Constant.CONSENT_STATUS AND
                      BIIB_Consent_Flag__c = true AND
                      RecordTypeId = :recordTypeId AND
                      (BIIB_Consent_Type__c = :BIIB_Adu_Constant.CONSENT_TYPE_HIPAA OR
                       BIIB_Consent_Type__c = :BIIB_Adu_Constant.CONSENT_TYPE_PATIENTSERVICES) 
                     LIMIT 2];
        
        Map<String,BIIB_Consent_Management__c> mapConsent = new Map<String,BIIB_Consent_Management__c>();
        for(BIIB_Consent_Management__c cm:consentList){
            mapConsent.put(cm.BIIB_Consent_Type__c,cm);
        }
        if(!mapConsent.containsKey(BIIB_Adu_Constant.CONSENT_TYPE_HIPAA)){
            consentList.add(new BIIB_Consent_Management__c(BIIB_Consent_Type__c=BIIB_Adu_Constant.CONSENT_TYPE_HIPAA));
        }
        if(!mapConsent.containsKey(BIIB_Adu_Constant.CONSENT_TYPE_PATIENTSERVICES)){
            consentList.add(new BIIB_Consent_Management__c(BIIB_Consent_Type__c=BIIB_Adu_Constant.CONSENT_TYPE_PATIENTSERVICES));
        }
        return consentList;
    }
    
    
}
Hello Everyone,
There is one standard object 'Case' which has one related object called 'Replacement__c'. When a case record is created we are creating four potential records for that case. So, now requirement is whenever someone change the status of one replacement record say 'Selected', other three reoords should automaticaly updated as'Not Selected'. 

I need help how I can do it.
I need to update parent record from child record. So, I have  four objects- Case, WorkOrder, ServiceAppointmen, ServiceReport. I need to write a trigger when ServiceReport record is created then field (Test__c)  of Case object should be checked. Case is parent object of  Workorder, Workorder is parent Object of ServiceAppointment, ServiceAppointment is Parent object of Service report. I have written a trigger and able to upate the field of ServiceAppointment when service report is created but I need to update the field of case .So, I am unable to fetch the Case record's detail from my triggger and do the updation.

trigger :-
trigger sendEmail on ServiceReport (After insert) {
            list<Id> SerApp = new list<id>();
    for(ServiceReport sr : trigger.new){
        SerApp.add(sr.Parentid); 
    }
             list<ServiceAppointment> sa = [SELECT id,Report_Generated__c from ServiceAppointment WHERE id in: SerApp];
      for(ServiceAppointment a : sa){
                a.Report_Generated__c = true;
              }
         update sa;


}

 
I have a hierarchical custom  setting called Audience__C and i have a checkbox field 'Booking__c'. now i have a requirement if booking__c is checked then update a field. So, how to query and put if condition on custom setting.We are using "Default Organization Level Value".

Please help on this.
Hello Everyone,
There is one standard object 'Case' which has one related object called 'Replacement__c'. When a case record is created we are creating four potential records for that case. So, now requirement is whenever someone change the status of one replacement record say 'Selected', other three reoords should automaticaly updated as'Not Selected'. 

I need help how I can do it.