• balu palavalasa
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Hi All,

Before executing Batch apex how am i getting the Jobid of batch apex in finish method as shown below.

Please explain as i am a new to salesforce.

global void finish(Database.BatchableContext BC){

// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.

AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id = :BC.getJobId()]; ( how do i get job id in finish method before executing batch apex )
// Send an email to the Apex job's submitter notifying of job completion.

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {a.CreatedBy.Email}; mail.setToAddresses(toAddresses); mail.setSubject('Apex Sharing Recalculation ' + a.Status); mail.setPlainTextBody ('The batch Apex job processed ' + a.TotalJobItems + ' batches with '+ a.NumberOfErrors + ' failures.'); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); }

 
hi All,

I've witten a code which has to take input from an input box and add the input to select options until submit button is pressed.
that is as long as i give input and click on add button it should keep on adding the given input texts to select option list. and if i click on submit button it should display the selectoptions list.

vf code :

<apex:page Controller="selectlistoption">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
         
            <apex:outputlabel value="Enter Country"/>
            <apex:inputText value="{!str}"/>
            <apex:commandButton value="Add" action="{!setCountry}"/> 
            <apex:commandButton value="submit" rerender="showdetails"/>
        </apex:pageBlockSection>    
        
    <apex:pageBlockSection id="showdetails">
      
            <apex:selectlist size="1" value="{!str}">
           
                <apex:selectoptions value="{!country}"/>
                 </apex:selectlist>
        
 
        
        </apex:pageBlockSection>
                    </apex:pageBlock>
    </apex:form>
 
</apex:page>

Controller :

public class selectlistoption {
    
  
      public   string str{get;set;}
    
       public  list<selectoption> country{get;set;}
    
    public pagereference setCountry()
    {
         
        country.add(new selectoption(str,str));
        return null;
       
    }
    
   

}

Error :

System.NullPointerException: Argument 1 cannot be null
Error is in expression '{!setCountry}' in component <apex:commandButton> in page selectlist: Class.selectlistoption.setCountry: line 11, column 1
Class.selectlistoption.setCountry: line 11, column 1
hi all, 

I have witten a vf code in which it shows "Error in ine 0 " i could not understand whats the error is. Please halp me in sorting out the issue.
Below is my code: 
------------------------
<apex:page standardController="Account" recordSetVar="accs">
<style>
.activetab {background-color : #9ACD32 ; color:white;}
.inactivetab {backgound-color :  #DCDCDC ; color:white;}
</style>

<apex:tabpanel switchtype="Client" selectedtab="Accounts" id="tabpanel1"
tabclass="activetab" inactivetabclass="inactivetab">
<apex:tab label="Account Details" name="Accounts" id="1"> 

 <apex:pageblock title="All Accounts"> 
 <apex:pageblocktable value="{!accs}" var="a">
 <apex:column title="Action" >
 <apex:outputLink value="{!URLFOR($Action.Account.Edit,a.id)}">Edit
 </apex:outputLink>&nbsp;|&nbsp;
 <apex:outputlink value="{!URLFOR($Action.Account.Delete,a.id)}">Del</apex:outputlink>
 </apex:column>
 <apex:column value="{!a.Name}"/>
 <apex:column value="{!a.Phone}"/> 
 </apex:pageblocktable>
 
 </apex:pageblock>
 
 </apex:tab>
 </apex:tabpanel>
 
</apex:page>

Error is :

Error in line 0

 
hi i am a beginner in salesforce.i have a requirement . there are 2 sections in a vf page .in first section there is only one input textbox which takes values for a country field . and a button called "add" once this button is clicked in the backend it has to add the value in country textbox to a selectlist. so how many times we click on add button those many values must be added to select list.there is another button submit. once submit button is clicked the country list must be displayed in 2nd pageblock section . how can i achieve this

vf page code is :
<apex:page Controller="selectlistoption">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
        
            <apex:outputlabel value="Enter Country"/>
            <apex:inputText value="{!str}"/>
            <apex:commandButton value="Add" action="{!setCountry}"/> 
            <apex:commandButton value="submit" rerender="showdetails"/>
        </apex:pageBlockSection>    
        
    <apex:pageBlockSection id="showdetails">
        
            <apex:selectlist size="1" value="{!str}">
           
                <apex:selectoptions value="{!country}"/>
                 </apex:selectlist>
        
 
        
        </apex:pageBlockSection>
                    </apex:pageBlock>
    </apex:form>
 
</apex:page>

------------------------------------------------------------------------apex code -------------------------------------------------------------
public class selectlistoption {
    
    
      public   string str{get;set;}
    

   public  list<selectoption> country{get;set;}
    
    public void setCountry()
    {
         
        country.add(new selectoption(str,str));
       
    }
    
   

}
 
hi all, 

I have witten a vf code in which it shows "Error in ine 0 " i could not understand whats the error is. Please halp me in sorting out the issue.
Below is my code: 
------------------------
<apex:page standardController="Account" recordSetVar="accs">
<style>
.activetab {background-color : #9ACD32 ; color:white;}
.inactivetab {backgound-color :  #DCDCDC ; color:white;}
</style>

<apex:tabpanel switchtype="Client" selectedtab="Accounts" id="tabpanel1"
tabclass="activetab" inactivetabclass="inactivetab">
<apex:tab label="Account Details" name="Accounts" id="1"> 

 <apex:pageblock title="All Accounts"> 
 <apex:pageblocktable value="{!accs}" var="a">
 <apex:column title="Action" >
 <apex:outputLink value="{!URLFOR($Action.Account.Edit,a.id)}">Edit
 </apex:outputLink>&nbsp;|&nbsp;
 <apex:outputlink value="{!URLFOR($Action.Account.Delete,a.id)}">Del</apex:outputlink>
 </apex:column>
 <apex:column value="{!a.Name}"/>
 <apex:column value="{!a.Phone}"/> 
 </apex:pageblocktable>
 
 </apex:pageblock>
 
 </apex:tab>
 </apex:tabpanel>
 
</apex:page>

Error is :

Error in line 0