• arabisays
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
I am trying to get test coverage for the following batch job
global class ApprovalMailBatchJob implements Database.Batchable<sObject>
{
  public String QuerySalesTeam;
  public Map<Id,String> User_EmailMap =new Map<Id,String>();
  public Map<Id,String> User_NameMap =new Map<Id,String>();
    global Database.QueryLocator start(Database.Batchablecontext BC)
    {
     QuerySalesTeam='select Id,Approver__c,Approver__r.Email,Approver__r.FirstName from Contact_Team__c where Status__c=\'Pending\' ORDER BY Approver__c';
     System.debug(QuerySalesTeam);
     return Database.getQueryLocator(QuerySalesTeam);
      
    }
   
    global void execute(Database.BatchableContext BC,List<SObject> scope)
    {
     List<Contact_Team__c> conList=new List<Contact_Team__c>();
     conList=(List<Contact_Team__c>)scope;
     System.debug(conList);
     for(Contact_Team__c conTeam:conList)
     {
        if(!User_EmailMap.containskey(conTeam.Approver__c))
        {
            User_EmailMap.put(conTeam.Approver__c,conTeam.Approver__r.Email);
            User_NameMap.put(conTeam.Approver__c,conTeam.Approver__r.FirstName);
        }
                 
     }
      System.debug(User_EmailMap);
    System.debug(User_NameMap);

    }
   
    global void finish(Database.BatchableContext BC)
    {
    System.debug('UserMap'+User_EmailMap);
    System.debug('User Name Map'+User_NameMap);

        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
        String[] toAddresses ;
        for(Id usr:User_EmailMap.keyset())
        {
         
          Messaging.SingleEmailMessage mail=new Messaging.SingleEmailMessage();
        
        
     
         // Assign the addresses for the To and CC lists to the mail object.
          mail.setTargetObjectId(usr);
         // Specify the name used as the display name.
          mail.setSenderDisplayName(UserInfo.getName());
         // Specify the subject line for your email address.
          mail.setSubject('Needed Pending Approval Request in Salesforce.com' );
         
          String str_HtmlBody='';
          str_HtmlBody=str_HtmlBody + '<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><HTML><HEAD></HEAD><BODY>';
          str_HtmlBody=str_HtmlBody + '       <H5>Dear ' + User_NameMap.get(usr)+ '</H5><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Your approval is required for the requested staff code change(s). ';
          str_HtmlBody=str_HtmlBody + '       <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please visit the link to view details. ';

          str_HtmlBody=str_HtmlBody + '           <A HREF=\"https://cs10.salesforce.com/home/home.jsp\">Click here </A>';
          str_HtmlBody=str_HtmlBody + '       <P>Regards,<P>' + UserInfo.getName() + '</BODY></HTML>';                                               
         
          mail.setHtmlBody(str_HtmlBody);
        
         // Send the email you have created.
          mails.add(mail);
         }
         if(mails.size()>0)
         {
           Messaging.sendEmail(mails);
         }
        }

}

While running the test , the Maps (highlighted in bold) not getting passed from execute to finish method. 
Here is the log.

[32]|DEBUG|{null=null, 005J0000001LT3eIAG=test.user@hexgn.com
[33]|DEBUG|{null=null, 005J0000001LT3eIAG=Test User
[38]|DEBUG|UserMap{}
[39]|DEBUG|User Name Map{}

why it is happening?
Hi,

I am trying to hide some of the Side Bar Search options(Usually it has all the Objects)  using JavaScript.

I have created a custome home page component and pasted the below code by clicking Edit HTML.

    $("#sen option[value='087']").remove();
    $("#sen option[value='a04']").remove();
    $("#sen option[value='a07']").remove();
    $("#sen option[value='a0B']").remove();
    $("#sen option[value='a0H']").remove();
    $("#sen option[value='a0I']").remove();
    $("#sen option[value='a0K']").remove();
    $("#sen option[value='a0L']").remove();

But I am not able to hide the components.
PS: I have pasted the HTML of the side bar search to JSFiddle and used the same script. It is working fine in JSFiddle.
I am migrating reports from one Org to another. When migrating some reports I am having trouble. This reports contains the following markup.

<params>
        <name>scopeid</name>
        <value>701800000011GlK</value>
    </params>
  <params>
        <name>co</name>
        <value>1</value>
  </params>

Please clarify what this exactly means.
I am trying to deploy Custom Report Types from one org to another. While validating in force.com IDE , I am getting the following error:

# Deploy Results:
   File Name:    reportTypes/Custom_Contacts.reportType
   Full Name:  Custom_Contacts
   Action:  NO ACTION
   Result:  FAILED
   Problem: No such relationship Activities on object Contact

Why this erro.
Hi,

I am trying to deploy report types from one org to another using force.com ide. The target org does not have all the fields that present in the source org. While validating deployment validation error shows one field is missing , if I delete that field from the xml and try to validate again it shows another field is missing and so on.
Is there anyway to show all the validation errors so that I can get complete list of fields that missing in a single validation.
I am trying to pass the  value captured from text box as query string to another visualforce page on button click.
Here is my code:

 VF Page:

<apex:page id="pg" controller="OnLoadController">
<apex:form >
<script type="text/javascript">
      function doSearch() {
        contactSearch(document.getElementById("searchBox").value);
        alert(document.getElementById("searchBox").value);

      }
</script>
<apex:actionFunction action="{!redirect}" name="contactSearch">
    <apex:param name="searchBox" value=""/>
</apex:actionFunction>
<apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton value="btn1" onclick="doSearch(); return false;"/>
        </apex:pageBlockButtons>
        <input type="text" id="searchBox" />
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller:
public class OnLoadController {

    public String searchName {get; set;}

    public PageReference redirect()
    {
        searchName = Apexpages.currentPage().getParameters().get('searchBox');
        PageReference searchResult= new PageReference('/apex/VF_SearchDetails?searchCriteria='+ searchName);
        searchResult.setRedirect(true);
        return searchResult;      
       
    }

}

But it is redirecting to the page with null query string value.
Please help.
Hi. I am new to sales force. I have to perform a simple task.
When clicking an apex command button , it should alert a message through JavaScript.
Please see my code.

<apex:page standardController="Book__c">
<script>
    alertSample(){
        alert("Hello");
    }
</script>
    <apex:form >
        <apex:commandButton oclick="alertSample()" value="Hello"/>
        <apex:PageBlock title="Book View">
            <apex:outputField value="{! Book__c.Name}"/>
            <apex:detail />
        </apex:PageBlock>
    </apex:form>
</apex:page>

But I am not getting expected response. Please help.
I am migrating reports from one Org to another. When migrating some reports I am having trouble. This reports contains the following markup.

<params>
        <name>scopeid</name>
        <value>701800000011GlK</value>
    </params>
  <params>
        <name>co</name>
        <value>1</value>
  </params>

Please clarify what this exactly means.
Hi,

I am trying to hide some of the Side Bar Search options(Usually it has all the Objects)  using JavaScript.

I have created a custome home page component and pasted the below code by clicking Edit HTML.

    $("#sen option[value='087']").remove();
    $("#sen option[value='a04']").remove();
    $("#sen option[value='a07']").remove();
    $("#sen option[value='a0B']").remove();
    $("#sen option[value='a0H']").remove();
    $("#sen option[value='a0I']").remove();
    $("#sen option[value='a0K']").remove();
    $("#sen option[value='a0L']").remove();

But I am not able to hide the components.
PS: I have pasted the HTML of the side bar search to JSFiddle and used the same script. It is working fine in JSFiddle.
I am migrating reports from one Org to another. When migrating some reports I am having trouble. This reports contains the following markup.

<params>
        <name>scopeid</name>
        <value>701800000011GlK</value>
    </params>
  <params>
        <name>co</name>
        <value>1</value>
  </params>

Please clarify what this exactly means.