• soumyodeep Guha 6
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 12
    Replies
HI All,

i have written the below trigger to populate a number field No_of_updates__c with the number of time a record is updated, but i am getting a Null pointer exception when a try a update a record. can anybody help me with this issue.

trigger
================================

trigger updatecount on Account (after update) {
if(trigger.isupdate)
{
updatecountAcct.countnumber(trigger.new);
}
}
=================================================

Helper class
=================================================
public class updatecountAcct {
public static void countnumber(list<account> a)
{
list<account> c= new list<account>();
    for(account b : a)
    {
    b.No_of_updates__c=b.No_of_updates__c+1;
    c.add(b);
    }
    update c;
    }
}
=====================================================
 
Hi All,

i have written the below VF page and the controller class code to fecth the records based on two fields that is Date and Language input bythe user in the VF page, but my custom controller class does not seem to work properly and is throwing a null point exception, Can anybody help correct this. The Null pointer issue is being thirown at line  Mlist.add(Ml);

VF page
============================================================
<apex:page sidebar="false" showHeader="false" standardController="Ticket_transaction__c" extensions="MovieController">
<apex:form >
{!Ticket_transaction__c.Movie_Date__c}
 
  <apex:sectionHeader title="Movie Select Page"/>
  <apex:pageblock title="Movie Preference">
  <apex:pageblockSection title="Movie Language Preference" collapsible="false">
  <apex:inputField value="{!tc.Language_preference__c}"/>
  </apex:pageblockSection>
  <apex:pageblockSection title="Movie Date" collapsible="false">
  <apex:inputfield Value="{!tc.Movie_Date__c}" id="MovieDate" />
  <br/><br/>
  <apex:commandButton value="Display Movies.." action="{!MovieList}" />
  <br/><br/>
        <apex:pageBlockTable value="{!Mlist}" var="M" id="Table">
            <apex:column value="{!M.Movie__c}"/>
            <apex:column value="{!M.Theater__c}"/>
            <apex:column value="{!M.Show_TIme__c}"/>
            <apex:column value="{!M.Movie_Language__c}"/>
        </apex:pageBlockTable>
  </apex:pageblockSection>
  </apex:pageblock>
 </apex:form>
</apex:page>
====================================================================

Custom controller
====================================================================
public class MovieController {
 public MovieController(ApexPages.StandardController controller) {
        tc = new Ticket_transaction__c();
    }

public string Language{get;set;}
public Date MovieDate{get;set;}
public Ticket_transaction__c tc{get;set;}
public list<Movie_at_Theater__c> Mlist{get;set;}
public Movie_at_Theater__c Query{get;set;}
public void MovieList()
{
    
  //  Query = new Movie_at_Theater__c();
       System.debug('Language'+tc.Language_preference__c);
   if(tc.Language_preference__c==null){

       System.debug('Date movie'+tc.Movie_Date__c);
       try{
           Mlist = [Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c, Movie_Date__c from Movie_at_Theater__c where Movie_Date__c=:tc.Movie_Date__c];
       }catch(System.QueryException qe){
           System.debug('Exception'+qe);
       }
             System.debug('MOvies List'+Mlist);
   } 
else
{
    
    list<Movie_at_Theater__c>Templist = [Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c, Movie_Date__c from Movie_at_Theater__c where Movie_Date__c=:tc.Movie_Date__c]; 
 for( Movie_at_Theater__c Ml : Templist)
 {

     If(tc.Language_preference__c==Ml.Movie_Language__c)
    
 {
   Mlist.add(Ml);  
 }
         System.debug('MOvies List'+Mlist);
 }  
}
}
}
Hi
i need help in a issue where i am not able to fetch records based on a date parameter passed to a soql query in a controller class for a VF page.
The issue is with the line 10 in the VF page code where it takes date as an input, and passes it to the controller class and used in the soql in line 14, which return no records even though its there. If i hardcode any date in the soql query as in line 15 then records are returned. 
can anybody help me to correct this as i am not getting any error in the code written but it does not seems to work.

VF page
=================================================================
<apex:page sidebar="false" showHeader="false" standardController="Ticket_transaction__c" extensions="MovieController">
<apex:form >
 
  <apex:sectionHeader title="Ticket Booking Page"/>
  <apex:pageblock title="Movie Preference">
  <apex:pageblockSection title="Movie Language Preference" collapsible="false">
  <apex:inputField value="{!Ticket_transaction__c.Language_preference__c}"/>
  </apex:pageblockSection>
  <apex:pageblockSection title="Movie Date" collapsible="false">
  <apex:inputfield value="{!Ticket_transaction__c.Movie_Date__c}" id="MovieDate"/>
  <br/><br/>
  <apex:commandButton value="Display Movies.." action="{!MovieList}"/>
  <br/><br/>
        <apex:pageBlockTable value="{!Mlist}" var="M">
            <apex:column value="{!M.Movie__c}"/>
            <apex:column value="{!M.Theater__c}"/>
            <apex:column value="{!M.Show_TIme__c}"/>
            <apex:column value="{!M.Movie_Language__c}"/>
        </apex:pageBlockTable>
  </apex:pageblockSection>
  </apex:pageblock>
 </apex:form>
</apex:page>
===========================================================================

Controller 
============================================================================
public class MovieController {
 public MovieController(ApexPages.StandardController controller) {

    }
public list<Movie_at_Theater__c> Mlist{get;set;}
public string Language{get;set;}
public Date MovieDate{get;set;}
//public string query{get;set;}
public Ticket_transaction__c tc {get;set;}
public void MovieList()
{
if(Language==null)
{
Mlist=database.query('Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c from Movie_at_Theater__c where Movie_Date__c=:MovieDate'); 
//Mlist=database.query('Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c,Movie_Date__c from Movie_at_Theater__c where Movie_Date__c=2016-08-28' ); 
//query='Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c,Movie_Date__c from Movie_at_Theater__c';

}
else
{
list<Movie_at_Theater__c>Templist=database.query('Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c from Movie_at_Theater__c where Movie_Date__c='+MovieDate); 
 for( Movie_at_Theater__c Ml : Templist)
 {
 If(Language==Ml.Movie_Language__c)
 {
   Mlist.add(Ml);  
 }
 Else{}
 }
   
}
}
}
HI All,

i have written the below trigger to populate a number field No_of_updates__c with the number of time a record is updated, but i am getting a Null pointer exception when a try a update a record. can anybody help me with this issue.

trigger
================================

trigger updatecount on Account (after update) {
if(trigger.isupdate)
{
updatecountAcct.countnumber(trigger.new);
}
}
=================================================

Helper class
=================================================
public class updatecountAcct {
public static void countnumber(list<account> a)
{
list<account> c= new list<account>();
    for(account b : a)
    {
    b.No_of_updates__c=b.No_of_updates__c+1;
    c.add(b);
    }
    update c;
    }
}
=====================================================
 
Hi All,

i have written the below VF page and the controller class code to fecth the records based on two fields that is Date and Language input bythe user in the VF page, but my custom controller class does not seem to work properly and is throwing a null point exception, Can anybody help correct this. The Null pointer issue is being thirown at line  Mlist.add(Ml);

VF page
============================================================
<apex:page sidebar="false" showHeader="false" standardController="Ticket_transaction__c" extensions="MovieController">
<apex:form >
{!Ticket_transaction__c.Movie_Date__c}
 
  <apex:sectionHeader title="Movie Select Page"/>
  <apex:pageblock title="Movie Preference">
  <apex:pageblockSection title="Movie Language Preference" collapsible="false">
  <apex:inputField value="{!tc.Language_preference__c}"/>
  </apex:pageblockSection>
  <apex:pageblockSection title="Movie Date" collapsible="false">
  <apex:inputfield Value="{!tc.Movie_Date__c}" id="MovieDate" />
  <br/><br/>
  <apex:commandButton value="Display Movies.." action="{!MovieList}" />
  <br/><br/>
        <apex:pageBlockTable value="{!Mlist}" var="M" id="Table">
            <apex:column value="{!M.Movie__c}"/>
            <apex:column value="{!M.Theater__c}"/>
            <apex:column value="{!M.Show_TIme__c}"/>
            <apex:column value="{!M.Movie_Language__c}"/>
        </apex:pageBlockTable>
  </apex:pageblockSection>
  </apex:pageblock>
 </apex:form>
</apex:page>
====================================================================

Custom controller
====================================================================
public class MovieController {
 public MovieController(ApexPages.StandardController controller) {
        tc = new Ticket_transaction__c();
    }

public string Language{get;set;}
public Date MovieDate{get;set;}
public Ticket_transaction__c tc{get;set;}
public list<Movie_at_Theater__c> Mlist{get;set;}
public Movie_at_Theater__c Query{get;set;}
public void MovieList()
{
    
  //  Query = new Movie_at_Theater__c();
       System.debug('Language'+tc.Language_preference__c);
   if(tc.Language_preference__c==null){

       System.debug('Date movie'+tc.Movie_Date__c);
       try{
           Mlist = [Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c, Movie_Date__c from Movie_at_Theater__c where Movie_Date__c=:tc.Movie_Date__c];
       }catch(System.QueryException qe){
           System.debug('Exception'+qe);
       }
             System.debug('MOvies List'+Mlist);
   } 
else
{
    
    list<Movie_at_Theater__c>Templist = [Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c, Movie_Date__c from Movie_at_Theater__c where Movie_Date__c=:tc.Movie_Date__c]; 
 for( Movie_at_Theater__c Ml : Templist)
 {

     If(tc.Language_preference__c==Ml.Movie_Language__c)
    
 {
   Mlist.add(Ml);  
 }
         System.debug('MOvies List'+Mlist);
 }  
}
}
}
Hi
i need help in a issue where i am not able to fetch records based on a date parameter passed to a soql query in a controller class for a VF page.
The issue is with the line 10 in the VF page code where it takes date as an input, and passes it to the controller class and used in the soql in line 14, which return no records even though its there. If i hardcode any date in the soql query as in line 15 then records are returned. 
can anybody help me to correct this as i am not getting any error in the code written but it does not seems to work.

VF page
=================================================================
<apex:page sidebar="false" showHeader="false" standardController="Ticket_transaction__c" extensions="MovieController">
<apex:form >
 
  <apex:sectionHeader title="Ticket Booking Page"/>
  <apex:pageblock title="Movie Preference">
  <apex:pageblockSection title="Movie Language Preference" collapsible="false">
  <apex:inputField value="{!Ticket_transaction__c.Language_preference__c}"/>
  </apex:pageblockSection>
  <apex:pageblockSection title="Movie Date" collapsible="false">
  <apex:inputfield value="{!Ticket_transaction__c.Movie_Date__c}" id="MovieDate"/>
  <br/><br/>
  <apex:commandButton value="Display Movies.." action="{!MovieList}"/>
  <br/><br/>
        <apex:pageBlockTable value="{!Mlist}" var="M">
            <apex:column value="{!M.Movie__c}"/>
            <apex:column value="{!M.Theater__c}"/>
            <apex:column value="{!M.Show_TIme__c}"/>
            <apex:column value="{!M.Movie_Language__c}"/>
        </apex:pageBlockTable>
  </apex:pageblockSection>
  </apex:pageblock>
 </apex:form>
</apex:page>
===========================================================================

Controller 
============================================================================
public class MovieController {
 public MovieController(ApexPages.StandardController controller) {

    }
public list<Movie_at_Theater__c> Mlist{get;set;}
public string Language{get;set;}
public Date MovieDate{get;set;}
//public string query{get;set;}
public Ticket_transaction__c tc {get;set;}
public void MovieList()
{
if(Language==null)
{
Mlist=database.query('Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c from Movie_at_Theater__c where Movie_Date__c=:MovieDate'); 
//Mlist=database.query('Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c,Movie_Date__c from Movie_at_Theater__c where Movie_Date__c=2016-08-28' ); 
//query='Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c,Movie_Date__c from Movie_at_Theater__c';

}
else
{
list<Movie_at_Theater__c>Templist=database.query('Select Movie__c, Theater__c, Show_TIme__c, Movie_Language__c from Movie_at_Theater__c where Movie_Date__c='+MovieDate); 
 for( Movie_at_Theater__c Ml : Templist)
 {
 If(Language==Ml.Movie_Language__c)
 {
   Mlist.add(Ml);  
 }
 Else{}
 }
   
}
}
}