Display Date/Time Based On Lookup User.
VF Page:
<apex:page standardcontroller="Contact" extensions="RelatedController" showHeader="false">
<apex:form >
<apex:actionRegion >
<apex:pageBlock id="accinfo">
<apex:pageBlockSection title="Account Information">
<apex:inputField value="{!contact.AccountId}" id="abc">
<apex:actionSupport event="onchange" action="{!currentDatePopup}" rerender="accinfo,abc" />
</apex:inputField>
<apex:outputText value="{!currentDatetime }" label="Current Date/time" />
<apex:inputField value="{!contact.Look__c}" id="abc1">
<apex:actionSupport event="onchange" action="{!currentDatePopup1}" rerender="accinfo,abc1" />
</apex:inputField>
<apex:outputText value="{!currentDatetime1 }" label="Current "/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:actionRegion>
</apex:form>
</apex:page>
Apex Class:
public with sharing class RelatedController
{
private ApexPages.StandardController stdCtrl;
public Contact con;
public datetime currentDatetime{get;set;}
public datetime currentDatetime1{get;set;}
public void currentDatePopup()
{
currentDatetime = System.now();
}
public void currentDatePopup1()
{
currentDatetime1 = System.now();
}
public RelatedController(ApexPages.StandardController std)
{
stdCtrl=std;
}
public void AccountPopulated()
{
Contact cont=(Contact) stdCtrl.getRecord();
try{
if(cont.account!= null)
cont.Account=[select AccountNumber,CurrentDate__c,Lookuptest__c,DateTime__c from Account where id=:cont.AccountId ];
}
catch(exception e){}
}
}
VF Page:
<apex:page standardcontroller="Contact" extensions="RelatedController" showHeader="false">
<apex:form >
<apex:actionRegion >
<apex:pageBlock id="accinfo">
<apex:pageBlockSection title="Account Information">
<apex:inputField value="{!contact.AccountId}" id="abc">
<apex:actionSupport event="onchange" action="{!currentDatePopup}" rerender="accinfo,abc" />
</apex:inputField>
<apex:outputText value="{!currentDatetime }" label="Current Date/time" />
<apex:inputField value="{!contact.Look__c}" id="abc1">
<apex:actionSupport event="onchange" action="{!currentDatePopup1}" rerender="accinfo,abc1" />
</apex:inputField>
<apex:outputText value="{!currentDatetime1 }" label="Current "/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:actionRegion>
</apex:form>
</apex:page>
Apex Class:
public with sharing class RelatedController
{
private ApexPages.StandardController stdCtrl;
public Contact con;
public datetime currentDatetime{get;set;}
public datetime currentDatetime1{get;set;}
public void currentDatePopup()
{
currentDatetime = System.now();
}
public void currentDatePopup1()
{
currentDatetime1 = System.now();
}
public RelatedController(ApexPages.StandardController std)
{
stdCtrl=std;
}
public void AccountPopulated()
{
Contact cont=(Contact) stdCtrl.getRecord();
try{
if(cont.account!= null)
cont.Account=[select AccountNumber,CurrentDate__c,Lookuptest__c,DateTime__c from Account where id=:cont.AccountId ];
}
catch(exception e){}
}
}