• Derek Dolan
  • NEWBIE
  • 30 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
I have been building a VF page that updates child and parent records 

The error that I get back after inputting is
​​​​​​
Visualforce Error
Help for this Page

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!insertChild}' in component <apex:commandButton> in page updatechild: Class.AddingChildController.insertChild: line 23, column 1


User-added image
​​​​​​This is the VF page
 
<apex:page controller="AddingChildController" >
<apex:form >
    <apex:variable var="rowNum" value="{!0}" />
    <apex:pageBlock >
        <apex:variable var="rowNum" value="{!0}" />
        <apex:PageBlockTable value="{!childList}" var="int">
        <apex:facet name="footer">
            <apex:commandLink value="Add" action="{!insertRow}"/>
            </apex:facet>
            <apex:column headerValue="Lead Generator">
                <apex:inputField value="{!int.Lead_Gen__c}"/>                                      
            </apex:column>
            
            
            
            <apex:column headerValue="Monday">
            <apex:inputField value="{!int.Monday__c}"/>
            </apex:column>
            <apex:column headerValue="Tuesday">
            <apex:inputField value="{!int.Tuesday__c}"/>
            </apex:column>
            <apex:column headerValue="Wednesday">
            <apex:inputField value="{!int.Wednesday__c}"/>
            </apex:column>
            <apex:column headerValue="Thursday">
            <apex:inputField value="{!int.Thursday__c}"/>
            </apex:column>
            <apex:column headerValue="Friday">
            <apex:inputField value="{!int.Friday__c}"/>
            </apex:column>
             <apex:column headerValue="Delete">
            <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                <apex:param value="{!rowNum}" name="index"/>
                </apex:commandLink>
                <apex:variable var="rowNum" value="{!rowNum+1}"/>
            </apex:column>
        </apex:PageBlockTable>
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!insertChild}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>

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

And this is the controller

 
public class AddingChildController {
Id parentId;
public List<Time_Sheets__c> childList {get;set;}
public Integer rowNum{get;set;}

public Lead_Gen__c Parent {get;set;}
 
 
 


public AddingChildController(){
    Id childId = ApexPages.currentPage().getParameters().get('childId');
    childList = new List<Time_Sheets__c>();
    childList.add(new Time_Sheets__c());
    ParentId=ApexPages.currentPage().getParameters().get('ParentId');   
      
}

public pagereference insertChild(){
    insert childList;

    Parent.Id=parentId;
    update Parent;

    Pagereference page=new pagereference('/'+parentId);
    Return page;

       
}    

public void insertRow(){
    childList.add(new Time_Sheets__c());
    
    
}

public void delRow(){
    rowNum = 
Integer.valueof(apexpages.currentpage().getparameters().get('index'));

childList.remove(rowNum);
}
}

​​​​​​Could someone assist with what I am missing

cheers 
I am trying to add a table within a table , from what I can see I have added the block and the table but I am getting the following error


Error: <apex:column> must be the direct child of either <apex:dataTable> or <apex:pageBlockTable>

 
<apex:page controller="AddingChildController" >
<apex:form >
    <apex:variable var="rowNum" value="{!0}" />
    <apex:pageBlock title="Weekly Time Sheets">
    <apex:pageBlock >
    
        <apex:variable var="rowNum" value="{!0}" />
        <apex:PageBlockTable value="{!childList}" var="int">
        <apex:facet name="footer">
            <apex:commandLink value="Add" action="{!insertRow}"/>
            </apex:facet>
            
            
            <apex:pageBlockTable value="{!childList}" var="int">
        <apex:column headerValue="Pay Run">
                <apex:inputField value="{!int.Pay_Run__c}"/>                                      
            </apex:column>

        <apex:column breakBefore="true" colspan="2">
                      
            <apex:column headerValue="Lead Generator">
                <apex:inputField value="{!int.Lead_Gen__c}"/>                                      
            </apex:column>
            <apex:column headerValue="Pay Run">
                <apex:inputField value="{!int.Pay_Run__c}"/>                                      
            </apex:column>
            <apex:column headerValue="Monday">
                <apex:inputField value="{!int.Monday__c}"/>
            </apex:column>
            <apex:column headerValue="Tuesday">
                <apex:inputField value="{!int.Tuesday__c}"/>
            </apex:column>
            <apex:column headerValue="Wednesday">
                <apex:inputField value="{!int.Wednesday__c}"/>
            </apex:column>
            <apex:column headerValue="Thursday">
                <apex:inputField value="{!int.Thursday__c}"/>
            </apex:column>
            <apex:column headerValue="Friday">
                <apex:inputField value="{!int.Friday__c}"/>
            </apex:column>
             <apex:column headerValue="Delete">
            
            <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                <apex:param value="{!rowNum}" name="index"/>
                </apex:commandLink>
                <apex:variable var="rowNum" value="{!rowNum+1}"/>
            </apex:column>
             </apex:column>
            </apex:PageBlockTable>
        </apex:pageblocktable>
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!insertChild}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:pageblock>
  </apex:form>
</apex:page>

Any Ideas ?
I am looking to point to the last login time on the user object as part of a solution I am building. However neither the process builder nor formulas allow us to point to the standard out of the box user field called Last login time. I found a trigger on another thread that I could leverage

this is the trigger 
trigger lastLoginDate on User(before update){
User u = [SELECT LastLoginDate FROM User WHERE Id =:UserInfo.getUserId()];
for(User c : Trigger.new){        
    c.last_login__c= u.LastLoginDate;
    }
}

It works but I must hit the edit save button on the user record in order for the trigger to fire. What I need is for the trigger to fire when a user actaully logs in . I had assumed that a user logging in would fire the trigger by updating the standard last login field and therefore update my new custom last login field

Any ideas ?

I thought I could build a process to hit a refresh check box every day on all users, this may work as I only need the login day for the solution.

OR

Is there anyone who knows if I could treak the above trigger to fire when someone actaully logs in ?

 
I have been building a VF page that updates child and parent records 

The error that I get back after inputting is
​​​​​​
Visualforce Error
Help for this Page

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!insertChild}' in component <apex:commandButton> in page updatechild: Class.AddingChildController.insertChild: line 23, column 1


User-added image
​​​​​​This is the VF page
 
<apex:page controller="AddingChildController" >
<apex:form >
    <apex:variable var="rowNum" value="{!0}" />
    <apex:pageBlock >
        <apex:variable var="rowNum" value="{!0}" />
        <apex:PageBlockTable value="{!childList}" var="int">
        <apex:facet name="footer">
            <apex:commandLink value="Add" action="{!insertRow}"/>
            </apex:facet>
            <apex:column headerValue="Lead Generator">
                <apex:inputField value="{!int.Lead_Gen__c}"/>                                      
            </apex:column>
            
            
            
            <apex:column headerValue="Monday">
            <apex:inputField value="{!int.Monday__c}"/>
            </apex:column>
            <apex:column headerValue="Tuesday">
            <apex:inputField value="{!int.Tuesday__c}"/>
            </apex:column>
            <apex:column headerValue="Wednesday">
            <apex:inputField value="{!int.Wednesday__c}"/>
            </apex:column>
            <apex:column headerValue="Thursday">
            <apex:inputField value="{!int.Thursday__c}"/>
            </apex:column>
            <apex:column headerValue="Friday">
            <apex:inputField value="{!int.Friday__c}"/>
            </apex:column>
             <apex:column headerValue="Delete">
            <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                <apex:param value="{!rowNum}" name="index"/>
                </apex:commandLink>
                <apex:variable var="rowNum" value="{!rowNum+1}"/>
            </apex:column>
        </apex:PageBlockTable>
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!insertChild}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>

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

And this is the controller

 
public class AddingChildController {
Id parentId;
public List<Time_Sheets__c> childList {get;set;}
public Integer rowNum{get;set;}

public Lead_Gen__c Parent {get;set;}
 
 
 


public AddingChildController(){
    Id childId = ApexPages.currentPage().getParameters().get('childId');
    childList = new List<Time_Sheets__c>();
    childList.add(new Time_Sheets__c());
    ParentId=ApexPages.currentPage().getParameters().get('ParentId');   
      
}

public pagereference insertChild(){
    insert childList;

    Parent.Id=parentId;
    update Parent;

    Pagereference page=new pagereference('/'+parentId);
    Return page;

       
}    

public void insertRow(){
    childList.add(new Time_Sheets__c());
    
    
}

public void delRow(){
    rowNum = 
Integer.valueof(apexpages.currentpage().getparameters().get('index'));

childList.remove(rowNum);
}
}

​​​​​​Could someone assist with what I am missing

cheers 
I have been building a VF page that updates child and parent records 

The error that I get back after inputting is
​​​​​​
Visualforce Error
Help for this Page

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!insertChild}' in component <apex:commandButton> in page updatechild: Class.AddingChildController.insertChild: line 23, column 1


User-added image
​​​​​​This is the VF page
 
<apex:page controller="AddingChildController" >
<apex:form >
    <apex:variable var="rowNum" value="{!0}" />
    <apex:pageBlock >
        <apex:variable var="rowNum" value="{!0}" />
        <apex:PageBlockTable value="{!childList}" var="int">
        <apex:facet name="footer">
            <apex:commandLink value="Add" action="{!insertRow}"/>
            </apex:facet>
            <apex:column headerValue="Lead Generator">
                <apex:inputField value="{!int.Lead_Gen__c}"/>                                      
            </apex:column>
            
            
            
            <apex:column headerValue="Monday">
            <apex:inputField value="{!int.Monday__c}"/>
            </apex:column>
            <apex:column headerValue="Tuesday">
            <apex:inputField value="{!int.Tuesday__c}"/>
            </apex:column>
            <apex:column headerValue="Wednesday">
            <apex:inputField value="{!int.Wednesday__c}"/>
            </apex:column>
            <apex:column headerValue="Thursday">
            <apex:inputField value="{!int.Thursday__c}"/>
            </apex:column>
            <apex:column headerValue="Friday">
            <apex:inputField value="{!int.Friday__c}"/>
            </apex:column>
             <apex:column headerValue="Delete">
            <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                <apex:param value="{!rowNum}" name="index"/>
                </apex:commandLink>
                <apex:variable var="rowNum" value="{!rowNum+1}"/>
            </apex:column>
        </apex:PageBlockTable>
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!insertChild}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>

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

And this is the controller

 
public class AddingChildController {
Id parentId;
public List<Time_Sheets__c> childList {get;set;}
public Integer rowNum{get;set;}

public Lead_Gen__c Parent {get;set;}
 
 
 


public AddingChildController(){
    Id childId = ApexPages.currentPage().getParameters().get('childId');
    childList = new List<Time_Sheets__c>();
    childList.add(new Time_Sheets__c());
    ParentId=ApexPages.currentPage().getParameters().get('ParentId');   
      
}

public pagereference insertChild(){
    insert childList;

    Parent.Id=parentId;
    update Parent;

    Pagereference page=new pagereference('/'+parentId);
    Return page;

       
}    

public void insertRow(){
    childList.add(new Time_Sheets__c());
    
    
}

public void delRow(){
    rowNum = 
Integer.valueof(apexpages.currentpage().getparameters().get('index'));

childList.remove(rowNum);
}
}

​​​​​​Could someone assist with what I am missing

cheers 
I am looking to point to the last login time on the user object as part of a solution I am building. However neither the process builder nor formulas allow us to point to the standard out of the box user field called Last login time. I found a trigger on another thread that I could leverage

this is the trigger 
trigger lastLoginDate on User(before update){
User u = [SELECT LastLoginDate FROM User WHERE Id =:UserInfo.getUserId()];
for(User c : Trigger.new){        
    c.last_login__c= u.LastLoginDate;
    }
}

It works but I must hit the edit save button on the user record in order for the trigger to fire. What I need is for the trigger to fire when a user actaully logs in . I had assumed that a user logging in would fire the trigger by updating the standard last login field and therefore update my new custom last login field

Any ideas ?

I thought I could build a process to hit a refresh check box every day on all users, this may work as I only need the login day for the solution.

OR

Is there anyone who knows if I could treak the above trigger to fire when someone actaully logs in ?