+ Start a Discussion
pradyprady 

Last login field in formula field

Hi,

 

I am trying to use the LastLoginDate from user object to be used in a custom object. But i cant seem to find the field in the formula editor.

 

Is there a way we can do it?

Ispita_NavatarIspita_Navatar

You can’t access the LastLoginDate field in formula field because it is not exposable anymore in database, so you can write a trigger*(before inser,before update) on custom object to fill a field in a custom object based on user. Here below is the code that may help you.


trigger Testtrigger on PTOReq__c (before insert,before update) 
{
                user us=[select LastLoginDate from user where id=:UserInfo.getuserid()];
                account acc=[select name,newpakge__lastlogintimes__c from account where id='00190000009i5qo'];
                acc.newpakge__lastlogintimes__c=us.LastLoginDate;
                update acc;
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.