• aparna d 1
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 8
    Replies
Hi Everyone,
I have requirement , We have object called project  and 16 checkbox fields  and ORR Process picklist. When we select ORR Process picklist as "Yes" then  these 16 checkbox should be checked and then 16 tasks should be creted automatically. These checklist should be visible on a tab before Activity tab on project record.
Could you please suggest  how can we achive this requirement. 
Thanks in advance
 
Hi Everyone,
I have requirement ,if Case Record has .csv file attached, we need that file to attach to the email template when the record is set to closed. Can  anyone please suggest how can we attach case files to email template.
How to get the list of users that show their EAC status. Can any one Please help me on this.

 
Hi Everyone am facing issues with archive article test class and can't able to findout the solution. If any one have idea on this please help me.Thanks in advance

global class BatchArchiveKB implements Database.Batchable<SObject> {
    global string query;

    global BatchArchiveKB() {
        Map<String, ArchiveKB__mdt> mapCMD = ArchiveKB__mdt.getAll();
    
    }

    global Database.QueryLocator start(Database.BatchableContext BC){
         ArchiveKB__mdt[] KBids = [Select Id, Salesforce_ID__c from ArchiveKB__mdt];
          Set<String> sfid = new Set<String>();
              for(ArchiveKB__mdt record:KBids) {
                  sfid.add(record.Salesforce_ID__c);
            }
        System.debug('sfids'+sfid);
         return Database.getQueryLocator([Select Id, KnowledgeArticleId FROM Customer_Support__kav WHERE ID =:sfid]);
  
    }
            
    global void execute(Database.BatchableContext BC, List<Customer_Support__kav> todelete) {
        system.debug('Todelete'+todelete);
        for (Customer_Support__kav kav:  todelete)
        {
            KbManagement.PublishingService.archiveOnlineArticle(kav.knowledgeArticleId,null);
             System.debug(kav.Id);
        }   
       
    }
     global void finish(Database.BatchableContext bc){
    
    }

}

Test class
-----------------------------------
@isTest
public class BatchArchiveKB_test {
    
    @testVisible static List<ArchiveKB__mdt> articlemap{ 
        get{ 
            if(articlemap == NULL){ 
                articlemap = [SELECT Id, Salesforce_ID__c FROM ArchiveKB__mdt]; 
            } 
            return articlemap; 
        } 
        set; 
    } 
    
    @istest
    public static void testBatchArchive(){
        
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs (thisUser) 
        {
          Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
          User u = new User(Alias = 'standt', Email='test@test.com', 
            EmailEncodingKey='UTF-8', LastName='Testing',  
            LocaleSidKey='en_US', ProfileId = p.Id, 
             UserName='sdss123@test.com');

        
        Customer_Support__kav kv = new Customer_Support__kav();
        kv.Title='test';
        kv.urlname='testurl';    
        kv.Summary= 'test';
        kv.IsVisibleInPkb=true;
        kv.IsVisibleInCsp=true;
        kv.IsVisibleInPrm =true;
        // kv.PublishStatus ='online'
        //kv.language='en_US';
        insert kv;
               
        Test.startTest();
        Customer_Support__kav kbs = [Select KnowledgeArticleId from Customer_Support__kav where ID = :kv.Id];
        string articleid = kbs.KnowledgeArticleId ;
      
        KbManagement.PublishingService.archiveOnlineArticle(articleid, null);
        
       
        BatchArchiveKB bc = new BatchArchiveKB ();
        Database.executeBatch(bc,200);
        
        
        Test.stopTest();
    }
    
    }    
}
Hi everyone,

How to archive bulk knowledge articles. I have list of articles 1000 provided by business team .Can any please help me on this how to archive bulk articles.

Thanks in advance
Hi ALL,

I am  trying to Reactiving the Users using data loader but am getting below error .Please some one help on this, Thanks in advance

ERROR: UserValidateFederationId: execution of AfterUpdatecaused by: System.DmlException: Update failed. First exception on row 0 with id 0031Y00005obhRdQAI; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Contact, original object: User: []Class.PC_UserHandler.pushUserValuesToContact: line 161, column 1Trigger.UserValidateFederationId: line 17, column 1
 
Hi All,

I am getting issue with Apex CPU time limit exceeded when i click on the button and error is coming from below method. Can any one please help meon this.
Thanks in advance

public List<salesforcerequestdocumentSfaccountreque.Contract> buildContractClassHierarchy (SB_Account_Letter__c serviceLetter, list<Asset__c> assetList, SB_Ref_Table__c letterDetails, list<Contract_c__c> selectedcontractList)
    {
        list<salesforcerequestdocumentSfaccountreque.Contract> result = new list<salesforcerequestdocumentSfaccountreque.Contract>();
        set<Id> contractSet = new set<Id>();
        list<Contract_c__c> allContracts = new list<Contract_c__c>();
        list<Asset__c> allAssets = new list<Asset__c>();
        list<Buyout__c> allBuyouts = new list<Buyout__c>();
        //1697
       // if (letterDetails.Letter_Code__c == 'USACCREPOSLTR')
        if (letterDetails.Class__c == '7') 
        {
           for (Contract_c__c sc :selectedcontractList)
          { 
           contractSet.add(sc.id);
        
           }
         }
            
        for (Asset__c a: assetList){
            contractSet.add(a.Contract_Number__c);
        }
        allContracts = this.getContractList(serviceLetter, contractSet, letterDetails);
        allAssets = this.getAssetList(allContracts, assetList);
        allBuyouts = this.getBuyoutList(contractSet);
        
        for (Contract_c__c c: allContracts)
        {
            salesforcerequestdocumentSfaccountreque.Contract cVO = new salesforcerequestdocumentSfaccountreque.Contract();
            cVO.Assets = new salesforcerequestdocumentSfaccountreque.Assets();
            cVO.Assets.Asset = new list<salesforcerequestdocumentSfaccountreque.Asset>();
            
            System.debug('medar heap before populateContractInfo call: '+ Limits.getHeapSize() );      
            populateContractInfo (c, cVO);
            System.debug('medar heap after populateContractInfo call: ' + Limits.getHeapSize() ); 
            
            for (Asset__c a: allAssets)
            {
                if (c.Id == a.Contract_Number__c)
                {
                    salesforcerequestdocumentSfaccountreque.Asset aVO = new salesforcerequestdocumentSfaccountreque.Asset();
                    
                    System.debug('medar heap before populateAssetInfo call:' + Limits.getHeapSize() );  
                    aVO = this.populateAssetInfo (a);
                    System.debug('medar Heap after populateAssetInfo call: ' + Limits.getHeapSize() );
                    system.debug('medar Heap size is: ' + Limits.getHeapSize());
                    cVO.Assets.Asset.add (aVO);
                     System.debug('medar after cVO.Assets.Asset.add (aVO)' );
                    system.debug('medar Heap size is before null aVO: ' + Limits.getHeapSize());
                    aVO = null;//medar attempting to reduce heap
                    system.debug('medar Heap size is after null aVO: ' + Limits.getHeapSize());
                }
            }
            
            if (letterDetails.Class__c == '2')
            {
                cVO.Buyouts = new salesforcerequestdocumentSfaccountreque.Buyouts();
                cVO.Buyouts.Buyout = new list<salesforcerequestdocumentSfaccountreque.Buyout>();
                for (Buyout__c b: allBuyouts)
                {
                    if (c.Id == b.Contract__c)
                    {
                        salesforcerequestdocumentSfaccountreque.Buyout bVO = new salesforcerequestdocumentSfaccountreque.Buyout();
                        System.debug('medar before bVO = this.populateBuyoutInfo(b)' );  
                        bVO = this.populateBuyoutInfo(b);
                        System.debug('medar after bVO = this.populateBuyoutInfo(b)' );  
                        cVO.Buyouts.Buyout.add(bVO);
                        system.debug('medar  Heap size before bVO is nulled: ' + Limits.getHeapSize());
                        bVO = null;//medar trying to reduce heap
                        system.debug('medar  Heap size after bVO is nulled: ' + Limits.getHeapSize());
                        System.debug('medar after cVO.Buyouts.Buyout.add(bVO);' );  
                    }
                }
            }
            System.debug('medar before result.add(cVO);' );
            result.add(cVO);
            System.debug('medar after result.add(cVO);' );
        }
        return result;   
    }
 
I have created listview button on lead .If we select multiple Lead records with different company names then click on list view button error should be display.
Can anyone please help me on this.

 
I have a requirement case is assigned to queue .If queue member is changed owner to any one of queue member then giving acces to public group memebrs. Am getting issues please help on this 
Public static void ShareReq(List<Case> listCase,Map<Id,Case> caseOldMap){
        Set<id> qmemberId = new Set<Id>();
        Set<id> gpmemId = new Set<Id>();
        Map<Id,Id> mapid = new Map<Id,Id>();
        list<CaseShare> casesharelist= new list<CaseShare>();
              Id devRecordTypeId = Schema.SObjectType.case.getRecordTypeInfosByName().get('Proposal case').getRecordTypeId();
        Id queuegp = [select Id, type from Group where type='Queue' AND Name=' Request Queue'].id;
          
        List<GroupMember> queuemem = [SELECT GroupId,Id,UserOrGroupId FROM GroupMember WHERE GroupId =:queuegp]; 
        for(GroupMember qmem : queuemem){
            
            qmemberId.add(qmem.UserOrGroupId);
        }
        Id gpid = [select Id, type from Group WHERE Name = 'test group'].id;
        List<GroupMember> gplst = [SELECT GroupId,Id,UserOrGroupId FROM GroupMember WHERE GroupId =:gpid];
       
        for(case newcase:listCase){
            Case oldcase= caseOldMap.get(newcase.id);
            for(GroupMember gpmem : gplst){
                if(newcase.RecordTypeId == devRecordTypeId && qmemberId.contains(newcase.OwnerId) && newcase.OwnerId != oldcase.OwnerId) {
                    CaseShare caseSharingRules= new CaseShare();
                    caseSharingRules.UserOrGroupId = gpmem.UserOrGrou
                   caseSharingRules.CaseAccessLevel = 'Edit';        
                   casesharelist.add(caseSharingRules);
                }
           }
        }
        
        if(casesharelist.size()>0)
            insert casesharelist;
    }
        
calling this method in trigger 
public override void bulkAfter(){
if(trigger.isUpdate){
CSCaseHandler.ShareReq(trigger.new,(Map<Id,Case>)Trigger.oldMap);
}
}
I want to display case fields based on related opportunity recordtype. I am facing issues.Anyone please help on this.

<apex:page standardController="Case"   showHeader="false" applyBodyTag="false" applyHtmlTag="false">
<apex:form >
<apex:outputPanel rendered="{!IF(Case.Opportunity__r.RecordType.Name =’proposed Recordtype’,true,false)}"> -->
<apex:pageBlocksection >
<apex:outputLabel value="space" /> 
<apex:inputField value="{!Case.space__c}" />
</apex:pageBlocksection>
</apex:outputPanel >

<apex:outputPanel rendered="{!IF(Case.Opportunity__r.RecordType.Name =’Intial Recordtype’,true,false)}"> -->
<apex:pageBlocksection >
<apex:outputLabel value="counter" /> 
<apex:inputField value="{!Case.counter__c}" />
</apex:pageBlocksection>
</apex:outputPanel >
</apex:form> 
</apex:page>
How to write a test  class on below code. please help me.Thanks in advance

public void selectOD(){
        IdList.clear();
        selectedOD.clear();
        selectedODOP.clear();
        
       for(oppwrapper ow : soplist) {
            
            if(ow.selected == true){
                mandatePD.put(ow.subopp.Id,ow.ODMap);
                SelectedQuotes.put(ow.subopp.Id,ow.ODMap);
                if(!IdList.containsKey(ow.ODMap)){
                     IdList.put(ow.ODMap, new List<String>{ow.subopp.Id});
                    }else{
                     IdList.get(ow.ODMap).add(ow.subopp.Id);
                    }
                if(ow.subopp.recordtype.name == ' Services'){
                    if(!selectedODOP.containsKey(ow.ODMap)){
                     selectedODOP.put(ow.PDMap, new List<String>{ow.subopp.description});
                    }else{
                     selectedODOP.get(ow.ODMap).add(ow.subopp.description);
                    }
                }
                else if(ow.subopp.recordtype.name != 'machinery'){
                    if(!selectedPD.containsKey(ow.ODMap)){
                     selectedPD.put(ow.ODMap, new List<String>{ow.subopp.description});
                    }else{
                     selectedPD.get(ow.ODMap).add(ow.subopp.description);
                    }
                }               
            }
        }
public pagereference save(){
    try{
        selectOD();
        List<Screening__c> creditapproval = new List<Screening__c>();
        String solarentity;
        String paymentterms;
        String payschedule;
        List<Opportunity> AllOpps = new List<Opportunity>();
        id Creditrectypeid =Schema.SObjectType.Screening__c.getRecordTypeInfosByName().get('Approval').getRecordTypeId();
        creditapproval=[Select id,Name,Solar_Entity__c,Invoice_Payment_Terms__c,Percentages__c,from Screening__c where Related_Opportunity__c=:masterOppID AND recordtypeid=:Creditrectypeid order by CreatedDate desc limit 1];
        
        For(Screening__c creditobj:creditapproval){
            
            solarentity= creditobj.Solar_Entity__c;
            paymentterms=creditobj.Invoice_Payment_Terms__c;
            payschedule=creditobj.Percentages__c;
        }
        
        pdcommon=new ProjectCreation.wrappdheader(pd.PO_Status__c,SelectedrevRecMethod,Selectedsplitship,Selectedpartialship,Selectedfreightbill,
                                 monthsNonOp,monthsOp,expandWarrnty,SelectedtechTrain,wrntynotes,paymentterms,payschedule,jobcode,solarEntity); 
        AllOpps.addall(selectedsubopps.values());
                boolean pdmandate=false;
                for(string s:mandateOD.values()){
                system.debug('$$$$$$'+s);
                    if(s == null){                   
                        pdmandate = true;                       
                    }
                }
                if(pdmandate == true){
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Kindly select the PD'));                       
                }
                else{
                    system.debug('master project id: '+mp.id);
                    if(mp.Revenue_Lock__c == 'Lock'){
                    mp.Revenue_Lock__c = 'Unlock';
                    update mp;}
                    Creation.createPDHeader(mp,AllOpps,pdcommon,selectedOD,selectedODOP,SelectedQuotes,OppIds,IdList);    
                    return new PageReference('/'+mp.Id);
                }
       }
       catch (Exception e){
            System.debug('An exception occurred: ' + e.getMessage());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getDMLMessage(0)));
            
      }
      return null;
    }
I have a requirement while inserting and updating of information records ,fetch values from opportunity and populate on Information object . opportunity is a lookup field on Information object.I have tried below code using triggers.  please tell me  where did i mistake.Its very urgent. Thanks in advance.

public static void TMOppCompInfo(List<Competitive_Infomation__c> complst)
    {
        
        List<Infomation__c> lstcompinfo = new List<Infomation__c>();
        set<id> oppid = new set<id>();
        Id TMoppRecord = Schema.SobjectType.Opportunity.getRecordTypeInfosByName().get('machinery').getRecordTypeId();
        Id CloseOut = Schema.SobjectType.Competitive_Infomation__c.getRecordTypeInfosByName().get(' Information - Close Out').getRecordTypeId();
        for(Competitive_Infomation__c comp : complst)
        {
            oppid.add(comp.Sub_Opportunity_Name__c);
         }
       
       List<opportunity> lstoppcomp = [select id,Emissions_Unit__c,Emissions_Guaranteed__c,Reason_for_Guarantee__c,Guaranteed_NOx_15_O2_ppm__c,Liquid_NOx_15_O2_ppm__c,
                                        Guaranteed_CO_15_O2_ppm__c,Liquid_CO_15_O2_ppm__c,CBR_Temperature_Range_Unit__c,Temperature_Range__c,
                                       Load_Range_pct__c,CBR_Engine_Emissions_Controls__c from opportunity where id =: oppid and recordType.Name = 'machinery' ];
      IF(lstoppcomp.size()>0)
     {
        for(Competitive_Infomation__c compinfo : complst)
         {
          
           if(compinfo.Emissions_Same_as_Solar__c == 'same' && compinfo.RecordTypeId == CloseOut)
           {
               for(opportunity opplst : lstoppcomp)
              {
              
                  compinfo.NOx_Emissions_15_O2__c = opplst.Guaranteed_NOx_15_O2_ppm__c;
                  compinfo.CO_Emissions_15_O2__c = opplst.Guaranteed_CO_15_O2_ppm__c;
                  compinfo.Liquid_NOx_Emissions_15_O2__c = opplst.Liquid_NOx_15_O2_ppm__c;
                 
               
           }
         }
       }
Hi,

I am stuck in process builder . Can anyone help me .opportunity contain 4 stage picklist fields , and Release checkox fileld in case. 
stage1 = A,B,C,D,E 
stage2 =A,B,C,D,E 
stage3 =A,B,C,D,E 
stage4 =A,B,C,D,E  
 Requirement is   1) any one of picklist field is changed to A/B/C  then Release checkbox field should be checked 
                             2) any one of field is not equals to A/B/C changed to something else  then Release checkbox should be unchecked

​​​​​​​
 
Hi everyone,

I am stuck to send email notification using email templates.  Error is coming from whatId,targetobjectid. Can anyone help on this.Below is my code
Id LTA = Schema.SObjectType.opportunity.getRecordTypeInfosByName().get('Service').getRecordTypeId();
        Messaging.SingleEmailMessage mail= new Messaging.SingleEmailMessage(); 
        List < Messaging.SingleEmailMessage > allmails = new List < Messaging.SingleEmailMessage > ();
        List<test__c> BRElst = new List<test__c>();
        list<Id> CAMuser= new list<Id>(); 
        set<string> CAMmail= new set<string>(); 
         list<String> emailAddresses = new list<String>();
         List<user> lstuser = new List<user>();
         
        if( subopp.Business_Unit__c != null && subopp.recordtypeId == LTA ){
        
         BRElst = [select id,CS_Corp_Acc_Manager__c from test__c where Business_Unit__c=:subopp.Business_Unit__c ];
       System.debug ('BREList size'+BRElst.size());
       for(test__c bre : BRElst)
      {
        CAMuser.add(bre.CS_Corp_Acc_Manager__c);
      }
        if( CAMuser!=null)
        {
        lstuser = [select id,Email,firstName,lastName from User where ID IN:CAMuser];
        }
        EmailTemplate templateId = [Select id from EmailTemplate where name = 'sampletemplate'];
        for(BigMachines__c bq:relatedQuotes ){ 
        
       If (bq.AddCAMtoPDR__c == false){ 
         
          for(user u: lstuser ){
                CAMmail.add(u.Email);
                System.debug('CAMmail' +CAMmail);
                
                emailAddresses.addAll(CAMmail);
               if(!emailAddresses.isEmpty()){
          
         mail.setTemplateID(templateId.Id); 
         mail.setToAddresses(emailAddresses);
         mail.setTargetObjectId(u.id);
         mail.setWhatId(apprecord.id);
         mail.setSaveAsActivity(false);
        allmails.add(mail);
          try{
     Messaging.sendEmail(allmails);
    
      }
      catch(Exception e){
      system.debug('-------------exception------'+e);
       }
      }


 
Hi Everyone,

I am struck to display opportunity owner in email notification using triggers. Below is my code,  I am getting error ple any one give me solution 
for(sObject m : trigger.new)
        {
            Miles__c mile = (Miles__c)m;
            mileCaseid.add(mile.Case__c);
            mileOppid.add(mile.Opportunity__c);
            // Miles__c oldmile = (Miles__c ) trigger.oldMap.get(mile.id);
        //}  
        
        map<id,Case> casemap =new map<id,Case>();
        list<case> lstcase = [select id,CaseNumber,Revision__c,Priority from case where id in : mileCaseid AND RecordTypeId = :Caserectypid ];
       System.debug('lstcase'+lstcase);
        map<id,opportunity> oppmap = new map<id,opportunity>();
        list<opportunity> lstopp = [select id, name,Owner.Name,Region__c from opportunity where id in : mileOppid];
          System.debug('lstopp '+lstopp ); 
          if(!lstcase.isempty())
       { 
             for(case cse:lstcase ){
                casemap.put(cse.id,cse);
                }
    //   if(!lstopp.isempty())
     // { 
            for(opportunity opp:lstopp){
                oppmap.put(opp.id,opp);
            }    
            for(Miles__c mm : [select id,name,Status__c from Miles__c] ){
           //     Miles__c mile = (Miles__c)m;
               
                string oldmile  = mm.Status__c ;
              //  Miles__c oldmile = (Miles__c ) trigger.oldMap.get(mile.id);
                
                if(mile.Status__c == 'Completed' &&  mile.Status__c != oldmile && mile.Case__c!= null && mile.RecordTypeid ==  Milerectypid  )
                {
                    //system.debug('milestattusold'+oldmile.Status__c);
                    milemap.put(mile.id,mile);
                    string sub =  casemap.get(mile.Case__c).CaseNumber + mile.Opp_Inquiry__c+'Notification of Milestone Completion';
                    mail.setSubject(sub);
                    
                       mail.setHtmlBody( 
                       '<html lang="en">'+
                       '  <head>' +
                        '    <meta charset="utf-8"/>' +
                        '    <meta name="viewport" content="width=device-width" />' +
                        '    <br/>' +
                        '    <br/>' +
                        '    </head>' +
                        '    <br/>' +                 
                      
                        '   <b>Inquiry Number: </b>' + (String.isBlank(mile.Opp_Inquiry__c) ? '' :  mile.Opp_Inquiry__c) +
                        '    <br/>' +
                        '   <b> Case : </b> ' + (String.isBlank(casemap.get(mile.Case__c).CaseNumber) ? '' : casemap.get(mile.Case__c).CaseNumber ) +
                        '    <br/>' +
                        '   <b> Case Revision :  </b>' + (String.isBlank(casemap.get(mile.Case__c).Revision__c) ? '' :  casemap.get(mile.Case__c).Revision__c) +
                        '    <br/>' +
                         
                      '  <b>Opportunity Owner: </b>' + (String.isBlank(oppmap.get(mile.Opportunity__c).Owner.Name) ? '' :  oppmap.get(mile.Opportunity__c).Owner.Name) +
                       '    <br/>' +
                                                 
                        ' </html>'    
                       ) ; 
                     }
                  }



 
Hi All,

i want to display old date and current changed date in email template using visualfore component. In case object there is commitDate field and i want to display olddate and currently changed date. 
 
Hi All,

How to display case detail link and opportunity detail link in template. I have requirement to send notification along with case link and related opportunity link in template. I have tried like below but i didnt get opportunity link. Thanks in advance

case link : {!case.link}
opportunity link :  {!Opportunity.Link} 
Hi All,

How to send email notification to all case team members using triggers. I have requirement  location object is child and case is parent. when status field  is compleate on location object then send email to all case team members, Please any one give me solution
Hi All,

I am passing record id to email tempalte but am not getting values from visual component to eamil template . Below is my code.
Please help on this. Thanks in advance.
 
Apex class:
public class csCompetitiveOppNotification {
    
    public Id OppObj{get;set;}
    public Opportunity opp{get;set;} 
    public string Competitive_Infomation{get;set;}
    public string SubOppName{get;set;}
    
    public csCompetitiveOppNotification(){
        try{
            Competitive_Infomation='';
            SubOppName='';
            opp=[Select Id,name,StageName,Competitive__c,Region__c,Territory__c,Ownerid,End_User__c,Accountid,UnitCount_Product__c,Line_Item_PO_Contract_Value__c,Revenue__c from opportunity where id=:OppObj];
            List<Opportunity> subOppList=  [select name from opportunity where Opportunity_Master__c=:OppObj];
            for(Opportunity oppObj:subOppList)    {
                if(SubOppName !=''){
                    SubOppName=SubOppName+', ';
                }
                SubOppName=SubOppName+oppObj.name;
                
            }        
            List<Competitive_Infomation__c> comList=[select name from Competitive_Infomation__c where Opportunity__c=:OppObj];
            for(Competitive_Infomation__c ciObj:comList){
                if(Competitive_Infomation !=''){
                    Competitive_Infomation=Competitive_Infomation+', ';
                }
                Competitive_Infomation=Competitive_Infomation+ciObj.name;
            }   
        }
        catch(exception e){
            system.debug('test'+e.getMessage());
        }
    }
}
 
VF component:
<apex:component controller="csCompetitiveOppNotification" access="global">
    <apex:attribute name="Oppid" type="Id" assignTo="{!OppObj}" description="This is the Id of the Opportunity" access="global" />
    
    <apex:outputPanel layout="block">
        <html>
            <body>
                
                <table> 
                    <tr> 
                        <td style="font-weight:bold">Master Opportunity Name:</td>
                        <td>{!opp.Name}</td>
                    </tr>    
                    
                    <tr> 
                        <td style="font-weight:bold">Account Name:</td>
                        <td>{!opp.Account.Name}</td>
                    </tr>   
                    <tr> 
                        <td style="font-weight:bold">Enduser:</td>
                        <td>{!opp.End_User__c }</td>
                    </tr> 
                    
                    <tr> 
                        <td style="font-weight:bold">Competitive Information:</td>
                        <td>{!Competitive_Infomation}</td>
                    </tr>   
                    <tr> 
                        <td style="font-weight:bold">Sub Opportunities:</td>  
                        <td>{!SubOppName }</td>
                    </tr> 
                    
                    
                    
                    
                </table>
            </body>               
        </html>
    </apex:outputPanel>
</apex:component>
Template
<messaging:emailTemplate subject="Competitive Opportunity {!RelatedTo.Inquiry_Number__c} -{!RelatedTo.Name} - {!RelatedTo.Territory__c}  {!Relatedto.id}" recipientType="User" relatedToType="Opportunity">
<messaging:htmlEmailBody >
<c:cs_Comp_Opp_Notification Oppid="{!Relatedto.Id}"  >
</c:cs_Comp_Opp_Notification>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

please anyone give me solution on this.
 
Hi Everyone am facing issues with archive article test class and can't able to findout the solution. If any one have idea on this please help me.Thanks in advance

global class BatchArchiveKB implements Database.Batchable<SObject> {
    global string query;

    global BatchArchiveKB() {
        Map<String, ArchiveKB__mdt> mapCMD = ArchiveKB__mdt.getAll();
    
    }

    global Database.QueryLocator start(Database.BatchableContext BC){
         ArchiveKB__mdt[] KBids = [Select Id, Salesforce_ID__c from ArchiveKB__mdt];
          Set<String> sfid = new Set<String>();
              for(ArchiveKB__mdt record:KBids) {
                  sfid.add(record.Salesforce_ID__c);
            }
        System.debug('sfids'+sfid);
         return Database.getQueryLocator([Select Id, KnowledgeArticleId FROM Customer_Support__kav WHERE ID =:sfid]);
  
    }
            
    global void execute(Database.BatchableContext BC, List<Customer_Support__kav> todelete) {
        system.debug('Todelete'+todelete);
        for (Customer_Support__kav kav:  todelete)
        {
            KbManagement.PublishingService.archiveOnlineArticle(kav.knowledgeArticleId,null);
             System.debug(kav.Id);
        }   
       
    }
     global void finish(Database.BatchableContext bc){
    
    }

}

Test class
-----------------------------------
@isTest
public class BatchArchiveKB_test {
    
    @testVisible static List<ArchiveKB__mdt> articlemap{ 
        get{ 
            if(articlemap == NULL){ 
                articlemap = [SELECT Id, Salesforce_ID__c FROM ArchiveKB__mdt]; 
            } 
            return articlemap; 
        } 
        set; 
    } 
    
    @istest
    public static void testBatchArchive(){
        
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs (thisUser) 
        {
          Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
          User u = new User(Alias = 'standt', Email='test@test.com', 
            EmailEncodingKey='UTF-8', LastName='Testing',  
            LocaleSidKey='en_US', ProfileId = p.Id, 
             UserName='sdss123@test.com');

        
        Customer_Support__kav kv = new Customer_Support__kav();
        kv.Title='test';
        kv.urlname='testurl';    
        kv.Summary= 'test';
        kv.IsVisibleInPkb=true;
        kv.IsVisibleInCsp=true;
        kv.IsVisibleInPrm =true;
        // kv.PublishStatus ='online'
        //kv.language='en_US';
        insert kv;
               
        Test.startTest();
        Customer_Support__kav kbs = [Select KnowledgeArticleId from Customer_Support__kav where ID = :kv.Id];
        string articleid = kbs.KnowledgeArticleId ;
      
        KbManagement.PublishingService.archiveOnlineArticle(articleid, null);
        
       
        BatchArchiveKB bc = new BatchArchiveKB ();
        Database.executeBatch(bc,200);
        
        
        Test.stopTest();
    }
    
    }    
}
Hi All,

I am getting issue with Apex CPU time limit exceeded when i click on the button and error is coming from below method. Can any one please help meon this.
Thanks in advance

public List<salesforcerequestdocumentSfaccountreque.Contract> buildContractClassHierarchy (SB_Account_Letter__c serviceLetter, list<Asset__c> assetList, SB_Ref_Table__c letterDetails, list<Contract_c__c> selectedcontractList)
    {
        list<salesforcerequestdocumentSfaccountreque.Contract> result = new list<salesforcerequestdocumentSfaccountreque.Contract>();
        set<Id> contractSet = new set<Id>();
        list<Contract_c__c> allContracts = new list<Contract_c__c>();
        list<Asset__c> allAssets = new list<Asset__c>();
        list<Buyout__c> allBuyouts = new list<Buyout__c>();
        //1697
       // if (letterDetails.Letter_Code__c == 'USACCREPOSLTR')
        if (letterDetails.Class__c == '7') 
        {
           for (Contract_c__c sc :selectedcontractList)
          { 
           contractSet.add(sc.id);
        
           }
         }
            
        for (Asset__c a: assetList){
            contractSet.add(a.Contract_Number__c);
        }
        allContracts = this.getContractList(serviceLetter, contractSet, letterDetails);
        allAssets = this.getAssetList(allContracts, assetList);
        allBuyouts = this.getBuyoutList(contractSet);
        
        for (Contract_c__c c: allContracts)
        {
            salesforcerequestdocumentSfaccountreque.Contract cVO = new salesforcerequestdocumentSfaccountreque.Contract();
            cVO.Assets = new salesforcerequestdocumentSfaccountreque.Assets();
            cVO.Assets.Asset = new list<salesforcerequestdocumentSfaccountreque.Asset>();
            
            System.debug('medar heap before populateContractInfo call: '+ Limits.getHeapSize() );      
            populateContractInfo (c, cVO);
            System.debug('medar heap after populateContractInfo call: ' + Limits.getHeapSize() ); 
            
            for (Asset__c a: allAssets)
            {
                if (c.Id == a.Contract_Number__c)
                {
                    salesforcerequestdocumentSfaccountreque.Asset aVO = new salesforcerequestdocumentSfaccountreque.Asset();
                    
                    System.debug('medar heap before populateAssetInfo call:' + Limits.getHeapSize() );  
                    aVO = this.populateAssetInfo (a);
                    System.debug('medar Heap after populateAssetInfo call: ' + Limits.getHeapSize() );
                    system.debug('medar Heap size is: ' + Limits.getHeapSize());
                    cVO.Assets.Asset.add (aVO);
                     System.debug('medar after cVO.Assets.Asset.add (aVO)' );
                    system.debug('medar Heap size is before null aVO: ' + Limits.getHeapSize());
                    aVO = null;//medar attempting to reduce heap
                    system.debug('medar Heap size is after null aVO: ' + Limits.getHeapSize());
                }
            }
            
            if (letterDetails.Class__c == '2')
            {
                cVO.Buyouts = new salesforcerequestdocumentSfaccountreque.Buyouts();
                cVO.Buyouts.Buyout = new list<salesforcerequestdocumentSfaccountreque.Buyout>();
                for (Buyout__c b: allBuyouts)
                {
                    if (c.Id == b.Contract__c)
                    {
                        salesforcerequestdocumentSfaccountreque.Buyout bVO = new salesforcerequestdocumentSfaccountreque.Buyout();
                        System.debug('medar before bVO = this.populateBuyoutInfo(b)' );  
                        bVO = this.populateBuyoutInfo(b);
                        System.debug('medar after bVO = this.populateBuyoutInfo(b)' );  
                        cVO.Buyouts.Buyout.add(bVO);
                        system.debug('medar  Heap size before bVO is nulled: ' + Limits.getHeapSize());
                        bVO = null;//medar trying to reduce heap
                        system.debug('medar  Heap size after bVO is nulled: ' + Limits.getHeapSize());
                        System.debug('medar after cVO.Buyouts.Buyout.add(bVO);' );  
                    }
                }
            }
            System.debug('medar before result.add(cVO);' );
            result.add(cVO);
            System.debug('medar after result.add(cVO);' );
        }
        return result;   
    }
 
I want to display case fields based on related opportunity recordtype. I am facing issues.Anyone please help on this.

<apex:page standardController="Case"   showHeader="false" applyBodyTag="false" applyHtmlTag="false">
<apex:form >
<apex:outputPanel rendered="{!IF(Case.Opportunity__r.RecordType.Name =’proposed Recordtype’,true,false)}"> -->
<apex:pageBlocksection >
<apex:outputLabel value="space" /> 
<apex:inputField value="{!Case.space__c}" />
</apex:pageBlocksection>
</apex:outputPanel >

<apex:outputPanel rendered="{!IF(Case.Opportunity__r.RecordType.Name =’Intial Recordtype’,true,false)}"> -->
<apex:pageBlocksection >
<apex:outputLabel value="counter" /> 
<apex:inputField value="{!Case.counter__c}" />
</apex:pageBlocksection>
</apex:outputPanel >
</apex:form> 
</apex:page>
I have a requirement while inserting and updating of information records ,fetch values from opportunity and populate on Information object . opportunity is a lookup field on Information object.I have tried below code using triggers.  please tell me  where did i mistake.Its very urgent. Thanks in advance.

public static void TMOppCompInfo(List<Competitive_Infomation__c> complst)
    {
        
        List<Infomation__c> lstcompinfo = new List<Infomation__c>();
        set<id> oppid = new set<id>();
        Id TMoppRecord = Schema.SobjectType.Opportunity.getRecordTypeInfosByName().get('machinery').getRecordTypeId();
        Id CloseOut = Schema.SobjectType.Competitive_Infomation__c.getRecordTypeInfosByName().get(' Information - Close Out').getRecordTypeId();
        for(Competitive_Infomation__c comp : complst)
        {
            oppid.add(comp.Sub_Opportunity_Name__c);
         }
       
       List<opportunity> lstoppcomp = [select id,Emissions_Unit__c,Emissions_Guaranteed__c,Reason_for_Guarantee__c,Guaranteed_NOx_15_O2_ppm__c,Liquid_NOx_15_O2_ppm__c,
                                        Guaranteed_CO_15_O2_ppm__c,Liquid_CO_15_O2_ppm__c,CBR_Temperature_Range_Unit__c,Temperature_Range__c,
                                       Load_Range_pct__c,CBR_Engine_Emissions_Controls__c from opportunity where id =: oppid and recordType.Name = 'machinery' ];
      IF(lstoppcomp.size()>0)
     {
        for(Competitive_Infomation__c compinfo : complst)
         {
          
           if(compinfo.Emissions_Same_as_Solar__c == 'same' && compinfo.RecordTypeId == CloseOut)
           {
               for(opportunity opplst : lstoppcomp)
              {
              
                  compinfo.NOx_Emissions_15_O2__c = opplst.Guaranteed_NOx_15_O2_ppm__c;
                  compinfo.CO_Emissions_15_O2__c = opplst.Guaranteed_CO_15_O2_ppm__c;
                  compinfo.Liquid_NOx_Emissions_15_O2__c = opplst.Liquid_NOx_15_O2_ppm__c;
                 
               
           }
         }
       }
Hi,

I am stuck in process builder . Can anyone help me .opportunity contain 4 stage picklist fields , and Release checkox fileld in case. 
stage1 = A,B,C,D,E 
stage2 =A,B,C,D,E 
stage3 =A,B,C,D,E 
stage4 =A,B,C,D,E  
 Requirement is   1) any one of picklist field is changed to A/B/C  then Release checkbox field should be checked 
                             2) any one of field is not equals to A/B/C changed to something else  then Release checkbox should be unchecked

​​​​​​​
 
Hi All,

How to send email notification to all case team members using triggers. I have requirement  location object is child and case is parent. when status field  is compleate on location object then send email to all case team members, Please any one give me solution

Hi friends,

 

I have list of records,when i click the particular records it display the details of records.some records not display it's loading too long time after that am getting err like this.. Apex CPU time limit exceeded and An unexpected error has occurred. Your development organization has been notifiedwhy this err occur how to resolve this please can anyone help me..thanks in advance..

 

Regards,

kathir