• Singhforce
  • NEWBIE
  • 30 Points
  • Member since 2016


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
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 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 to write a trigger by which whenever a Contact is created, an email must be sent to the mail-id we specify. In that mail there should be :
Contact Details : 1.First Name. 2.LastName, 3.Account , 4.Content Like : "Hi , an Acc. is created bla bla bla......" 
Hi,
I have a requirement where i need to get the total count of Logins done by the particular profile.

Profile                                      Month                       Times Logged in
System Administrator                August 2016              150
Standard User                          August 2016               123


I tried to give this query,
List<Aggregateresult> logquery = [Select count(LoginTime) logintime, userid from LoginHistory where userid =: scope Group by userid];

But this wil execute the total count by Users. But i need it for Profiles. Is there any other workaround to do this?

Thanks
Vivekh
 
Good afternoon,
I am hoping you can help me.
I am building a POC and i have hit a brick wall and really appreciate some help form the community.

Problems :
My visual force page doesnt show a tick box. When i push save, i dont see the record being mapped back anywhere. when on Materials_Junction object and look at Buttons, Links, and Actions i edit the "new" button to add the visual force page, however no vf pages are presented.

Ideal Solution :
Go to the sales & marketing object, scroll to the "Materials_Junction" related list and click on "New". Upon clicking on "New" it should open up the "visual force" page below (which references the "materials" object). The user should select the "material" via a tick box add a quantity,upon clicking the save button on the visual force page, the values the user has selected should get mapped back to the "sales & marketing object"
Apex Controller

Apex controller 
public with sharing class testWrapper
{
    public List<Materials__c> Materials {get;set;} 
    public List<materialWrapper> materialWrapperList {get;set;} 
    
    public testWrapper()
    {   
        materialWrapperList = new List<materialWrapper>();
        Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10];
        for(Materials__c obj : Materials)
        {
            materialWrapper tempObj= new materialWrapper();
            tempObj.recordId = obj.id;
            tempObj.name = obj.name;
            tempObj.product = obj.Product__c;
            tempObj.item = obj.Item__c;
            tempObj.quantity = obj.Quanity__c;
            tempObj.selectB = false;
            materialWrapperList.add(tempObj);
        }
    }

    //save method
    public void save()
    {
        list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>();
        
        for(materialWrapper obj : materialWrapperList)
        {
         Materials_Junction__c temp ;
            if(obj.selectB == true)
            {
                temp = new Materials_Junction__c();
                temp.sales_and_marketing__c = 'a032000000VQaRT';
                temp.Materials__C= obj.recordId;
                temp.quantity__C = obj.quantity; 
                recordToInsert.add(temp);
            }
            //recordToInsert.add(temp); you are adding element outside the if condition that the reason for save button error
        }
        insert recordToInsert;        
    }
    
    
    public class materialWrapper
    {
        public string recordId {get; set;}
        public string name {get; set;}
        public string product {get; set;}
        public string item {get; set;}
        public Decimal quantity {get; set;}
        public boolean selectB {get; set;}
        
        public void materialWrapper()
        {
            recordId = '';
            name = '';
            product = '';
            item = '';
            quantity = 0.0;
            selectB = false;
        }
    }
}

visual force page 
<apex:page controller="testWrapper">
    <apex:form >
        <apex:pageBlock title="Select Product">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>

            <apex:pageBlockTable value="{!materialWrapperList}" var="MKT"> <!-- for loop of contact in Materials -->
                <apex:column value="{!MKT.selectB}"/>
                <apex:column value="{!MKT.name}"/>       
                <apex:column value="{!MKT.Product}"/>
                <apex:column value="{!MKT.Item}"/>
                <apex:column headerValue="Quantity">
                    <apex:inputText value="{!MKT.quantity}"/>
                </apex:column>

            </apex:pageBlockTable>

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

Really appreciate all the help i can get 
Hi,
I am Creating a visualforce page in which I have apex selectlist which contains the type of objects which should be selected by lookup field and show results accordingly.Below is the screenshot
User-added image
I want lookup field to show values according to the value selected in selectlist.If I select Account then lookup field should show the Accounts in lookup field and vice versa.
Plz help in coding this in apex controller