• sfdc007
  • NEWBIE
  • 225 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 85
    Questions
  • 90
    Replies
Hi ,

I need help on following error

I have a visualforce page with a input field and a button below , when i click the button without giving any value in input field , i am getting the below error

List Index out of Bounds :1
Controller method referred in VF Page :


public PageReference Ok() {
    try {  
    
        string Vz = Vzid;        
        list<user>lstU = new list<user>();  
        system.debug('VZ==>'+Vz);
        lstU = [select vz_id__c, Id, name, email from user where vz_id__c =:Vz];
        if(lstU.size()==0){
           ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Kindly Enter a Valid "VZID" '));
        return null;
        }
        string Name = lstU[0].Name;
        string[] strName = Name.split(' ');
        FirstName = strName[0];
        LastName = strName[1];
        EmailId = lstU[0].email;
    } 
     catch (Exception e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
      return null;
    }
    
  // return page.HackathonRegistrationPage1;
        PageReference pr = new PageReference('/apex/HackathonRegistrationPage2'); 
        pr.setRedirect(false);
        return pr;  
     

  }


It happens on click of "Proceed" button in my VF Page

Kindly help me on it pls
 
MY VF PAGE :

<apex:page standardController="Hackathon_Registration__c" extensions="RegistrationController">



     <apex:includeScript value="{!$Resource.JQUERY_1_9_1}"/>       
        <apex:includeScript value="{!$Resource.HandsOnTableJS}"/>
        <apex:includeScript value="{!URLFOR($Resource.Select2, '/select2/select2.min.js')}"/>
        <apex:includeScript value="{!$Resource.HandsOnTableSelect2}"/>   
        <apex:stylesheet value="{!URLFOR($Resource.Select2, '/select2/select2.css')}"/>
        <apex:stylesheet value="{!$Resource.HandsOnTableCSS}"/>
    <style>  
            body .bPageBlock .detailList tr td, body .bPageBlock .detailList tr th, body table.list tr td, body table.list tr th, body .hoverDetail .bPageBlock .detailList tr td, body .hoverDetail .bPageBlock .detailList tr th {
    border-color: #0C0909;
}

.custom1  {
    background-color: red !important;
}
.custom3 {
    background-color: green !important;
}

.custom2 {
    background-color: orange!important;
}


  </style>
  
  
  
  <apex:sectionHeader title="Visualforce" subtitle="Hackthon Registration"/>

  <apex:form >
    <apex:pageMessages /> <!-- this is where the error messages will appear -->
      <apex:pageBlock mode="edit">
      
      <apex:outputPanel layout="block" styleClass="custom1">
      <apex:pageBlockSection title="Registration Users  Information Details"  columns="1"> 
      </apex:pageBlockSection>
         </apex:outputPanel>  
  <apex:pageBlockSection columns="3">         
             <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Name"></apex:outputLabel>
                    <apex:outputLabel value="{!FirstName}{!LastName}"></apex:outputLabel>
                </apex:pageBlockSectionItem> 
      <apex:pageBlockSectionItem >
                   <!-- <apex:outputLabel value="LastName"></apex:outputLabel>
                    <apex:outputLabel value="{!LastName}"></apex:outputLabel>
                </apex:pageBlockSectionItem> 
      <apex:pageBlockSectionItem > -->
      
                    <apex:outputLabel value="Email"></apex:outputLabel>
                    <apex:outputLabel value="{!eMailId}"></apex:outputLabel>
                </apex:pageBlockSectionItem>
          </apex:pageBlockSection>  
          
    <apex:outputPanel layout="block" styleClass="custom3">       
   <apex:pageBlockSection title=" Please Add Registration Details" columns="1">              
   </apex:pageBlockSection>
    </apex:outputPanel>  
    
   <apex:pageBlockSection columns="1" >
    <apex:pageBlockSectionItem >
            <apex:outputPanel >
            <apex:outputLabel value="{!$ObjectType.Hackathon_Registration__c.Fields.Team_Name__c.Label}"/>          
            </apex:outputPanel>
            <apex:inputField Value="{!HacRegMain.Team_Name__c}"/>
    </apex:pageBlockSectionItem>
    <apex:pageBlockSectionItem >
            <apex:outputPanel >
            <apex:outputLabel value="{!$ObjectType.Hackathon_Registration__c.Fields.PassWord__c.Label}"/>           
            </apex:outputPanel>
            <apex:inputField Value="{!HacRegMain.PassWord__c}"/>
    </apex:pageBlockSectionItem>
    <apex:pageBlockSectionItem >
            <apex:outputPanel >
            <apex:outputLabel value="{!$ObjectType.Hackathon_Registration__c.Fields.Re_Enter_PassWord__c.Label}"/>          
            </apex:outputPanel>
            <apex:inputField Value="{!HacRegMain.Re_Enter_PassWord__c}"/>
    </apex:pageBlockSectionItem>          
   </apex:pageBlockSection>

          <div class="handsontable">
          
                 <apex:outputPanel layout="block" styleClass="custom2">       
          <apex:pageBlockSection title="Add Team Member Details" columns="1" collapsible="false">

        </apex:pageBlockSection>
                  </apex:outputPanel> 
                              <c:Hackathon_Detail_Component id="Haccomp"  Reg_Id="{!RegId}" Table_Name="{!'HackRegistion'}"/>     
         </div>

       <apex:pageBlockButtons location="bottom">    
            <input type="button" onclick="btnClick();" value="Save" id="btnSaveHTML"/> 
    </apex:pageBlockButtons>
<apex:actionFunction name="fnSaveNow" action="{!fnSave}" oncomplete="saveMainGrids();"/> 
<apex:actionFunction name="fnRedirect" action="{!fnRedirect}" />
    </apex:pageBlock>  
      <apex:pageBlock >
<apex:pageBlockSection >

<script>

function saveMainGrids() {  
      tempDisableBeforeUnload = true;
    data1.splice(data1.length-1,1);  
  RegistrationController.savemaingrid('{!RegId}','{!'HackRegistion'}',data1,function (result,event2)
              {
               
                  if(event2.status) 
                  {
                      tempDisableBeforeUnload = true;
                     fnRedirect();
                      
                  } 
              });  
        
      }
     
</script>
 <script>
        function btnClick() {           
             fnSaveNow();
        } 
    </script> 
   
</apex:pageBlockSection>
</apex:pageBlock>

  </apex:form>
</apex:page>



 
Hi,

I need to write a trigger for the below scenario as follows,

Add After Upsert trigger code (SasLineItemAfter) on SAS_Line_Item__c object to upsert SAS_Line_Item__c .SAS_Assigned_SA__c into the SAS_Line_Item__c.Engagement_Script__c.Opportunity__c Sales Team.  We are not going to remove Sales Team if the SAS_Assigned_SA__c is changed to somebody else. Watch for Sales Team validtions that may come up. We don’t want those validations to just pop unhandled in the inline VF. We should trap those errors gracefully.
Add SA(s) from the Assigned SA field of the TF to the Opportunity Sales Team (on the Opportunity) with:
  1. Status = Active
  2. Team Role = Tier 2/3 SA
  3. Opportunity Access = Read/Write
Note: if multiple SAs found, put all them in the Opportunity Sales Team
Existing Assign SAs will not be added to the Opportunity Sales Team


I have written th e below trigger . but not sure if its right , kindly help me on this  issue

MY TRIGGER :
trigger OTOpportunityTrigger on SAS_Line_Item__c (before update) {
    List<OpportunityTeamMember> listOpptyTeamMem = new List<OpportunityTeamMember>();
    Set<Id> OpptyIdSet =  new Set<Id>();
    for(SAS_Line_Item__c sas : trigger.New)
    {
        //Checking Oppty SecondaryOwner
        if(sas.SAS_Assigned_SA__c != null)
        {
            OpportunityTeamMember OTM = new OpportunityTeamMember();
            OTM.UserOrGroupId = sas.SAS_Assigned_SA__c;
            OTM.Status ='Active';
            OTM.TeamMemberRole = 'Tier 2/3 SA';
            OTM.OpportunityAccessLevel = 'Read/Write';
            listOpptyTeamMem.add(OTM);

        if(listOpptyTeamMem.size() > 0)
        insert listOpptyTeamMem;

        
}
}
}

Kindly help me pls

Thanks in advance
Hi,

I am trying to write test class for the below batch class ,

I am getting the following error on my test class


System.NullPointerException: Business Hours Id cannot be null 
 
MY BATCH CLASS :




global class CROBatchController implements Database.Batchable<sObject> {
    global string strBusHrId;
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        BusinessHours bh = [SELECT Id, Name FROM BusinessHours WHERE Name = 'Defend'];
        if(bh != null){
            strBusHrId = bh.Id; 
        }
        // SOQL Query to fetch the values of hours , minutes and days
        String query = 'select Id, Status__c,CreatedDate From Team_Form__c where Status__c = \'New\' and Engagement_Team__r.Initial__c = \'Defend\'';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Team_Form__c> lstTF)
    {
        system.debug('strBusHrId=>'+strBusHrId);
        List<Id> lstTFIds = new List<Id>();
        map<Id,DateTime>tfCDtMap = new map<Id,DateTime>();
        
        for(Team_Form__c objTF: lstTF){
        	lstTFIds.add(objTF.Id); 
        }
        
        for(Team_Form__History objTFHis:[select Id, CreatedDate, NewValue,OldValue,ParentId from Team_Form__History where Field = 'Status__c' and ParentId in :lstTFIds Order By CreatedDate ASC]){
            if(string.valueof(objTFHis.NewValue) == 'New'){
            	tfCDtMap.put(objTFHis.ParentId,objTFHis.CreatedDate);
            }
        }
        
        Datetime startDate, endDate;
        endDate = System.Datetime.now();        
        string subject;
        map <Id, String> chatterTextMap = new map <Id, String> ();
        map <Id, set <Id>> mentionIdMap = new map <Id, set <Id>> ();
        List<Id> lsmentionId = new List<Id>();        
        for(Team_Group_Member__c objTGM :[select Id, Engagement_Team__r.Initial__c,User__c From Team_Group_Member__c where User_Role__c = 'Super User' and Engagement_Team__r.Initial__c = 'Defend']){                
            lsmentionId.add(objTGM.User__c);
        }        
        for(Team_Form__c objTF: lstTF)
        {            
            if(tfCDtMap.get(objTF.Id) != null){
                startDate = tfCDtMap.get(objTF.Id);
            }else{
               startDate = objTF.Createddate; 
            }
			long businessMillisecondsDiff = BusinessHours.diff(strBusHrId, startDate, endDate);             
            long millitoHrs = businessMillisecondsDiff/3600000;
            if(millitoHrs >= 48){                
                subject = 'TF is in \'New\' status for more than 48hrs';
                chatterTextMap.put(objTF.Id,Subject);
                mentionIdMap.put(objTF.Id,new set <Id>(lsmentionId));
                if(chatterTextMap.size()>0){
                    CommunityUtility.postCustomFeedItem (mentionIdMap, chatterTextMap, 'AllUsers');
                }
            }
        }         
    }  
    global void finish(Database.BatchableContext BC)
    {
    }
}
MY TEST CLASS

@isTest
Public class CROBatchController_Test{
public static testMethod void testBatch() {
 skipingHelper.SkippThemAll();
 BusinessHours bh = [SELECT Id, Name FROM BusinessHours WHERE Name = 'Defend'];
 Account acct = GPSTestUtilities.createTestAccount();
 Opportunity oppty1 = GPSTestUtilities.createTestOpportunity(acct.Id);
 Engagement_Script__c ES = GPSTestUtilities.createEngagementScript(acct.Id,oppty1.Id);  
 Engagement_Team__c ET = createEngagementTeamDefend();   
 Team_Form__c TF = createTeamFormDefend(ES.Id);  
 //Team_Group_Member__c  TFMem =createTeamGroupMemberDefend(); 
    
    Test.startTest();
	   CROBatchController mbcCon=new CROBatchController();
       //mbcCon.businessHrsId = bh.Id;
		ID batchprocessid = Database.executeBatch(mbcCon);
	Test.stopTest();
}
    	 public static Engagement_Team__c createEngagementTeamDefend() {  
        list<Engagement_Team__c> ET1 =[SELECT ID,Initial__c FROM Engagement_Team__c WHERE  Initial__c ='Defend' limit 1];
        Engagement_Team__c tmobj = new Engagement_Team__c();
        if(ET1.size()==0){
            Engagement_Team__c ET = new Engagement_Team__c();
            ET.Engagement_Model__c = 'Queue';
            ET.IsActive__c = true;
            ET.Engage_Direct__c = true;
            ET.Engage_Period__c =  'PreSales';
            ET.Engaged_By__c = 'Sales & Support';
            ET.Group_API_Name__c='EP_Defend_Group';
            ET.Queue_API_Name__c ='EP_Defend_Queue';
            ET.Super_User_Group__c='EP_Defend_SuperUser';
            ET.Initial__c ='Defend';
            ET.Team_Name__c ='Defend Team';           
            insert ET;
            tmobj =  ET;               
        }
        else{
            tmobj= ET1[0];}        
        return tmobj;
    }
    
    public static Team_Form__c createTeamFormDefend(Id ESId) {
        Engagement_Team__c ET=createEngagementTeamDefend();
        
        Engaged_Team__c engtm= new Engaged_Team__c (Engagement_Team__c=ET.Id,Engagement_Script__c=ESId);
        Insert engtm;
        
        Id rectypeid=[select Id,name from RecordType where NAME='Defend' and SobjectType='Team_Form__c' limit 1].Id;
        Team_Form__c TF = new Team_Form__c();
        TF.Engagement_Script__c = ESId;
        TF.Engagement_Team__c = ET.Id;    
        TF.Status__c='New';
        TF.RecordTypeId = rectypeid; 
        TF.OwnerId =  UserInfo.getUserId();
        TF.Revision_Reason__c = 'Cost/Price Impacting Change in Requirements';
        TF.Revision_Reason_Detail__c = 'Number of sites';
        TF.IsActive__c = true;
        insert TF;
        
        return TF;
    }

    
}


Kindly help me what is the issue here pls

Thanks in Advance
Hi,

I am trying to write test class for the below batch class ,I am getting the following error on my test class


System.NullPointerException: Business Hours Id cannot be null
 
MT BATCH CLASS :


global class CROBatchController implements Database.Batchable<sObject> {
    global string strBusHrId;
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        BusinessHours bh = [SELECT Id, Name FROM BusinessHours WHERE Name = 'Defend'];
        if(bh != null){
            strBusHrId = bh.Id; 
        }
        // SOQL Query to fetch the values of hours , minutes and days
        String query = 'select Id, Status__c,CreatedDate From Team_Form__c where Status__c = \'New\' and Engagement_Team__r.Initial__c = \'Defend\'';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Team_Form__c> lstTF)
    {
        system.debug('strBusHrId=>'+strBusHrId);
        List<Id> lstTFIds = new List<Id>();
        map<Id,DateTime>tfCDtMap = new map<Id,DateTime>();
        
        for(Team_Form__c objTF: lstTF){
        	lstTFIds.add(objTF.Id); 
        }
        
        for(Team_Form__History objTFHis:[select Id, CreatedDate, NewValue,OldValue,ParentId from Team_Form__History where Field = 'Status__c' and ParentId in :lstTFIds Order By CreatedDate ASC]){
            if(string.valueof(objTFHis.NewValue) == 'New'){
            	tfCDtMap.put(objTFHis.ParentId,objTFHis.CreatedDate);
            }
        }
        
        Datetime startDate, endDate;
        endDate = System.Datetime.now();        
        string subject;
        map <Id, String> chatterTextMap = new map <Id, String> ();
        map <Id, set <Id>> mentionIdMap = new map <Id, set <Id>> ();
        List<Id> lsmentionId = new List<Id>();        
        for(Team_Group_Member__c objTGM :[select Id, Engagement_Team__r.Initial__c,User__c From Team_Group_Member__c where User_Role__c = 'Super User' and Engagement_Team__r.Initial__c = 'Defend']){                
            lsmentionId.add(objTGM.User__c);
        }        
        for(Team_Form__c objTF: lstTF)
        {            
            if(tfCDtMap.get(objTF.Id) != null){
                startDate = tfCDtMap.get(objTF.Id);
            }else{
               startDate = objTF.Createddate; 
            }
			long businessMillisecondsDiff = BusinessHours.diff(strBusHrId, startDate, endDate);             
            long millitoHrs = businessMillisecondsDiff/3600000;
            if(millitoHrs >= 48){                
                subject = 'TF is in \'New\' status for more than 48hrs';
                chatterTextMap.put(objTF.Id,Subject);
                mentionIdMap.put(objTF.Id,new set <Id>(lsmentionId));
                if(chatterTextMap.size()>0){
                    CommunityUtility.postCustomFeedItem (mentionIdMap, chatterTextMap, 'AllUsers');
                }
            }
        }         
    }  
    global void finish(Database.BatchableContext BC)
    {
    }
}
MY TEST CLASS :


@isTest
Public class CROBatchController_Test{
public static testMethod void testBatch() {
 skipingHelper.SkippThemAll();
 BusinessHours bh = [SELECT Id, Name FROM BusinessHours WHERE Name = 'Defend'];
 Account acct = GPSTestUtilities.createTestAccount();
 Opportunity oppty1 = GPSTestUtilities.createTestOpportunity(acct.Id);
 Engagement_Script__c ES = GPSTestUtilities.createEngagementScript(acct.Id,oppty1.Id);  
 Engagement_Team__c ET = createEngagementTeamDefend();   
 Team_Form__c TF = createTeamFormDefend(ES.Id);  
 //Team_Group_Member__c  TFMem =createTeamGroupMemberDefend(); 
    
    Test.startTest();
	   CROBatchController mbcCon=new CROBatchController();
       //mbcCon.businessHrsId = bh.Id;
		ID batchprocessid = Database.executeBatch(mbcCon);
	Test.stopTest();
}
    	 public static Engagement_Team__c createEngagementTeamDefend() {  
        list<Engagement_Team__c> ET1 =[SELECT ID,Initial__c FROM Engagement_Team__c WHERE  Initial__c ='Defend' limit 1];
        Engagement_Team__c tmobj = new Engagement_Team__c();
        if(ET1.size()==0){
            Engagement_Team__c ET = new Engagement_Team__c();
            ET.Engagement_Model__c = 'Queue';
            ET.IsActive__c = true;
            ET.Engage_Direct__c = true;
            ET.Engage_Period__c =  'PreSales';
            ET.Engaged_By__c = 'Sales & Support';
            ET.Group_API_Name__c='EP_Defend_Group';
            ET.Queue_API_Name__c ='EP_Defend_Queue';
            ET.Super_User_Group__c='EP_Defend_SuperUser';
            ET.Initial__c ='Defend';
            ET.Team_Name__c ='Defend Team';           
            insert ET;
            tmobj =  ET;               
        }
        else{
            tmobj= ET1[0];}        
        return tmobj;
    }
    
    public static Team_Form__c createTeamFormDefend(Id ESId) {
        Engagement_Team__c ET=createEngagementTeamDefend();
        
        Engaged_Team__c engtm= new Engaged_Team__c (Engagement_Team__c=ET.Id,Engagement_Script__c=ESId);
        Insert engtm;
        
        Id rectypeid=[select Id,name from RecordType where NAME='Defend' and SobjectType='Team_Form__c' limit 1].Id;
        Team_Form__c TF = new Team_Form__c();
        TF.Engagement_Script__c = ESId;
        TF.Engagement_Team__c = ET.Id;    
        TF.Status__c='New';
        TF.RecordTypeId = rectypeid; 
        TF.OwnerId =  UserInfo.getUserId();
        TF.Revision_Reason__c = 'Cost/Price Impacting Change in Requirements';
        TF.Revision_Reason_Detail__c = 'Number of sites';
        TF.IsActive__c = true;
        insert TF;
        
        return TF;
    }

    
}


Kindly help me what is the issue here pls

Thanks
 
Hi,

I am trying to write test class for the below batch class , Kindly help me how to write the test class for it please

 
MY BATCH CLASS :




global class CROBatchController implements Database.Batchable<sObject> {
    global string strBusHrId;
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        BusinessHours bh = [SELECT Id, Name FROM BusinessHours WHERE Name = 'Defend'];
        if(bh != null){
            strBusHrId = bh.Id; 
        }
        // SOQL Query to fetch the values of hours , minutes and days
        String query = 'select Id, Status__c,CreatedDate From Team_Form__c where Status__c = \'New\' and Engagement_Team__r.Initial__c = \'Defend\'';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Team_Form__c> lstTF)
    {
        system.debug('strBusHrId=>'+strBusHrId);
        List<Id> lstTFIds = new List<Id>();
        map<Id,DateTime>tfCDtMap = new map<Id,DateTime>();
        
        for(Team_Form__c objTF: lstTF){
        	lstTFIds.add(objTF.Id); 
        }
        
        for(Team_Form__History objTFHis:[select Id, CreatedDate, NewValue,OldValue,ParentId from Team_Form__History where Field = 'Status__c' and ParentId in :lstTFIds Order By CreatedDate ASC]){
            if(string.valueof(objTFHis.NewValue) == 'New'){
            	tfCDtMap.put(objTFHis.ParentId,objTFHis.CreatedDate);
            }
        }
        
        Datetime startDate, endDate;
        endDate = System.Datetime.now();        
        string subject;
        map <Id, String> chatterTextMap = new map <Id, String> ();
        map <Id, set <Id>> mentionIdMap = new map <Id, set <Id>> ();
        List<Id> lsmentionId = new List<Id>();        
        for(Team_Group_Member__c objTGM :[select Id, Engagement_Team__r.Initial__c,User__c From Team_Group_Member__c where User_Role__c = 'Super User' and Engagement_Team__r.Initial__c = 'Defend']){                
            lsmentionId.add(objTGM.User__c);
        }        
        for(Team_Form__c objTF: lstTF)
        {            
            if(tfCDtMap.get(objTF.Id) != null){
                startDate = tfCDtMap.get(objTF.Id);
            }else{
               startDate = objTF.Createddate; 
            }
			long businessMillisecondsDiff = BusinessHours.diff(strBusHrId, startDate, endDate);             
            long millitoHrs = businessMillisecondsDiff/3600000;
            if(millitoHrs >= 48){                
                subject = 'TF is in \'New\' status for more than 48hrs';
                chatterTextMap.put(objTF.Id,Subject);
                mentionIdMap.put(objTF.Id,new set <Id>(lsmentionId));
                if(chatterTextMap.size()>0){
                    CommunityUtility.postCustomFeedItem (mentionIdMap, chatterTextMap, 'AllUsers');
                }
            }
        }         
    }  
    global void finish(Database.BatchableContext BC)
    {
    }
}

Kindly help me pls

Thanks in Advance
 
Hi,

I need help on the following requirement as follows


1) i am trying to prepare an excel sheet with all the org limits details as follows

i have written an vf page and an apex code which will extract the object name with the limits corresponding to it

similary i am trying to figure how to get the other details

Item               Usage      Limit  % used
Custom Fields 19           800     2%  
Custom Relationship Fields 2 50 4%  
Active Workflow Rules 1 100 1%  
Total Workflow Rules 1 500 0%  
Approval Processes 0 500 0%  
Active Lookup Filters 0 10 0%  
Active Validation Rules 0 500 0%  
VLOOKUP Functions 0 10 0%  
Sharing Rules (Both Owner- and Criteria-based) 0 300 0%  
Sharing Rules (Criteria-based Only) 0 200 0%  



i want to get the details of others highlighted in bold

Kindly help me how to get thse info pls
 
MY APEX CODE :

public class ObjectListController {
    public String val {get;set;} 
    public List<SelectOption> getName() 
    { 
        
        List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();      
       
        List<SelectOption> options = new List<SelectOption>(); 
        for(Schema.SObjectType f : gd) 
        { 
            
            options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel())); 
            
        } 
        return options; 
        
    } 
    public List<String> getObName() 
    { 
        List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();      
        List<string> options = new List<string>(); 
        for(Schema.SObjectType f : gd) 
        { 
            
           	string ObjectName = f.getDescribe().getLabel();
            system.debug('ObjectName==>'+ObjectName);
             integer FieldCount = f.getDescribe().fields.getMap().size();
			system.debug('FieldCount==>'+FieldCount);
			
            options.add(f.getDescribe().getLabel() +' ; '+ f.getDescribe().fields.getMap().size()); 
            
          
        } 
        System.debug('wewetwet'+options);
        return options; 
        
    } 
 
}
MY VF CODE :

<apex:page controller="ObjectListController" readOnly="true" > 
    <apex:form >
        <apex:pageBlock >
        <apex:pageBlockTable value="{!obName}" var="o">
            <apex:column value="{!o}"/>
        </apex:pageBlockTable> 
        <apex:SelectList value="{!val}" size="1"> 
            <apex:selectOptions value="{!Name}"></apex:selectOptions> 
        </apex:SelectList> 
            </apex:pageBlock>
    </apex:form> 
</apex:page>


Kindly help me pls

Thanks in Advance
Hi,

I have a batch class where i am trying to write the test class for it

Help me how to write the test class for it
 
MY BATCH CLASS :

global class MillisecondBatchConvertController implements Database.Batchable<sObject>
{
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        // SOQL Query to fetch the values of hours , minutes and days
        String query = 'SELECT Hours__c, Minutes__c, Days__c FROM PS_TF_Status_Track__c';
        return Database.getQueryLocator(query);
    }
 
    global void execute(Database.BatchableContext BC, List<PS_TF_Status_Track__c> scope)
    {
         for(PS_TF_Status_Track__c currPS: scope)
         {
            long hoursToMilliSeconds  = Integer.Valueof(currPS.Hours__c != null ? currPS.Hours__c * 3600000 : 0);
            long minToMilliSeconds = Integer.Valueof(currPS.Minutes__c != null ? currPS.Minutes__c * 60000 : 0);
            long daysToMilliSeconds =  Integer.Valueof(currPS.Days__c != null ? currPS.Days__c * 86400000 : 0);
        
             // Enter your custom field to sum all three fields values.
             currPS.Total_Milliseconds__c =  hoursToMilliSeconds + minToMilliSeconds + daysToMilliSeconds;

         }
         update scope;
    }  
    global void finish(Database.BatchableContext BC)
    {
    }
}
 Kindly help me pls

Thanks in Advance
 
  • September 22, 2015
  • Like
  • 0
Hi,

I have a requirement where i need to write a batch class for which i need help n it

I have a custom object called "PS_TF_Status_Track__c"

I have 3 number fields in it called Hours__c, Minutes__c and days__c

i want to write a batch class which should calculate the milli seconds for all the 3 fields mentioned above and sum it up to a single custom field

Hours -> milli seconds
Minutes -> milli seconds
days -> milli seconds

the single custom field should sum up all the 3 milli seconds together

let me know hw to write it

Pls help me

Thanks in Advance
  • September 21, 2015
  • Like
  • 0
Hi,

I am trying to create a formula field for the below requirement for which i need help on it


I have to convert milli seconds value given to the normal time value using a formula field


I tried the below formula its working fine for hours,minutes and seconds , but not sure how to add days to it

 
MY FORMULA :

if(((Duration_Number__c /1000)<60),'0hr/ 0min /' + text( ((Duration_Number__c /1000))) +'sec',
if(and(((Duration_Number__c /1000)/60)>0,((Duration_Number__c /1000)/60)<60),'0hrs /'+
text(floor( ((Duration_Number__c /1000)/60))) +'min/'+text(mod((Duration_Number__c /1000),60))+

'secs',if(((Duration_Number__c /1000)/360)>0,text(floor( ((Duration_Number__c /1000)/3600)))+'hrs/'+
text(floor(MOD(((Duration_Number__c /1000)/60),60)))+'mins/'+	
text(mod((Duration_Number__c /1000),60))+'secs','nope')))

Kindly help me pls

Thanks in Advance
 
  • September 21, 2015
  • Like
  • 0

Hi,

I am trying to create a formula field for the below requirement for which i need help on it


I have to convert milli seconds value given to the normal time value using a formula field


I tried the below formula its working fine for minutes and seconds , but not sure how to add hours to it

MY FORMULA :
IF((MOD((Duration_Number__c )/60,1)*60) > 10,
TEXT(FLOOR( (Duration_Number__c )/60)) + ":" + TEXT( FLOOR(MOD((Duration_Number__c )/60,1)*60) ),
TEXT(FLOOR( (Duration_Number__c )/60)) + ":0" + TEXT( FLOOR(MOD((Duration_Number__c )/60,1)*60) )
)

I tried to add hrs but getting incorrect number of parameters in if expected 3 recieved 4

Help me how to add hrs in my formula

Thanks in Advance
  • September 18, 2015
  • Like
  • 1
Hi,

I am trying to create a formula field for the below requirement for which i need help on it


I have to convert milli seconds value given to the normal time value using a formula field

let me know the formula field logic to achieve it

Thanks in Advance
  • September 18, 2015
  • Like
  • 1
Hi,

I have a HTML Page where i have a button on it , when i click on the button i am invoking a rest api from my developer account

my issue is , when i click on the button i am just getting the alert message , but when i right click the button and select inspect element i am able to see the output from my rest api

i need to parse and show it as a output on a button click in my html page for which i need help on it

Kindly help me pls
 
MY HTML CODE :

<!DOCTYPE html>
<html>
   <head> 
     <script type="text/javascript" src="jquery-2.1.4.min.js"></script>

     <script>
      function getTasks() {


       $.getJSON("https://bharathnrest-developer-edition.ap2.force.com/services/apexrest/opportunity",
          function(data){
            alert("Data Loaded: " + data);
// $("#content").val(data);
         });
    }
	function jsonpCallback(data){
	alert(data);
}
    </script>
   </head>
   <body>
     <center> <button onclick="javascript:getTasks();">REST API </button></center>
   </body>
</html>
 
my output :

AccountId	"00128000005yLY7AAM"

attributes	[object]
Id	"00628000004KwQ0AAK"
Name	"data-"


Help me how to parse this info in html page

Thanks in Advance
Hi,

I need help on the following requirement as follows

I have a  External HTML Page(not in visualforce) where i am trying to invoke a REST API call which i have in my developer account on a button click of html page

But when i click on the buttin nothing is happening , let me know what i am doing wrong here

 
MY HTML PAGE :


<html>
   <head> 
     <script type="text/javascript" src="jquery-1.6.4.js"></script>

     <script>
      function getTasks() {
        $.get("https://ap2.salesforce.com/services/apexrest/opportunity",
          function(data){
            alert("Data Loaded: " + data);
          });
    }
    </script>
   </head>
   <body>
      <button onclick="javascript:getTasks();">Show Match</button>
   </body>
</html>


I have inclued the REST API url in Remote site settings call back url
 
REST CLASS IN MY DEVELOPER EDITION:

@RestResource(urlMapping='/opportunity/*')
global with sharing class MyRestResource {

@HttpGet
    global static opportunity doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        //String opportunityId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        opportunity result = [SELECT Id, Name,Account.name,owner.name FROM opportunity WHERE Id = '00628000004KwQ0'];
        return result;
    }

@HttpPost
global static String doPost(String name,
    String phone, String website) {
    opportunity opportunity = new opportunity();
    opportunity.Name = name;
    insert opportunity;
    return opportunity.Id;
}
}

Kindly help me pls

Thanks in Advance

 
Hi,

I need help on the following requirement which should be done via REST API

I have a HTML Page with a button in it, when i click the button , i should populate a opportunity record from salesforce

Let me know how to do it , Kindly help me pls

Thanks in Advance
Hi,

I need help on the following requirement as follows,

I have a visualforce page where i have a button in it , when i click the button it is calling my REST API apex class where i am passing the opportunity id and it should display

but when i click on the button i am getting the following error as follows

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]


Let me know what i should do to resove it , i need to display the opportunity record alone on clik of that button through rest api
 
MY VF PAGE :

<apex:page controller="getservice2">
<apex:form >
<apex:commandButton action="{!getResult}" value="REST API" id="theButton"/>
        <br/><br/>        {!myresponse}
</apex:form>
  </apex:page>
MY REST API CLASS :

@RestResource(urlMapping='/opportunity/*')
global with sharing class MyRestResource {

@HttpGet
    global static opportunity doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        //String opportunityId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        opportunity result = [SELECT Id, Name,Account.name,owner.name FROM opportunity WHERE Id = '00628000004KwQ0'];
        return result;
    }

@HttpPost
global static String doPost(String name,
    String phone, String website) {
    opportunity opportunity = new opportunity();
    opportunity.Name = name;
    insert opportunity;
    return opportunity.Id;
}
}
MY APEX CLASS WHERE MY REST API CONTTOLLER IS REFERRED :

public class getservice2
{
    public String myresponse{get;set;}
    public Pagereference getResult()
    {
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setMethod('GET');
        String url = 'https://ap2.salesforce.com/services/apexrest/opportunity';
        req.setEndpoint(url);
        HTTPResponse resp = http.send(req);
        myresponse=resp.getBody();          

        return null;    }
}




Help me pls

Thanks in Advance
Hi,

I am having 2 formulas which is holding the values of the mul ti select picklst values in it , i am trying to conacenate both the formulas in another formula field , where i am not able to save it

getting formula size char exceeded error

Kindly help me what to do in my case


Thanks in Advance
Hi,

I have a fomula field on a custom object called as "Campaign topic "  which is not firing and throwing the following error


formula text is exceeded  Char limit


Let me know how to fix it or we just create another formula and concatenate in this Campaign topic formula?


Kindly help me pls

Thanks in Advance
MY FORMULA FIELD :


IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Cloud"), "Cloud; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Communications"), "Communications; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Connected Machines"), "Connected Machines; ", NULL)+
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Core Network"), "Core Network; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "CPE"), "CPE; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Data Center Services"), "Data Center Services; ", NULL)+
IF(INCLUDES(Campaign_Name__r.Campaign_Topic__c , "Machine-to-Machine Pro Serv"), "Machine-to-Machine Pro Serv; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Managed Solutions"), "Managed Solutions; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Med Bus Bundle"), "Med Bus Bundle; ", NULL)+
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Mobility Solutions"), "Mobility Solutions; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Net Conferencing Services"), "Net Conferencing Services; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Other"), "Other; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Parent - Multi"), "Parent - Multi; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Partner"), "Partner; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Professional Services"), "Professional Services; ", NULL)+
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Security Solutions"), "Security Solutions; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Strategic Network"), "Strategic Network; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Thought Leadership"), "Thought Leadership; ", NULL)

 
Hi,

I have a requirement on REST API for which i need some help on it


1) I have a HTML Page which is having a button in it

on click of that button it should navigate me to a specific opportunity record ( we can harcode the opp id)

these process has to be done via REST API

Help me how to achieve it using REST API code pls

Thanks in Advance
Hi,

I am having a trigger on feed item which will fetch the account and opportunity id along  with the @mention

i  have a class which will store the @mention , and a trigger which will store the account and opp id

my issue is the trigger is throwing record is read  only on( after insert ) , whereas the before insert is fetching the ids but the @mention gets grad out

my logic needs after insert trigger only

 
MY TRIGGER :

trigger FeedItemTrigger on FeedItem (after insert , after update) {
  
  if(PIPIntelHelper.skipChatterTriggers == true)
    return;
  
  List<FeedItem>feeditemupdatelist = new List<FeedItem>();
  set<id> parentAccountIds = new set<id>();
  
  for(FeedItem fdItem : trigger.new){
    String idStr = fdItem.Parentid;
    if(idStr.startsWith('006')){
       parentAccountIds.add(idStr);
    }
  }
    
  System.debug('parentAccountIds'+ parentAccountIds);
  Map<id,Opportunity> oppty  = new Map<id,Opportunity>([Select id, AccountId  from Opportunity where id in:parentAccountIds]);

  if(oppty.size()>0){
    for(FeedItem fdItem : trigger.new){
      String chatterBody = fdItem.Body;
      Opportunity parentopportunity = oppty.get(fdItem.Parentid);
      FeedItem f = new FeedItem(id = fdItem.id,Body = chatterBody + '\n Account Id is :'+ parentopportunity.AccountId + ' \n Opportunity Id :'+parentopportunity.Id);
      System.debug('feeditemlist'+fdItem );

      feeditemupdatelist.add(f);
    }
    //if(feeditemupdatelist!=null){
    PIPIntelHelper.skipChatterTriggers = true;

   // update feeditemupdatelist;
         system.debug('feeditemlistupdate'+feeditemupdatelist);
   // }
    }
}
 I am able to store the @mention , but the account ids and opp ids are not getting populated , help me what do i need to change in my trigger


Thanks in Advance
 
Hi,
 
MY APEX CLASS CODE :

for(ProcessInstanceStep pInst : [Select OriginalActorId, ActorId, StepStatus From ProcessInstanceStep where ProcessInstance.TargetObjectId=:oNew.id  order by CreatedDate desc limit 1] ) 
                {
                    If(pInst.OriginalActorId <> pInst.ActorId)
                    {
                        string strsub;  
                        String body;
                        user usr=[select id,email from user where id=:pInst.OriginalActorId];
                        user usr1=[select id,name from user where id=:pInst.ActorId];

                        if(pInst.StepStatus=='Approved')
                        {
                            strsub = oNew.Name+' has been approved by  '+usr1.name;
                            body = '<p>'+oNew.Name+' has been approved by  '+usr1.name+' on your behalf on '+system.now()+'. </p>' ;
                        }
                        if(pInst.StepStatus=='Rejected')
                        {
                            strsub = oNew.Name+' has been rejected by  '+usr1.name;
                            body = '<p>'+oNew.Name+' has been rejected by  '+usr1.name+' on your behalf on '+system.now()+'. </p>' ;
                        }

                        List<Messaging.SingleEmailMessage> mailMessages = new List<Messaging.SingleEmailMessage>();
                        String[] toAddresses = new String[]{}; 
                        toAddresses.add(usr.email);
                        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                        mail.setToAddresses(toAddresses);
                        mail.setReplyTo('no-reply@verizon.com');
                        mail.setSubject(strsub);
                        URL currentUrl = URL.getCurrentRequestUrl();
                        URL curl = new URL(URL.getSalesforceBaseUrl().toExternalForm());
                        System.debug('currentUrl:'+currentUrl);
                        System.debug('curl:'+curl);
                        String fullRecordURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + oNew.Id;
                        System.debug('fullRecordURL:'+fullRecordURL);
                         // Add lead ids to body
                         body = body + '<br> Link to '+oNew.SFDC_Opportunity_ID__c+'-';
                         body = body + ': ' +fullRecordURL;
                         mail.setHtmlBody (body);
                         mailMessages.add(mail);
                         if(!mailMessages.isEmpty())
                         Messaging.sendEmail(mailMessages);
                    }
                }

I am having a apex class which is calling a approval process , where i need help on it to cover that part ,

i am not able to cover that part, Kindly help me on this


 

Hi,

I am trying to create a formula field for the below requirement for which i need help on it


I have to convert milli seconds value given to the normal time value using a formula field


I tried the below formula its working fine for minutes and seconds , but not sure how to add hours to it

MY FORMULA :
IF((MOD((Duration_Number__c )/60,1)*60) > 10,
TEXT(FLOOR( (Duration_Number__c )/60)) + ":" + TEXT( FLOOR(MOD((Duration_Number__c )/60,1)*60) ),
TEXT(FLOOR( (Duration_Number__c )/60)) + ":0" + TEXT( FLOOR(MOD((Duration_Number__c )/60,1)*60) )
)

I tried to add hrs but getting incorrect number of parameters in if expected 3 recieved 4

Help me how to add hrs in my formula

Thanks in Advance
  • September 18, 2015
  • Like
  • 1
Hi,

I am trying to create a formula field for the below requirement for which i need help on it


I have to convert milli seconds value given to the normal time value using a formula field

let me know the formula field logic to achieve it

Thanks in Advance
  • September 18, 2015
  • Like
  • 1
Hi ,

I need help on following error

I have a visualforce page with a input field and a button below , when i click the button without giving any value in input field , i am getting the below error

List Index out of Bounds :1
Controller method referred in VF Page :


public PageReference Ok() {
    try {  
    
        string Vz = Vzid;        
        list<user>lstU = new list<user>();  
        system.debug('VZ==>'+Vz);
        lstU = [select vz_id__c, Id, name, email from user where vz_id__c =:Vz];
        if(lstU.size()==0){
           ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Kindly Enter a Valid "VZID" '));
        return null;
        }
        string Name = lstU[0].Name;
        string[] strName = Name.split(' ');
        FirstName = strName[0];
        LastName = strName[1];
        EmailId = lstU[0].email;
    } 
     catch (Exception e) {
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
      return null;
    }
    
  // return page.HackathonRegistrationPage1;
        PageReference pr = new PageReference('/apex/HackathonRegistrationPage2'); 
        pr.setRedirect(false);
        return pr;  
     

  }


It happens on click of "Proceed" button in my VF Page

Kindly help me on it pls
 
MY VF PAGE :

<apex:page standardController="Hackathon_Registration__c" extensions="RegistrationController">



     <apex:includeScript value="{!$Resource.JQUERY_1_9_1}"/>       
        <apex:includeScript value="{!$Resource.HandsOnTableJS}"/>
        <apex:includeScript value="{!URLFOR($Resource.Select2, '/select2/select2.min.js')}"/>
        <apex:includeScript value="{!$Resource.HandsOnTableSelect2}"/>   
        <apex:stylesheet value="{!URLFOR($Resource.Select2, '/select2/select2.css')}"/>
        <apex:stylesheet value="{!$Resource.HandsOnTableCSS}"/>
    <style>  
            body .bPageBlock .detailList tr td, body .bPageBlock .detailList tr th, body table.list tr td, body table.list tr th, body .hoverDetail .bPageBlock .detailList tr td, body .hoverDetail .bPageBlock .detailList tr th {
    border-color: #0C0909;
}

.custom1  {
    background-color: red !important;
}
.custom3 {
    background-color: green !important;
}

.custom2 {
    background-color: orange!important;
}


  </style>
  
  
  
  <apex:sectionHeader title="Visualforce" subtitle="Hackthon Registration"/>

  <apex:form >
    <apex:pageMessages /> <!-- this is where the error messages will appear -->
      <apex:pageBlock mode="edit">
      
      <apex:outputPanel layout="block" styleClass="custom1">
      <apex:pageBlockSection title="Registration Users  Information Details"  columns="1"> 
      </apex:pageBlockSection>
         </apex:outputPanel>  
  <apex:pageBlockSection columns="3">         
             <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Name"></apex:outputLabel>
                    <apex:outputLabel value="{!FirstName}{!LastName}"></apex:outputLabel>
                </apex:pageBlockSectionItem> 
      <apex:pageBlockSectionItem >
                   <!-- <apex:outputLabel value="LastName"></apex:outputLabel>
                    <apex:outputLabel value="{!LastName}"></apex:outputLabel>
                </apex:pageBlockSectionItem> 
      <apex:pageBlockSectionItem > -->
      
                    <apex:outputLabel value="Email"></apex:outputLabel>
                    <apex:outputLabel value="{!eMailId}"></apex:outputLabel>
                </apex:pageBlockSectionItem>
          </apex:pageBlockSection>  
          
    <apex:outputPanel layout="block" styleClass="custom3">       
   <apex:pageBlockSection title=" Please Add Registration Details" columns="1">              
   </apex:pageBlockSection>
    </apex:outputPanel>  
    
   <apex:pageBlockSection columns="1" >
    <apex:pageBlockSectionItem >
            <apex:outputPanel >
            <apex:outputLabel value="{!$ObjectType.Hackathon_Registration__c.Fields.Team_Name__c.Label}"/>          
            </apex:outputPanel>
            <apex:inputField Value="{!HacRegMain.Team_Name__c}"/>
    </apex:pageBlockSectionItem>
    <apex:pageBlockSectionItem >
            <apex:outputPanel >
            <apex:outputLabel value="{!$ObjectType.Hackathon_Registration__c.Fields.PassWord__c.Label}"/>           
            </apex:outputPanel>
            <apex:inputField Value="{!HacRegMain.PassWord__c}"/>
    </apex:pageBlockSectionItem>
    <apex:pageBlockSectionItem >
            <apex:outputPanel >
            <apex:outputLabel value="{!$ObjectType.Hackathon_Registration__c.Fields.Re_Enter_PassWord__c.Label}"/>          
            </apex:outputPanel>
            <apex:inputField Value="{!HacRegMain.Re_Enter_PassWord__c}"/>
    </apex:pageBlockSectionItem>          
   </apex:pageBlockSection>

          <div class="handsontable">
          
                 <apex:outputPanel layout="block" styleClass="custom2">       
          <apex:pageBlockSection title="Add Team Member Details" columns="1" collapsible="false">

        </apex:pageBlockSection>
                  </apex:outputPanel> 
                              <c:Hackathon_Detail_Component id="Haccomp"  Reg_Id="{!RegId}" Table_Name="{!'HackRegistion'}"/>     
         </div>

       <apex:pageBlockButtons location="bottom">    
            <input type="button" onclick="btnClick();" value="Save" id="btnSaveHTML"/> 
    </apex:pageBlockButtons>
<apex:actionFunction name="fnSaveNow" action="{!fnSave}" oncomplete="saveMainGrids();"/> 
<apex:actionFunction name="fnRedirect" action="{!fnRedirect}" />
    </apex:pageBlock>  
      <apex:pageBlock >
<apex:pageBlockSection >

<script>

function saveMainGrids() {  
      tempDisableBeforeUnload = true;
    data1.splice(data1.length-1,1);  
  RegistrationController.savemaingrid('{!RegId}','{!'HackRegistion'}',data1,function (result,event2)
              {
               
                  if(event2.status) 
                  {
                      tempDisableBeforeUnload = true;
                     fnRedirect();
                      
                  } 
              });  
        
      }
     
</script>
 <script>
        function btnClick() {           
             fnSaveNow();
        } 
    </script> 
   
</apex:pageBlockSection>
</apex:pageBlock>

  </apex:form>
</apex:page>



 
Hi,

I am trying to write test class for the below batch class , Kindly help me how to write the test class for it please

 
MY BATCH CLASS :




global class CROBatchController implements Database.Batchable<sObject> {
    global string strBusHrId;
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        BusinessHours bh = [SELECT Id, Name FROM BusinessHours WHERE Name = 'Defend'];
        if(bh != null){
            strBusHrId = bh.Id; 
        }
        // SOQL Query to fetch the values of hours , minutes and days
        String query = 'select Id, Status__c,CreatedDate From Team_Form__c where Status__c = \'New\' and Engagement_Team__r.Initial__c = \'Defend\'';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Team_Form__c> lstTF)
    {
        system.debug('strBusHrId=>'+strBusHrId);
        List<Id> lstTFIds = new List<Id>();
        map<Id,DateTime>tfCDtMap = new map<Id,DateTime>();
        
        for(Team_Form__c objTF: lstTF){
        	lstTFIds.add(objTF.Id); 
        }
        
        for(Team_Form__History objTFHis:[select Id, CreatedDate, NewValue,OldValue,ParentId from Team_Form__History where Field = 'Status__c' and ParentId in :lstTFIds Order By CreatedDate ASC]){
            if(string.valueof(objTFHis.NewValue) == 'New'){
            	tfCDtMap.put(objTFHis.ParentId,objTFHis.CreatedDate);
            }
        }
        
        Datetime startDate, endDate;
        endDate = System.Datetime.now();        
        string subject;
        map <Id, String> chatterTextMap = new map <Id, String> ();
        map <Id, set <Id>> mentionIdMap = new map <Id, set <Id>> ();
        List<Id> lsmentionId = new List<Id>();        
        for(Team_Group_Member__c objTGM :[select Id, Engagement_Team__r.Initial__c,User__c From Team_Group_Member__c where User_Role__c = 'Super User' and Engagement_Team__r.Initial__c = 'Defend']){                
            lsmentionId.add(objTGM.User__c);
        }        
        for(Team_Form__c objTF: lstTF)
        {            
            if(tfCDtMap.get(objTF.Id) != null){
                startDate = tfCDtMap.get(objTF.Id);
            }else{
               startDate = objTF.Createddate; 
            }
			long businessMillisecondsDiff = BusinessHours.diff(strBusHrId, startDate, endDate);             
            long millitoHrs = businessMillisecondsDiff/3600000;
            if(millitoHrs >= 48){                
                subject = 'TF is in \'New\' status for more than 48hrs';
                chatterTextMap.put(objTF.Id,Subject);
                mentionIdMap.put(objTF.Id,new set <Id>(lsmentionId));
                if(chatterTextMap.size()>0){
                    CommunityUtility.postCustomFeedItem (mentionIdMap, chatterTextMap, 'AllUsers');
                }
            }
        }         
    }  
    global void finish(Database.BatchableContext BC)
    {
    }
}

Kindly help me pls

Thanks in Advance
 
Hi,

I need help on the following requirement as follows


1) i am trying to prepare an excel sheet with all the org limits details as follows

i have written an vf page and an apex code which will extract the object name with the limits corresponding to it

similary i am trying to figure how to get the other details

Item               Usage      Limit  % used
Custom Fields 19           800     2%  
Custom Relationship Fields 2 50 4%  
Active Workflow Rules 1 100 1%  
Total Workflow Rules 1 500 0%  
Approval Processes 0 500 0%  
Active Lookup Filters 0 10 0%  
Active Validation Rules 0 500 0%  
VLOOKUP Functions 0 10 0%  
Sharing Rules (Both Owner- and Criteria-based) 0 300 0%  
Sharing Rules (Criteria-based Only) 0 200 0%  



i want to get the details of others highlighted in bold

Kindly help me how to get thse info pls
 
MY APEX CODE :

public class ObjectListController {
    public String val {get;set;} 
    public List<SelectOption> getName() 
    { 
        
        List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();      
       
        List<SelectOption> options = new List<SelectOption>(); 
        for(Schema.SObjectType f : gd) 
        { 
            
            options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel())); 
            
        } 
        return options; 
        
    } 
    public List<String> getObName() 
    { 
        List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();      
        List<string> options = new List<string>(); 
        for(Schema.SObjectType f : gd) 
        { 
            
           	string ObjectName = f.getDescribe().getLabel();
            system.debug('ObjectName==>'+ObjectName);
             integer FieldCount = f.getDescribe().fields.getMap().size();
			system.debug('FieldCount==>'+FieldCount);
			
            options.add(f.getDescribe().getLabel() +' ; '+ f.getDescribe().fields.getMap().size()); 
            
          
        } 
        System.debug('wewetwet'+options);
        return options; 
        
    } 
 
}
MY VF CODE :

<apex:page controller="ObjectListController" readOnly="true" > 
    <apex:form >
        <apex:pageBlock >
        <apex:pageBlockTable value="{!obName}" var="o">
            <apex:column value="{!o}"/>
        </apex:pageBlockTable> 
        <apex:SelectList value="{!val}" size="1"> 
            <apex:selectOptions value="{!Name}"></apex:selectOptions> 
        </apex:SelectList> 
            </apex:pageBlock>
    </apex:form> 
</apex:page>


Kindly help me pls

Thanks in Advance

Hi,

I am trying to create a formula field for the below requirement for which i need help on it


I have to convert milli seconds value given to the normal time value using a formula field


I tried the below formula its working fine for minutes and seconds , but not sure how to add hours to it

MY FORMULA :
IF((MOD((Duration_Number__c )/60,1)*60) > 10,
TEXT(FLOOR( (Duration_Number__c )/60)) + ":" + TEXT( FLOOR(MOD((Duration_Number__c )/60,1)*60) ),
TEXT(FLOOR( (Duration_Number__c )/60)) + ":0" + TEXT( FLOOR(MOD((Duration_Number__c )/60,1)*60) )
)

I tried to add hrs but getting incorrect number of parameters in if expected 3 recieved 4

Help me how to add hrs in my formula

Thanks in Advance
  • September 18, 2015
  • Like
  • 1
Hi,

I am trying to create a formula field for the below requirement for which i need help on it


I have to convert milli seconds value given to the normal time value using a formula field

let me know the formula field logic to achieve it

Thanks in Advance
  • September 18, 2015
  • Like
  • 1
Hi,

I need help on the following requirement as follows,

I have a visualforce page where i have a button in it , when i click the button it is calling my REST API apex class where i am passing the opportunity id and it should display

but when i click on the button i am getting the following error as follows

[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]


Let me know what i should do to resove it , i need to display the opportunity record alone on clik of that button through rest api
 
MY VF PAGE :

<apex:page controller="getservice2">
<apex:form >
<apex:commandButton action="{!getResult}" value="REST API" id="theButton"/>
        <br/><br/>        {!myresponse}
</apex:form>
  </apex:page>
MY REST API CLASS :

@RestResource(urlMapping='/opportunity/*')
global with sharing class MyRestResource {

@HttpGet
    global static opportunity doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        //String opportunityId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        opportunity result = [SELECT Id, Name,Account.name,owner.name FROM opportunity WHERE Id = '00628000004KwQ0'];
        return result;
    }

@HttpPost
global static String doPost(String name,
    String phone, String website) {
    opportunity opportunity = new opportunity();
    opportunity.Name = name;
    insert opportunity;
    return opportunity.Id;
}
}
MY APEX CLASS WHERE MY REST API CONTTOLLER IS REFERRED :

public class getservice2
{
    public String myresponse{get;set;}
    public Pagereference getResult()
    {
        HttpRequest req = new HttpRequest();
        Http http = new Http();
        req.setMethod('GET');
        String url = 'https://ap2.salesforce.com/services/apexrest/opportunity';
        req.setEndpoint(url);
        HTTPResponse resp = http.send(req);
        myresponse=resp.getBody();          

        return null;    }
}




Help me pls

Thanks in Advance
Hi,

I have a fomula field on a custom object called as "Campaign topic "  which is not firing and throwing the following error


formula text is exceeded  Char limit


Let me know how to fix it or we just create another formula and concatenate in this Campaign topic formula?


Kindly help me pls

Thanks in Advance
MY FORMULA FIELD :


IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Cloud"), "Cloud; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Communications"), "Communications; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Connected Machines"), "Connected Machines; ", NULL)+
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Core Network"), "Core Network; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "CPE"), "CPE; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Data Center Services"), "Data Center Services; ", NULL)+
IF(INCLUDES(Campaign_Name__r.Campaign_Topic__c , "Machine-to-Machine Pro Serv"), "Machine-to-Machine Pro Serv; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Managed Solutions"), "Managed Solutions; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Med Bus Bundle"), "Med Bus Bundle; ", NULL)+
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Mobility Solutions"), "Mobility Solutions; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Net Conferencing Services"), "Net Conferencing Services; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Other"), "Other; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Parent - Multi"), "Parent - Multi; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Partner"), "Partner; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Professional Services"), "Professional Services; ", NULL)+
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Security Solutions"), "Security Solutions; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Strategic Network"), "Strategic Network; ", NULL) +
IF(INCLUDES( Campaign_Name__r.Campaign_Topic__c , "Thought Leadership"), "Thought Leadership; ", NULL)

 

Hi,

I am having a trigger on feed item which will fetch the account and opportunity id along  with the @mention

i  have a class which will store the @mention , and a trigger which will store the account and opp id

my issue is the trigger is throwing record is read  only on( after insert ) , whereas the before insert is fetching the ids but the @mention gets grad out

my logic needs after insert trigger only

when i click on post , i am getting

Apex trigger FeedItemTrigger caused an unexpected exception, contact your administrator: FeedItemTrigger: execution of AfterInsert

caused by: System.FinalException: Record is read-only: Trigger.FeedItemTrigger: line 31, column 1


Line 31 :

        fdItem.Body = chatterBody + '\n Account Id is :'+ parentopportunity.AccountId + ' \n Opportunity Id :'+parentopportunity.Id;


 

MY TRIGGER :

trigger FeedItemTrigger on FeedItem (after insert , after update) {

 if(PIPIntelHelper.skipChatterTriggers == true)
    return;
    
  List<FeedItem>feeditemupdatelist = new List<FeedItem>();
    
    set<id> parentAccountIds = new set<id>();

    for(FeedItem fdItem : trigger.new){
        String idStr = fdItem.Parentid;

        if(idStr.startsWith('006')){
           parentAccountIds.add(idStr);
        }
        
        
        
        
    }
    
    system.debug('parentAccountIds'+ parentAccountIds);
   Map<id,Opportunity> oppty  = new Map<id,Opportunity>([Select id, AccountId  from Opportunity where id in:parentAccountIds]);
   if(oppty.size()>0){
    for(FeedItem fdItem : trigger.new){
     system.debug('feeditemlist'+fdItem );
        Opportunity parentopportunity = oppty.get(fdItem.Parentid);

        String chatterBody = fdItem.Body;

        fdItem.Body = chatterBody + '\n Account Id is :'+ parentopportunity.AccountId + ' \n Opportunity Id :'+parentopportunity.Id;
          feeditemupdatelist.add(fdItem);
                
    }
    
    
    
    //if(feeditemupdatelist!=null){
    PIPIntelHelper.skipChatterTriggers = true;

   // update feeditemupdatelist;
         system.debug('feeditemlistupdate'+feeditemupdatelist);
   // }
    

    }
    
  
 

}
 

Kindly help me whats the issue here

Thanks



help me how to fix the issue

Hi,

I am having a apex class which i am trying to post the opp id and account id from opportunity along with the text on opportunity object alone , this fires on posting a content i n chatter


i have written the apex class , but for some reasong its not firing

help me if i am doing anything wrong here
 
public class EditFeedItemHelper {

  /**

  * Call this method from an after insert FeedItem trigger.

  * It updates the feed items passed in and preserves @mentions.

*/

  public static void edit(FeedItem[] feedItems) {

    String communityId = Network.getNetworkId();

    List<String> feedItemIds = new List<String>();

    for (FeedItem f : feedItems) {

        feedItemIds.add(f.id);

    }

        // Get all feed items passed into the trigger (Step #1).

    ConnectApi.BatchResult[] results = ConnectApi.ChatterFeeds.getFeedElementBatch(communityId, feedItemIds);

    for (ConnectApi.BatchResult result : results) {

        if (result.isSuccess()) {

            Object theResult = result.getResult();

            if (theResult instanceof ConnectApi.FeedItem) {

                ConnectApi.FeedItem item = (ConnectApi.FeedItem) theResult;

                // Convert message segments into input segments (Step #2a).

                ConnectApi.FeedItemInput input = ConnectApiHelper.createFeedItemInputFromBody(item.body);

                // Modify the input segments as you see fit (Step #2b).

                modifyInput(input);

                // Update the feed item (Step #2c).

                // We need to update one feed item at a time because there isn't a batch update method yet.

                ConnectApi.ChatterFeeds.updateFeedElement(communityId, item.id, input);

            }

            else {

                // Do nothing. Posting other feed element types isn't supported.

            }

        }

        else {

                System.debug('Failure in batch feed element retrieval: ' + result.getErrorMessage());

        }

    }

}

    /**

    * Update the feed item input here!

    */

    public static void modifyInput(ConnectApi.FeedItemInput input) {

          set<id> parentAccountIds = new set<id>();
          List<FeedItem> fd = new List<FeedItem>();
              for(FeedItem fdItem : fd){
          String idStr = fdItem.Parentid;
            if(idStr.startsWith('006')){
           parentAccountIds.add(idStr);
        }
                      }
        
           Map<id,Opportunity> oppty  = new Map<id,Opportunity>([Select id, AccountId  from Opportunity where id in:parentAccountIds]);
             if(oppty.size()>0){
             for(FeedItem fdItem : fd){
          Opportunity parentopportunity = oppty.get(fdItem.Parentid);
                  String chatterBody = fdItem.Body;
           fdItem.Body = chatterBody + '\n Account Id is :'+ parentopportunity.AccountId + ' \n Opportunity Id :'+parentopportunity.Id;


            
             
              



        // This example appends text to the feed item.

        ConnectApi.TextSegmentInput textInput = new ConnectApi.TextSegmentInput();

        textInput.text =  chatterBody ;


        input.body.messageSegments.add(textInput);

    }
      }
              
     }

}


Kindly help me

Thanks
 
Hi,

I have a method in my apex class where i am not able to cover , need help on it


public static void sendEmailAfterBatchJob(Database.BatchableContext BC, String jobName)
    {
        if (BC.getJobId() != null)
        {
        AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
                            TotalJobItems, CreatedBy.Email from AsyncApexJob
                        where Id =:BC.getJobId()];
        
        // Send an email to the Apex job's submitter notifying of job completion.         
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[]{};
        toAddresses.add(a.CreatedBy.Email);
        string newaddress = system.label.GSAM_Batch_Email_Notification;
        toAddresses.add(newaddress);
        mail.setToAddresses(toAddresses);
        mail.setSubject(jobName + ' ' + a.Status);
        mail.setPlainTextBody
        (jobName + ' Apex job processed ' + a.TotalJobItems +
        ' batches with '+ a.NumberOfErrors + ' failures.');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });      
        }
    }



I tried to call controller. methodname() , but not sure about the parameters to pass


Kindly help me pls

Thanks in Advance
Hi,

I have a following requirement for which i need help on it related to chatter post

1) I have enabled the chatter post for opportunity object
My requirment is

whenever i enter some chatter post in opportunity and post it it should capture account id and opportunity id automatically and those ids should be visible in the chatter post to whom i post to.


can it be done through configuration in salesforce ?

Let me know how to achieve this requirement

Thanks in Advance





 
Hi,

I have a trigger for which i am not able to cover certain methods in it , I have a test class for it


I need help to cover those methods

Kindly help me pls

 
Methods to cover in my trigger


   if(trigger.isBefore)
    {
        if (trigger.isDelete)
        { 
            
            map<Id,List<Team_Form_Member__c >>  TeammemberMap = new map<Id,List<Team_Form_Member__c>>(); 
            list <Id> RemoveLst = new list <Id>();
            list <Id> RemoveuserLst = new list <Id>();
            for(Integer i=0;i<trigger.old.size();i++)
            {
                RemoveLst.add(trigger.Old[i].Id);
                RemoveuserLst.add(trigger.Old[i].Team_Member__c);
                removeId = trigger.Old[i].Id;
                if(trigger.Old[i].GPS_Team_Form_Role__c <> null)
                     {
                     gpsteamrole.add(trigger.Old[i].UserName__c);
                     }
            }
            if(!RemoveLst.isEmpty())
            {
                list<Id> EpscriptId = new list <Id>();
                list<Id> EpTeamformId = new list <Id>();  
                Id EPscriptIds;             
                list<Team_Form_Member__c> EPTeammember = [select Team_Form__c,Id,name,Team_Member__c,Team_Form__r.Engagement_Script__c,Team_Form__r.Engagement_Team__r.Initial__c from Team_Form_Member__c where Id in :RemoveLst and Team_Role__c != :EP_Utilities.getEPLabel('TFM_Role_SharingAccess')]; 
                for(Team_Form_Member__c TeamMember: EPTeammember)
                {
                    EPscriptIds = TeamMember.Team_Form__r.Engagement_Script__c;
                    EpscriptId.add(TeamMember.Team_Form__r.Engagement_Script__c);
                    EpTeamformId.add(TeamMember.Team_Form__c);
                    EpTeamformIntitial.add(TeamMember.Team_Form__r.Engagement_Team__r.Initial__c);                    
                }
                List <Engagement_Script__c>  EPscript = [select Id,AccountManager__c,REQUESTOR__c from Engagement_Script__c where Id in : EpscriptId];
                List <Team_Form_Member__c>  EPTeammemberLst = [select GPS_Team_Form_Role__c,Team_Member__c,PRM_Portal_URL_ESID__c, PRM_Portal_URL_OPPTYID__c, UserName__c,id,Team_Role__c,OpportunityName__c,AccountName__c,EngagedTeam__c,Team_Form__r.Team_initials__c,Team_Form__c,EPScriptOpptyLink__c,NASP_Name__c,EPScriptLink__c,Team_Form__r.BidName__c,Team_Form__r.Engagement_Script__r.Name from Team_Form_Member__c where Team_Form__c in :EpTeamformId and Status__c =:'Active'];   
                list <Id> userlst =  new list <Id>();
                for(Team_Form_Member__c TFM: EPTeammemberLst)
                {
                    if(TFM.Team_Form__c <> null)
                    {
                        List <Team_Form_Member__c> lstTFM  = new List <Team_Form_Member__c>();
                        if(TeammemberMap.get(TFM.Team_Form__c)!=null)
                        lstTFM = TeammemberMap.get(TFM.Team_Form__c);
                        lstTFM.add(TFM);
                        TeammemberMap.put(TFM.Team_Form__c,lstTFM);                        
                    }
                    if(TFM.GPS_Team_Form_Role__c <> null)
                    RemoveuserLst.add(TFM.Team_Member__c);    
                } 
                if(!EPTeammember.isempty() && gpsteamrole.size()==0)
                {
                    userlst = EPEmailReceiptList.EPEmailSuperUserLst(EPscript);
                }
                else
                    userlst.addall(RemoveuserLst);
                system.debug('userlst-->'+userlst);
                if(!userlst.isEmpty()&& Label.EP_Email_ON_OFF =='ON')
                {
                    for(Id TFId : TeammemberMap.KeySet())
                    {
                        //EP_EmailComponent obj = new EP_EmailComponent();
                        //obj.SendEmailsWithoutTemplate(userlst,EPTeammemberLst,'Add');
                         system.debug('EpTeamformIntitial==>'+EpTeamformIntitial);
                       if(!EpTeamformIntitial.contains('EMEA SaSu')) 
                        EP_EmailComponent.SendEmailsWithoutTemplate(userlst,TFId,'Removed',EPscriptIds,removeId,gpsteamrole);
                    }
                }
            }
            
        }   
    }
MY TEST CLASS :

@Istest(seeAllData=true)
public class Team_Form_Member_AfterInsDel_Test 
{
    Public static testmethod void TestMethod1()
    {
	
	 string strUsr;
        User usr = GPSTestUtilities.createStandardUser(strUsr);
        System.runAs(usr)
        { 
            
            skipingHelper.SkippThemAll();
            Account acct = GPSTestUtilities.createTestAccount();
            Opportunity oppty1 = GPSTestUtilities.createTestOpportunity(acct.Id);
            Team_Group_Member__c TGM = GPSTestUtilities.createTeamGroupMember();
            Engagement_Script__c ES = GPSTestUtilities.createEngagementScript(acct.Id,oppty1.Id);
            test.startTest();  
            
            Team_Form__c TF = GPSTestUtilities.createTeamForm(ES.Id);  
            Team_Form_Member__c TfMember = GPSTestUtilities.createTeamFormMember(TF.Id);
            GPS_PremiSys_Quote__c gpsquote = new GPS_PremiSys_Quote__c();
            gpsquote.Engagement_Script_Id__c = ES.Id;
            gpsquote.GPSTeamForm__c = TF.id;
            gpsquote.Quote_ID__c = 'Testsss';
            insert gpsquote;
            
            system.debug('TF::'+TF);  
            TF.Status__c ='Released to Sales';
            TF.Status_Comments__c = 'rejtest';
            update TF;
                        
           
            system.debug('TF::'+TF);
            TF.Status__c = 'Quote uploaded';
            TF.Status_Comments__c = 'tesaaaat';
            update TF;
            
            test.stopTest();
              TF.Status__c = 'Won';
            TF.Status_Comments__c = 'tesaaaaqq1t';
            update TF;
            
           
            system.debug('TF::'+TF);
            TF.Status__c = 'Closed Lost';
            TF.Status_Comments__c = 'te121ast';
            update TF;   
            
            
        }
	
	
	
	
	
	}
	}
Kindly help me pls

Thanks in Advance

 
Hi,

I have a apex class which is having a test class on running which is throwing too many soql queries 101

need help on it pls
 
MY APEX CLASS :

Public class dqtCustomSimple

{
public String dlmstage { get;set;}    

  public dqtCustomSimple()
  
   {
 
   dlmstage = ApexPages.currentPage().getParameters().get('dlmstageid');
      
   }
   Public pagereference redirecttostage()
  
 {
 PageReference newpage= new PageReference('/'+ dlmstage);
      newpage.setRedirect(true);
return newpage;
}

  }
MY TEST CLASS :

@isTest(seeallData = true)
private class dqtCustomSimple_Test
{
    
  static Stage__c stg;
  static Opportunity opp;
   static User U;
   static Engagement_Script__c EP;
    

   
     static testMethod void dqtCustomSimple_Test()
    {
         Test.StartTest();
        CreateData();             
        CreateDQTStage();
       
      
        system.currentpagereference().getparameters().put('id',stg.Id);  
        dqtCustomSimple objdqtCustom = new dqtCustomSimple();
        objdqtCustom.redirecttostage();
       Test.StopTest();
     }
     
     public static void  CreateData()
     {
	 Test.StartTest();
     U = Utils_TestMethods.createStandardUser('alias');  
     insert U;
     System.runAs(U){
     List <PriceBook2> pb2list = new List<PriceBook2>();
     List <Product2> prodlist = new List<Product2>();
     List <PriceBookEntry> pbelist = new List<PriceBookEntry>();
     List <PriceBookEntry> stdPbelist = new List<PriceBookEntry>();
     integer quantity;
      Account acc = Utils_TestMethods.createAccount();
      insert acc;
       acc.ActualUnmanaged__c = true; 
       Database.update(acc);
       system.debug('acc==>'+acc);
     pricebook2 pb2 = [select Id from Pricebook2 where name='Wireline Price Book' and IsActive=true limit 1];
     SFDCtoECSfromTrigger.isttesting = true;  
     opp = Utils_TestMethods.createOpportunity(acc,u);
     insert opp; 
       opp.DLM_Region__c   = 'APAC';
       Database.update(opp); 
       system.debug('opp==>'+opp);
       
      product2 p2= new product2(name='p2test',product_id__c='p2test',isActive=true);
      insert p2;    
      
      pricebookentry pbe = [select Pricebook2Id from pricebookentry where pricebook2id=:pb2.id and product2id =: p2.id limit 1];
    
      Exchange_Rate__c exr=new Exchange_Rate__c(Name='USD',Conversion_Rate__c=10); 
      insert exr;
      Test.StopTest();
      OpportunityLineItem olm=new OpportunityLineItem(Pricebookentryid=pbe.id,Local_Currency__c=exr.id,Local_Booking__c=123455,Opportunityid=opp.id );
      insert olm;
       system.debug('olm==>'+olm);
       
      
      }
    }
    public static void CreateDQTStage()
    {
		 Test.StartTest();

	
        EP = new Engagement_Script__c();
      EP.Engagement_Status__c = 'Open';
      EP.Opportunity__c = opp.Id ;        
      insert EP; 
      system.debug('EP==>'+EP);  
        
     stg = Utils_TestMethods.createStage(opp);
    string strStageName;
    Id rectypeid =[select Id from RecordType where Name=:'Stage 1 RRB'  and SobjectType='Stage__c' limit 1].Id;
    stg.RecordTypeId =rectypeid;
    stg.PCM__c= U.ID;
    stg.Sales__c= U.ID;
    stg.SDA__c = U.ID;                   
    stg.Engagement_Script__c = EP.Id;
    stg.DQT_Approval_Status__c='Approved';    
    insert stg;
       system.debug('stg==>'+stg); 
       
     Stage_Team__c stgTeam = Utils_TestMethods.createStageTeam(stg,U);
     Insert stgTeam; 
	 Test.StopTest();
     stgTeam.User_Role__c = 'Business Operations';
     Database.update(stgTeam);  

        
    }
    
  
    
    
    
}
 It is giving error in thi line

dqtCustomSimple_Test

Kindly help me pls

Thanks in advnace