• Stefan Abramiuk
  • NEWBIE
  • 65 Points
  • Member since 2015
  • CEO
  • Sempre Esperto


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 15
    Replies
Hello!
I have a related list on my vf page called Account Number. This page uses standard controller - Account. So on this page i show Account Numbers related list for Account.
To show necessary record, i add the render component. My code below:
<apex:page standardController="Account" showHeader="true">
    
    <apex:pageBlock title="{!account.name}">
      <apex:pageBlockSection title="Account Numbers" columns="1">      
        <apex:pageBlockTable title="Account Numbers" var="acnum" value="{!account.Account_Numbers__r}" border="1" cellpadding="4" cellspacing="1" width="100%">
            <apex:column >
                <apex:facet name="header">Action</apex:facet>
                <apex:OutputLink value="{!$Action.Account_Number__c.Edit}" rendered="{!acnum.Status__c ='Created'}">Edit</apex:outputLink>
                <apex:OutputText value=" | " rendered="{!acnum.Status__c ='Created'}"> </apex:OutputText>
                <apex:OutputLink value="{!$Action.Account_Number__c.Delete}" rendered="{!acnum.Status__c ='Created'}">Del</apex:outputLink>
            </apex:column>        
            <apex:column >
                <apex:facet name="header">Name</apex:facet>
                <apex:OutputLink value="https://cs87.salesforce.com/{!acnum.id}" rendered="{!acnum.Status__c ='Created'}">{!acnum.Name}</apex:OutputLink>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Account #</apex:facet>
                <apex:OutputText value="{!acnum.Account_No__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Status</apex:facet>
                <apex:OutputText value="{!acnum.Status__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>            
            <apex:column >
                <apex:facet name="header">Trading Account</apex:facet>
                <apex:OutputText value="{!acnum.Account_Number_Old__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Account #</apex:facet>
                <apex:OutputText value="{!acnum.Account_No__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Markets</apex:facet>
                <apex:OutputText value="{!acnum.Markets__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">TCA Settlement Account</apex:facet>
                <apex:OutputText value="{!acnum.TCA_Settlement_Account__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>                
            <apex:column >
                <apex:facet name="header">Trading Account Type</apex:facet>
                <apex:OutputText value="{!acnum.Trading_Account_Type__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column> 
            <apex:column >
                <apex:facet name="header">Account Setup With</apex:facet>
                <apex:OutputText value="{!acnum.Account_Setup_With__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column> 
            <apex:column >
                <apex:facet name="header">Record Type</apex:facet>
                <apex:OutputText value="{!acnum.RecordType.Name}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Login</apex:facet>
                <apex:OutputText value="{!acnum.Login__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>                                                                                             
        </apex:pageBlockTable>
      </apex:pageBlockSection>

This is work for me pretty good, but the table shows now empty rows. See the picture:
Empty rows
It seems there two records, that doesn't meet the criteria of rendered component.
So how can i hide this empty rows from the related list?
I am trying out  JS RemoteAction with the help of Apex dev guide.
I am trying to return the result of account , but the result.id or result.name is coming as null whereas result is not null. What is the reason? Please help..

VF code
<apex:page controller="VFRemoteAction" sidebar="false">
  <head>
      <style>
          #errors{color:red;font-size:15px;font-style:bold;margin:5px; width:100%;}
      </style>
       <script>
          var getAccount = function(){
               var accountName = document.getElementById('account_name').value;
               
               Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VFRemoteAction.getAccount}',            
               accountName,
               function(result,event){
                   if(event.status){
                      
                       document.getElementById('result').innerHTML=result.id; --> null ????????
                   }
                   else{
                       document.getElementById('errors').innerHTML="Error --> "+event.message;
                   }
               },
               {escape: true} 
               
               );
               
               
          }
        </script>
  </head>
  <body>
      <apex:pageBlock title="Javascript Remote Sample" >
          <apex:pageBlockSection title="Search for an account" columns="2">
              <div id="errors">
              </div>
              <div id="input">
                  <label>Enter the account name:</label>
                  <input type="text" name="account_name" id="account_name"/>
                  
                  <button onclick="getAccount()">Get Account</button>

              </div>
          </apex:pageBlockSection>
      </apex:pageBlock>
      <apex:outputPanel >
           <div id="result">
            
            </div>
      </apex:outputPanel>
  </body>
</apex:page>

Apex code
global with sharing class VFRemoteAction {
    
    public static Account account{get;set;}
    
    public  String accountName{get;set;}
    
    public VFRemoteAction(){
    }
    
    
    
    @RemoteAction
    global static Account  getAccount(String accountName){
      
         account = [SELECT id,name ,site FROM ACCOUNT where name=:accountName];
          return account; 

    } 
}
Hi,

I need help in Line Break in HTML email template, please see below bold text. I tried everyting i.e. <br>, <br/ > etc. but no success yet.
Hi {!Receiving_User.FirstName}, 

{!IF(Receiving_User.Profile='System Administrator',"Thank you for registering for BusinessLink. Your registration is almost complete, the last step is to verify your email address." & BR() & "hey","")}

{!IF(Receiving_User.Profile='EMS External User',"To complete your final step for Business Link registration either click on the link below or copy and paste the link directly into your browser.","")}

{!IF(Receiving_User.Profile='EMS External User',"Please verify yourself at:","")} 

{!IF(Receiving_User.Profile='EMS External User', $Label.Community_URL+"EMSVerification?uid="+Receiving_User.Username+"&em="+Receiving_User.Email+"&key="+Receiving_User.Verify_Hash__c,"")}

{!IF(Receiving_User.Profile='EMS External User',"After verification, your registration will be reviewed and access to the Business Link portal will be granted and ID sent in an email.","")}

{!IF(Receiving_User.Profile='EMS External User',"","You should have access to Salesforce EMS within My Links on your default portal.")}

Sincerely,
Business Link

 
I want to mapped Lead from source org to custom object in target org, but It is showing only standard objects to mapp. Is there is any other way to do it?
hi guys,
I am trying to work on this trigger but unable to find the error. there are 2 objects invoice & revenue.if revenue object fields(salary=regular,salary processed=today & invoice type=time & material) and invoice object fields(categlory=individual, billing calendar=today & type= time& material) & both the objects ecode & emp codeare equal then RevenueWithoutST(REVENUE OBJECT) = subtotal(invoice object).

trigger subtotal on Revenue__c (after insert,before update ) {
    List<Revenue__c> Revenue__c = New List<Revenue__c>();
    Set<Id>ECode = New Set<Id>();
    For(Revenue__c Rev : Trigger.New)
     Revenue__c.ECode__c == Invoice__c.Emp_Code__c   
    }

    List<Revenue__c> RevList = [Select Id,Salary_Processed_month__c,Invoice_Type__c from Revenue__c where id =: ECode];
{Revenue__c r = new Revenue__c();
 Invoice__c inv =new Invoice__c();
        For(r.Salary_Type__c=='Regular'&&inv.Invoice_Category__c== 'Individual')
        
            If(inv.Billing_Calendar__c== system.today()&& inv.Type_of_Invoices__c=='Time & Material' && r.Salary_Processed_month__c==system.today()
               && r.Invoice_Type__c=='Time & Material')           
            {
                r.Revenue_without_ST__c =inv.Sub_Total__c;
            }
             else
            {
                r.Revenue_without_ST__c =11;
            }
 
                
          
Update RevList;
              
            }
           
        
    

           
    


 

    // method submit the case
   public PageReference submitCase() {
     
            try {
              
                // Specify DML options to ensure the assignment rules are executed
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.useDefaultRule = true;
                c.setOptions(dmlOpts);
              
                c.SuppliedName = username;
                c.SuppliedEmail = useremail;
                c.Market__c = market;
                c.Boss_Region__c = region;
                c.Case_CC_List__c = CCuser; 
                ccAddresses = CCuser.split(',');  // capture multiple CCed email list
               
               
              
                if(productType=='Manage'){
                    Id mngRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Manage').getRecordTypeId();
                    c.RecordTypeId = mngRcdTypeId;   // RT = Manage
                   
               }
               else if(ReqType =='Salesforce Support' || productTypeRadia=='SalesForce Related Issue') {
                   Id sfsRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Salesforce Support').getRecordTypeId();
                   c.RecordTypeId = sfsRcdTypeId; // RT= SF Support
                }
               
              else if(ReqType =='New Feature Request'){
                  Id enblmtRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Enablement').getRecordTypeId();
                  c.RecordTypeId = enblmtRcdTypeId;   // RT = Enablement
              }
                           
                if((productType=='XBP' && (productTypeRadia=='Radia Related Issue' ||productTypeRadia=='Business Question / Help'))||productType=='Slack'){
                  
                    sendEmail(); // send email
                      
                }
                INSERT c;
                    
                      //Attachment Start
               
                    attachment.OwnerId = UserInfo.getUserId();
                    attachment.ParentId = c.id; // the record the file is attached to
                    attachment.IsPrivate = false;
                system.debug('starting try block ++++++++++++++');
                    try {
                          insert attachment;
                        } catch (DMLException e) {
                      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
                     // return null;
                    }
                system.debug('Ending try block ++++++++++++++');
                             
                           
                   PageReference redirectPage = Page.thanks;
                   redirectPage.setRedirect(true);
                   return redirectPage;                                                                        
                             
            } catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
      
        }
   
}
Hi,

  Need a suggestion for writing a test class for below trigger logic is it updates entitlement when opportunity NS Start and NS End Dates are updated in opportunity product
 
trigger update_entitlement on Opportunity (after insert, after update) 
{
 
 set<id> oppid = new set<id>();

  for( opportunity op : trigger.new)
   {
     oppid.add(op.id);
     }
     
   EntitlementUtil.updateentitlement(oppid);
    
}
Below is the class that is getting called inside the trigger 
public with sharing class EntitlementUtil {


public static void updateentitlement(set<ID> opp){

  list<entitlement> ent = [select Opportunity__c,StartDate,EndDate from Entitlement where Opportunity__c in :opp]; 

   opportunity getopp = [select NS_Start_Date_Min__c,NS_End_Date_Max__c from opportunity where id = :opp];
  
   for( entitlement gent : ent)
   {
      gent.StartDate = getopp.NS_Start_Date_Min__c;
      gent.EndDate = getopp.NS_End_Date_Max__c;
      update gent;
    }


}

}
Please suggest me how should i be writing the logic to update the dates. 

Thanks
Sudhir
 
Hello!
I have a related list on my vf page called Account Number. This page uses standard controller - Account. So on this page i show Account Numbers related list for Account.
To show necessary record, i add the render component. My code below:
<apex:page standardController="Account" showHeader="true">
    
    <apex:pageBlock title="{!account.name}">
      <apex:pageBlockSection title="Account Numbers" columns="1">      
        <apex:pageBlockTable title="Account Numbers" var="acnum" value="{!account.Account_Numbers__r}" border="1" cellpadding="4" cellspacing="1" width="100%">
            <apex:column >
                <apex:facet name="header">Action</apex:facet>
                <apex:OutputLink value="{!$Action.Account_Number__c.Edit}" rendered="{!acnum.Status__c ='Created'}">Edit</apex:outputLink>
                <apex:OutputText value=" | " rendered="{!acnum.Status__c ='Created'}"> </apex:OutputText>
                <apex:OutputLink value="{!$Action.Account_Number__c.Delete}" rendered="{!acnum.Status__c ='Created'}">Del</apex:outputLink>
            </apex:column>        
            <apex:column >
                <apex:facet name="header">Name</apex:facet>
                <apex:OutputLink value="https://cs87.salesforce.com/{!acnum.id}" rendered="{!acnum.Status__c ='Created'}">{!acnum.Name}</apex:OutputLink>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Account #</apex:facet>
                <apex:OutputText value="{!acnum.Account_No__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Status</apex:facet>
                <apex:OutputText value="{!acnum.Status__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>            
            <apex:column >
                <apex:facet name="header">Trading Account</apex:facet>
                <apex:OutputText value="{!acnum.Account_Number_Old__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Account #</apex:facet>
                <apex:OutputText value="{!acnum.Account_No__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Markets</apex:facet>
                <apex:OutputText value="{!acnum.Markets__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">TCA Settlement Account</apex:facet>
                <apex:OutputText value="{!acnum.TCA_Settlement_Account__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>                
            <apex:column >
                <apex:facet name="header">Trading Account Type</apex:facet>
                <apex:OutputText value="{!acnum.Trading_Account_Type__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column> 
            <apex:column >
                <apex:facet name="header">Account Setup With</apex:facet>
                <apex:OutputText value="{!acnum.Account_Setup_With__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column> 
            <apex:column >
                <apex:facet name="header">Record Type</apex:facet>
                <apex:OutputText value="{!acnum.RecordType.Name}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">Login</apex:facet>
                <apex:OutputText value="{!acnum.Login__c}" rendered="{!acnum.Status__c ='Created'}"/>
            </apex:column>                                                                                             
        </apex:pageBlockTable>
      </apex:pageBlockSection>

This is work for me pretty good, but the table shows now empty rows. See the picture:
Empty rows
It seems there two records, that doesn't meet the criteria of rendered component.
So how can i hide this empty rows from the related list?
Hello
Pls explain what is dynamic visual force bindings?
How to implement in salesforce and in how to use in project?

divya
I was not able to cover the code block based on document object..  my sample code is.
public class testcontroller{
public void method1(){ 
list<document>docs;
list<string>li=new list<string>()
  try{
                                 
                                   docs=[select id from document where name !=null'];
                                      
                                     }catch(Exception e){
                                         apexpages.addmessages(e);
                                      }
                        }


if(docs!null || !docs.isemprty()){
    for(document d:docs)
         li.add(d.name);

}

}
when writing test class i am not able to insert anty doucmet an always get docs as null
how can i cover if block.

Thanks
Abhilash

 
Dear Community

I have following setup:
@isTest
private class myTestClass {
	/** static helper variables to store data across different test classes to
	/*  accelerate test speed
	*/
	Boolean isInitiated = false;
	//  ...

	@isTest(SeeAllData=true)
	private static void init() {
		// create helper variable's values
		// ...
	}

	static testMethod void testStuff() {
		if ( !isInitiated ) { init(); }
		
		// test all the stuff to be tested
	}
}
Within the init method I use nother helper class I worte independatly to create different sObjects. One of them relies on a custom setting. Now I know that SeeAllData has to be set to true so that the method can access that data, but I do not understand why it doesn't work for the case above. In the documentations, it is not said that the isTest Annotation with the SeeAllData addition may only be used for the actual testMethods... I guess this must be where it fails because otherwise it seems to work correctly...

Any clarification on that?
Hi All,

Count(Field) is not working for few Data Types. is there any way to achive this ?
I am trying out  JS RemoteAction with the help of Apex dev guide.
I am trying to return the result of account , but the result.id or result.name is coming as null whereas result is not null. What is the reason? Please help..

VF code
<apex:page controller="VFRemoteAction" sidebar="false">
  <head>
      <style>
          #errors{color:red;font-size:15px;font-style:bold;margin:5px; width:100%;}
      </style>
       <script>
          var getAccount = function(){
               var accountName = document.getElementById('account_name').value;
               
               Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.VFRemoteAction.getAccount}',            
               accountName,
               function(result,event){
                   if(event.status){
                      
                       document.getElementById('result').innerHTML=result.id; --> null ????????
                   }
                   else{
                       document.getElementById('errors').innerHTML="Error --> "+event.message;
                   }
               },
               {escape: true} 
               
               );
               
               
          }
        </script>
  </head>
  <body>
      <apex:pageBlock title="Javascript Remote Sample" >
          <apex:pageBlockSection title="Search for an account" columns="2">
              <div id="errors">
              </div>
              <div id="input">
                  <label>Enter the account name:</label>
                  <input type="text" name="account_name" id="account_name"/>
                  
                  <button onclick="getAccount()">Get Account</button>

              </div>
          </apex:pageBlockSection>
      </apex:pageBlock>
      <apex:outputPanel >
           <div id="result">
            
            </div>
      </apex:outputPanel>
  </body>
</apex:page>

Apex code
global with sharing class VFRemoteAction {
    
    public static Account account{get;set;}
    
    public  String accountName{get;set;}
    
    public VFRemoteAction(){
    }
    
    
    
    @RemoteAction
    global static Account  getAccount(String accountName){
      
         account = [SELECT id,name ,site FROM ACCOUNT where name=:accountName];
          return account; 

    } 
}
Hi ,
I am having one trigger and i have created a test class for this trigger to achieve code coverage but some part of code is not covering can some one tell the root cause why the part of code is not covering:
My trigger is:
 if (trigger.isInsert)
    {
        oppTeamMembers = new List<Opportunity>([Select Name, Id,
                (SELECT Id, UserId, TeamMemberRole
                 FROM   OpportunityTeamMembers where EngTeamCreated__c= false) FROM Opportunity 
                                          WHERE Name IN :engagementName AND Type = 'New Business']);
        
    }
    else
    {
        oppTeamMembers = new List<Opportunity>([Select Name, Id,Related_Engagement__c,
                (SELECT Id, UserId, TeamMemberRole
                 FROM   OpportunityTeamMembers where EngTeamCreated__c= false) FROM Opportunity 
                                          WHERE Related_Engagement__c IN :engagementId AND Type != 'New Business']);
                                         
    }
        // from here the code is not covering in the test class
     for(Opportunity opp : oppTeamMembers )
    {
        String EngId;
        String EngCurrencyCode;
        Date EngStartDate;
        Date EngEndDate;
        
        if(trigger.isInsert)
        {
            EngId = EngMap.get(opp.Name).Id;
            EngCurrencyCode = EngMap.get(opp.Name).CurrencyIsoCode;
            EngStartDate = EngMap.get(opp.Name).Billing_Start_Date__c;
            EngEndDate = EngMap.get(opp.Name).Billing_End_Date__c;
        }
        else
        {
            EngId = EngagementMap.get(opp.Related_Engagement__c).Id;
            EngCurrencyCode = EngagementMap.get(opp.Related_Engagement__c).CurrencyIsoCode;
            EngStartDate = EngagementMap.get(opp.Related_Engagement__c).Billing_Start_Date__c;
            EngEndDate = EngagementMap.get(opp.Related_Engagement__c).Billing_End_Date__c; 
        }
        List<OpportunityTeamMember> oppTeam = new List<OpportunityTeamMember>(opp.OpportunityTeamMembers);
        //Creatig new record for engagament team and assigning values to relative fields  
        for (integer i = 0; i < oppTeam.size(); i++) 
        {
            Engagement_Team__c engTeam = new Engagement_Team__c();
            engTeam.CurrencyIsoCode   = EngCurrencyCode;
            engTeam.Engagement__c     = EngId;
            engTeam.Start_Date__c     = EngStartDate;
            engTeam.End_Date__c       = EngEndDate;
            engTeam.Team_Member__c    = oppTeam[i].UserId;
            engTeam.Team_Role__c      = oppTeam[i].TeamMemberRole;
            engTeamList.add(engTeam);
            oppTeam[i].EngTeamCreated__c = true;
            oppTeamToBeUpdated.add(oppTeam[i]);
        } 

My test class is:
@isTest
public with sharing class CreateEngTeamTest{
       public static testMethod void engagementTest(){
          RecordDatabase.objectWrapper objWrap = new RecordDatabase.objectWrapper();
        Boolean isApplicable = true;
        //Insert Account
        Map<String, String> accountValMap = new Map<String, String>{'Name' => 'Credit Suisse', 'CurrencyIsoCode' => 'USD', 'Industry' => 'Software',  
                                                'Type' => 'Customer', 'Region__c' => 'EMEA', 'Segment_dell__c' => 'LE', 'Client_Tier__c' => 'Growth'};
        List<Account> lstAccount = RecordDatabase.CreateAccount(1, accountValMap);
        insert lstAccount;
        
        objWrap.account = [Select Id from Account LIMIT 1];
        
        // Insert Product
        Map<String, String> productValMap = new Map<String, String>{'Name' => 'Specialist Onshore (3-12 months)', 'Description' => 'DEF', 'productCode' => 'prod',  
                                                'isActive' => 'true'};
        List<Product2> lstProduct = RecordDatabase.CreateProduct(1, productValMap);
        system.debug('@@@:- '+lstProduct);
        insert lstProduct;
        Product2 prod = [Select Id from Product2 LIMIT 1];
        
        // By default test can't access org data but using following method you can get standard pricebookId of org
        Id pricebookId = Test.getStandardPricebookId();
        
        // Insert a RecordType
        objWrap.rType = [SELECT Id FROM RecordType where Name='FS LTP'AND IsActive = TRUE limit 1];
        
        // Insert pricebookEntry
        Map<String, String> pbEntryValMap = new Map<String, String>{'Product2ID' => prod.Id, 'Pricebook2ID' => pricebookId, 'UnitPrice' => '21321.1',  
                                                'isActive' => 'true'};
        List<PricebookEntry> lstPricebookEntry = RecordDatabase.CreatePricebookEntry(1, pbEntryValMap);
        system.debug('@@@:- '+lstPricebookEntry);
        insert lstPricebookEntry;
        PricebookEntry pbEntry = [Select Id from PricebookEntry LIMIT 1];
        
        Trigger_Controller__c cs = new Trigger_Controller__c();
        cs.Name = 'ShouldCalculate';
        insert cs;
        
        Engagement__c updEngagement = new Engagement__c();
        updEngagement.Name = 'Tester Tesing Engage';
        updEngagement.Billing_Start_Date__c = date.today();
        updEngagement.Billing_end_Date__c = date.today().addDays(20);
        updEngagement.Account__c = lstAccount[0].Id;
        insert updEngagement;
        
        
        Engagement__c e = [select Id,Name from Engagement__c LIMIT 1];
        //Insert Opportunity
        Map<String, String> opptyValMap = new Map<String, String>{'Name' => 'Test Opp1', 'CurrencyIsoCode' => 'USD', 'AccountId' => objWrap.account.Id, 'StageName' => 'Opportunity Identified',   
                                                'Type' => 'Net New', 'Region__c' => 'EMEA', 'Create_Engagement__c' => 'No', 'Service_Areas__c' => 'Consulting', 'Reason_Won_lost__c' => '--None--',
                                                'Service_Class__c' => 'Pricing Ops Support', 'Probability' => '10', 'Cluster__c' => 'ABACUS', 'Pricebook2Id' => pricebookId};
        List<Opportunity> lstOppty = RecordDatabase.CreateOpportunity(1, opptyValMap, objWrap);
        system.debug('@@@ Oppty:- '+lstOppty);
        insert lstOppty;
        Opportunity oppty = [Select Id,Name,OwnerId, Create_Engagement__c, Final_Status__c, Type from Opportunity LIMIT 1];
        List<RecordType> lstRecType = [Select Id, SobjectType, Name, DeveloperName, Description From RecordType where Name =: 'DMS Read Only'];
     
        oppty.Create_Engagement__c = 'Yes';
        oppty.Type = 'New Business';
        oppty.Final_Status__c = 'Closed';
        oppty.Go_Live_Month__c = date.today();
        oppty.Related_Engagement__c = e.Id;
        OpportunityHalperClass.shouldRunTrigger = false; 
        update oppty;
        // inserting opportunity team member
        OpportunityTeamMember otm = new OpportunityTeamMember();
        otm.TeamMemberRole ='Sales Manager';
        otm.UserId = oppty.OwnerId;
        otm.OpportunityId = oppty.Id;
        otm.EngTeamCreated__c = false;
        insert otm;
        
        // list of engagement names
        List<String> engagementName = new List<String>();
        engagementName .add(oppty.Name);
        List<Opportunity> oppTeamMembers1 = new List<Opportunity>([Select Name, Id,
                (SELECT Id, UserId, TeamMemberRole
                 FROM   OpportunityTeamMembers where EngTeamCreated__c= false) FROM Opportunity 
                                          WHERE Name IN :engagementName AND Type = 'New Business']);
        
        system.debug('### List of opportunities:-'+oppTeamMembers1[0].Name);
       } 
        public static testMethod void engagementTest1(){
          RecordDatabase.objectWrapper objWrap = new RecordDatabase.objectWrapper();
        Boolean isApplicable = true;
        //Insert Account
        Map<String, String> accountValMap = new Map<String, String>{'Name' => 'Credit Suisse', 'CurrencyIsoCode' => 'USD', 'Industry' => 'Software',  
                                                'Type' => 'Customer', 'Region__c' => 'EMEA', 'Segment_dell__c' => 'LE', 'Client_Tier__c' => 'Growth'};
        List<Account> lstAccount = RecordDatabase.CreateAccount(1, accountValMap);
        insert lstAccount;
        
        objWrap.account = [Select Id from Account LIMIT 1];
        
        // Insert Product
        Map<String, String> productValMap = new Map<String, String>{'Name' => 'Specialist Onshore (3-12 months)', 'Description' => 'DEF', 'productCode' => 'prod',  
                                                'isActive' => 'true'};
        List<Product2> lstProduct = RecordDatabase.CreateProduct(1, productValMap);
        system.debug('@@@:- '+lstProduct);
        insert lstProduct;
        Product2 prod = [Select Id from Product2 LIMIT 1];
        
        // By default test can't access org data but using following method you can get standard pricebookId of org
        Id pricebookId = Test.getStandardPricebookId();
        
        // Insert a RecordType
        objWrap.rType = [SELECT Id FROM RecordType where Name='FS LTP'AND IsActive = TRUE limit 1];
        
        // Insert pricebookEntry
        Map<String, String> pbEntryValMap = new Map<String, String>{'Product2ID' => prod.Id, 'Pricebook2ID' => pricebookId, 'UnitPrice' => '21321.1',  
                                                'isActive' => 'true'};
        List<PricebookEntry> lstPricebookEntry = RecordDatabase.CreatePricebookEntry(1, pbEntryValMap);
        system.debug('@@@:- '+lstPricebookEntry);
        insert lstPricebookEntry;
        PricebookEntry pbEntry = [Select Id from PricebookEntry LIMIT 1];
        
        Trigger_Controller__c cs = new Trigger_Controller__c();
        cs.Name = 'ShouldCalculate';
        insert cs;
        
        Engagement__c updEngagement = new Engagement__c();
        updEngagement.Name = 'Tester Tesing Engage';
        updEngagement.Billing_Start_Date__c = date.today();
        updEngagement.CurrencyIsoCode = 'SGD';
        updEngagement.Billing_end_Date__c = date.today().addDays(20);
        updEngagement.Account__c = lstAccount[0].Id;
        insert updEngagement;
        IF( updEngagement.Billing_Start_Date__c == date.today()){
            updEngagement.Billing_Start_Date__c = date.today().addDays(10);
            update updEngagement;
            }
        
        Engagement__c e = [select Id,Name from Engagement__c LIMIT 1];
        //Insert Opportunity
        Map<String, String> opptyValMap = new Map<String, String>{'Name' => 'Test Opp', 'CurrencyIsoCode' => 'SGD', 'AccountId' => objWrap.account.Id, 'StageName' => 'Opportunity Identified',   
                                                'Type' => 'Net New', 'Region__c' => 'EMEA', 'Create_Engagement__c' => 'No', 'Service_Areas__c' => 'Consulting', 'Reason_Won_lost__c' => '--None--',
                                                'Service_Class__c' => 'Pricing Ops Support', 'Probability' => '10', 'Cluster__c' => 'ABACUS', 'Pricebook2Id' => pricebookId};
        List<Opportunity> lstOppty = RecordDatabase.CreateOpportunity(1, opptyValMap, objWrap);
        system.debug('@@@ Oppty:- '+lstOppty);
        insert lstOppty;
        Opportunity oppty = [Select Id,OwnerId, Create_Engagement__c, Final_Status__c, Type from Opportunity LIMIT 1];
        List<RecordType> lstRecType = [Select Id, SobjectType, Name, DeveloperName, Description From RecordType where Name =: 'DMS Read Only'];
     
        oppty.Create_Engagement__c = 'Yes';
        oppty.Type = 'Change';
        oppty.Final_Status__c = 'Closed';
        oppty.Go_Live_Month__c = date.today();
        oppty.Related_Engagement__c = e.Id;
        OpportunityHalperClass.shouldRunTrigger = false; 
        update oppty;
        // inserting opportunity team member
        OpportunityTeamMember otm = new OpportunityTeamMember();
        otm.TeamMemberRole ='Sales Manager';
        otm.UserId = oppty.OwnerId;
        otm.OpportunityId = oppty.Id;
        otm.EngTeamCreated__c = false;
        insert otm;
        
        // list of engagement ids
        List<Id> engagementId = new List<Id>();
        engagementId .add(e.Id);
        
        List<Opportunity> oppTeamMembers = new List<Opportunity>([Select Name, Id,Related_Engagement__c,
                (SELECT Id, UserId, TeamMemberRole
                 FROM   OpportunityTeamMembers where EngTeamCreated__c= false) FROM Opportunity 
                                          WHERE Related_Engagement__c IN :engagementId AND Type != 'New Business']);
        
        System.debug('@@@ Opportunities :-'+oppTeamMembers[0].Name);
       } 
     }