• sindoora
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 21
    Replies
I'm trying to add owner of parent account under team member for child Account.Here is senario. Account P with VPA = true and Owner = PO.

· Account A with VPA = false (or true, doesn’t matter) and Owner = AO.

For Account A, I specify account P as parent account. Then, I expect the trigger to add PO (parent account owner) to the account team of Account A. And again, this should happen only if the parent account has VPA = true.

Here is my work ,which works while creating a new record. I need to extend this by including the update condition i.e if we change the parent owner correspondingly the teAM member has to be changed. trigger AccountTeam on Account (after insert,before update, after update) { if(trigger.isafter && Trigger.Isinsert ){

  for(Account acct : trigger.new){

             Integer newcnt=0;
             Integer newcnt0=0;
             AccountTeamMember[] newmembers = new AccountTeamMember[]{};
              //list of new team members to add
              AccountShare[] newShare = new AccountShare[]{};
               //list of new shares to add

               list<Account> a1 = [select id,VPA__c, parent.Id,OwnerId from account Where Id=:acct.ParentID];
             for(account acc: a1){
               ID uid =  acc.OwnerId;
                Boolean x=acc.VPA__c;

               //get the user id of the parent Account, if VPA is checked and  will added to the account team
          if( a1.size()>0 && x == True)  {// checking size of list.
               for(Account a:trigger.new) {          
                        AccountTeamMember Teammemberad=new AccountTeamMember();
                        Teammemberad.AccountId=a.id;
                         Teammemberad.UserId=uid;
                         Teammemberad.TeamMemberRole = 'Global KA Manager';
                         newmembers.add(Teammemberad);
                         }
                    Database.SaveResult[] lsr = Database.insert(newmembers,false);
                 //insert any valid members then add their share entry if they were successfully added ;
                 for(Database.SaveResult sr:lsr)
                 {
                 if(!sr.isSuccess())
                 {
                 Database.Error emsg =sr.getErrors()[0];

                  system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
                   }
                   else
                   {
                   newShare.add(new AccountShare(UserOrGroupId=newmembers[newcnt].UserId, AccountId=newmembers[newcnt].Accountid, AccountAccessLevel='Read',OpportunityAccessLevel='Read'));
                   }
                    newcnt++;
                    }
                    Database.SaveResult[] lsr0 =Database.insert(newShare,false);
                     //insert the new shares Integer newcnt0=0;
                     for(Database.SaveResult sr0:lsr0)
                     {
                     if(!sr0.isSuccess())
                     {
                     Database.Error emsg0=sr0.getErrors()[0];
                     system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0); } newcnt0++; }
                      }
                          }
                              }

                      }
              }
We build a vf page for an custom object called competitor.  The vf page consists of java script for executing pop up box according to our senario.
The java part of the code is as below: function chngPrimComp(cmp,val){       
        var c;
        var flag=0;
        if(cmp.checked==false && flag!=0){           
            alert('{!$Label.msgCantUnchk}');
            cmp.checked=true;
            flag++;
        }
        if(cmp.checked==true && flag==0){             
            ctrlCompetitor.checkFirstPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
                if(event.status){           
                    if(result=='false'){                   
                    c=confirm('{!$Label.msgPrmryCompCnfrm}');
                        if(c==true){
                        flag++;                              
                            ctrlCompetitor.checkPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
                                if(event.status){}
                                if(event.exception){}
                            });
                        }
                        else if(c==false){
                        cmp.checked=false;
                        }
                    }
                }  
            });
Senario: Opportunity had competitor has a related list. ---> This competitor had few records. if we edit the record from opportunity page,the logic work fine and it displays popup.
In this case the logic captures the opportunity id {!$CurrentPage.parameters.retURL}' =>
ctrlCompetitor.checkFirstPrimaryComp('/006c0000009gG4Q',function(result, event){

Problem:if i edit the competitor records from competitor page then the code didn't fire pop up.

In this case the logic captures opprotunity id along with addtional info .something like this heckFirstPrimaryComp('/a0G?rlid=00ND0000005Df4w&id=006c0000009gG4Q',function(result, event){

 Bug:In the above case how to truncate the additional values and how to display popup on the competitor if user edits from competitor page.

Hi All,

Here is the batch apex for capturing system generated lastlogin date into a custom field.

1.Batch Apex

global class CaptureLastLoginDate implements Database.Batchable<sObject>{

//This is the query that is passed to the execute method. .

String ids = UserInfo.getUserId();
String query = 'SELECT id, LastLoginDate,LastLoginDate__c FROM User ';

global database.queryLocator start(Database.BatchableContext BC) {
System.debug(query);
return database.getQueryLocator(query);
}
//close start method
global void execute(Database.BatchableContext BC, List<sObject> scope){
    List<Schema.User> u = new List<Schema.User> ();
    for(sObject s: Scope){
        Schema.User inv = (Schema.User)s;
        inv.LastLoginDate__c= inv.LastLoginDate;
        u.add(inv);
        System.debug(u);
    }
    update u;

}

    global void finish(Database.BatchableContext sc){
    }
    
}

 

2.Scheduled batch

global class scheduledMerge1 implements Schedulable {
   global void execute(SchedulableContext SC) {
       CaptureLastLoginDate M = new  CaptureLastLoginDate(); 
       database.executebatch(M,100);
      scheduledMerge1 pa= new scheduledMerge1();
String cronStr = '0 0 * * * ? *';
 System.schedule('scheduledMerge1 Job', cronStr, pa);
 }
 }

 

4.Test Class for Batch APex

@IsTest(SeeAllData=true)
 Private class LastLogintest
 {
 
 static testMethod void CaptureLastLoginDate()
 {
String ids = UserInfo.getUserId();

    // Making the assumption that at least one user will match this. Better to assign to list and check that has at least one record.
    Schema.User testUser = new Schema.User();
    testUser=[SELECT id, LastLoginDate,LastLoginDate__c FROM User limit 1];
    // Set it to anything other than LastLoginDate so we can tell it has changed.
   
   //insert testUser;

    Test.startTest();
    CaptureLastLoginDate captureBatch = new CaptureLastLoginDate();
    // Modify the query here so we only get our one testing user of interest
    //captureBatch.query = 'SELECT id, LastLoginDate,LastLoginDate__c FROM User where Id =:testUser.Id';
    ID batchprocessid = Database.executeBatch(captureBatch,1);
    Test.StopTest();

    Schema.User afterBatchUser = [Select Id, LastLoginDate, LastLoginDate__c from User where Id =:testUser.Id limit 1];
    System.AssertEquals(afterBatchUser.LastLoginDate, testUser.LastLoginDate__c);
}
}

5.Test Class for scheduled apex

@istest
Private class Capturetest{
static testMethod void scheduledMerge()
 {

Test.StartTest();
scheduledMerge pa= new scheduledMerge();
String cronStr = '0 0 * * * ? *';
 
Test.stopTest();

}
}

 

Note:There were no errors in the code. test class for scheduled apex was running fine.but the test class for batch apex failed.Suggest

Hi all,

I'm trying to create a batch apex to capture system generated lastlogindate on to custom field.But this is firing an error.

Here is the code

global class CaptureLastLoginDate implements Database.Batchable<sObject>{
 
    //This is the query that is passed to the execute method.  .
    
    String query = 'SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()';
 
    global database.queryLocator start(Database.BatchableContext BC) {
        return database.getQueryLocator(query);
 
    }
    //close start method
 global void  Execute(Database.BatchableContext BC, List<User> scope) {
 User u = [SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()];
 
      
       // Iterate through the whole query
        for(User a : scope) {
            
                a.LastLoginDate__c = u.LastLoginDate;
            } //close if statement
         update LastLoginDate__c;
         }
        
        //close for-loop
      
     //close execute method
 
    global void finish(Database.BatchableContext BC) {
 
        
    } //close finish method

 

Could anyone help me.Thank you in advance

error:

Error: Compile Error: Argument type of global method must also be global: LIST<User> at line 12 column 15

 

hi

I want to execute the below code if VPA(custom field on Account of type checkbox) is true

trigger AccountTeam on Account (before insert,after update) {
if(trigger.isafter && Account.VPA__c!=null)
{
 Integer newcnt=0;
 Integer newcnt0=0;
 AccountTeamMember[] newmembers = new AccountTeamMember[]{};
  //list of new team members to add
  AccountShare[] newShare = new AccountShare[]{};
   //list of new shares to add
   Account a1 = [select id, parent.Id,OwnerId from account Where Id=:trigger.new[0].ParentID];
   ID uid =  a1.OwnerId;
    
   
   //get the user id of the parent Account, anyone that changes the Account will added to the account team
   for(Account a:trigger.new)
   {
   
   
    AccountTeamMember Teammemberad=new AccountTeamMember();
    Teammemberad.AccountId=a.id;
     Teammemberad.UserId=uid;
     Teammemberad.TeamMemberRole = 'Account Modifier';
     newmembers.add(Teammemberad);
     }
        Database.SaveResult[] lsr = Database.insert(newmembers,false);
     //insert any valid members then add their share entry if they were successfully added Integer newcnt=0;
     for(Database.SaveResult sr:lsr)
     {
     if(!sr.isSuccess())
     {
     Database.Error emsg =sr.getErrors()[0];
     
      system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
       }
       else
       {
       newShare.add(new AccountShare(UserOrGroupId=newmembers[newcnt].UserId, AccountId=newmembers[newcnt].Accountid, AccountAccessLevel='Read',OpportunityAccessLevel='Read'));
       }
        newcnt++;
        }
        Database.SaveResult[] lsr0 =Database.insert(newShare,false);
         //insert the new shares Integer newcnt0=0;
         for(Database.SaveResult sr0:lsr0)
         {
         if(!sr0.isSuccess())
         {
         Database.Error emsg0=sr0.getErrors()[0];
         system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0); } newcnt0++; }
          }
          }

But this is executing though VPA==null.

Quick response highly appriciated

Hi All,

 

I'm trying to add Account team member dynamically but my code fires error msg.Please go through the steps below.

 

Parent Account(Lookup Field)----------------on Account Object

VPA(Checkbox)------------------------------------on Account Object.

If VPA==true

then the owner of parent account to which it is lookup should be added as account teammember on account page.

trigger AccountTeam on Account (after update) {
Integer newcnt=0;
Integer newcnt0=0;
AccountTeamMember[] newmembers = new AccountTeamMember[]{};
//list of new team members to add
AccountShare[] newShare = new AccountShare[]{};
//list of new shares to add
Account a1 = [select id, parent.Id,Owner from account Where Id=:trigger.new[0].ParentID];
ID uid = a1.Owner;


//get the user id of the user running the trigger, anyone that changes the Account will added to the account team
for(Account a:trigger.new)
{
AccountTeamMember Teammemberad=new AccountTeamMember();
Teammemberad.AccountId=a.id;
Teammemberad.UserId=uid;
Teammemberad.TeamMemberRole = 'Account Modifier';
newmembers.add(Teammemberad);
}
Database.SaveResult[] lsr = Database.insert(newmembers,false);
//insert any valid members then add their share entry if they were successfully added Integer newcnt=0;
for(Database.SaveResult sr:lsr)
{
if(!sr.isSuccess())
{
Database.Error emsg =sr.getErrors()[0];

system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
}
else
{
newShare.add(new AccountShare(UserOrGroupId=newmembers[newcnt].UserId, AccountId=newmembers[newcnt].Accountid, AccountAccessLevel='Read',OpportunityAccessLevel='Read'));
}
newcnt++;
}
Database.SaveResult[] lsr0 =Database.insert(newShare,false);
//insert the new shares Integer newcnt0=0;
for(Database.SaveResult sr0:lsr0)
{
if(!sr0.isSuccess())
{
Database.Error emsg0=sr0.getErrors()[0];
system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0); } newcnt0++; }
}

 

 

Thank you inadvance

how to capture the last login date of a user into a custom field

We build a vf page for an custom object called competitor.  The vf page consists of java script for executing pop up box according to our senario.
The java part of the code is as below: function chngPrimComp(cmp,val){       
        var c;
        var flag=0;
        if(cmp.checked==false && flag!=0){           
            alert('{!$Label.msgCantUnchk}');
            cmp.checked=true;
            flag++;
        }
        if(cmp.checked==true && flag==0){             
            ctrlCompetitor.checkFirstPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
                if(event.status){           
                    if(result=='false'){                   
                    c=confirm('{!$Label.msgPrmryCompCnfrm}');
                        if(c==true){
                        flag++;                              
                            ctrlCompetitor.checkPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
                                if(event.status){}
                                if(event.exception){}
                            });
                        }
                        else if(c==false){
                        cmp.checked=false;
                        }
                    }
                }  
            });
Senario: Opportunity had competitor has a related list. ---> This competitor had few records. if we edit the record from opportunity page,the logic work fine and it displays popup.
In this case the logic captures the opportunity id {!$CurrentPage.parameters.retURL}' =>
ctrlCompetitor.checkFirstPrimaryComp('/006c0000009gG4Q',function(result, event){

Problem:if i edit the competitor records from competitor page then the code didn't fire pop up.

In this case the logic captures opprotunity id along with addtional info .something like this heckFirstPrimaryComp('/a0G?rlid=00ND0000005Df4w&id=006c0000009gG4Q',function(result, event){

 Bug:In the above case how to truncate the additional values and how to display popup on the competitor if user edits from competitor page.

Hi All,

 

I'm trying to add Account team member dynamically but my code fires error msg.Please go through the steps below.

 

Parent Account(Lookup Field)----------------on Account Object

VPA(Checkbox)------------------------------------on Account Object.

If VPA==true

then the owner of parent account to which it is lookup should be added as account teammember on account page.

trigger AccountTeam on Account (after update) {
Integer newcnt=0;
Integer newcnt0=0;
AccountTeamMember[] newmembers = new AccountTeamMember[]{};
//list of new team members to add
AccountShare[] newShare = new AccountShare[]{};
//list of new shares to add
Account a1 = [select id, parent.Id,Owner from account Where Id=:trigger.new[0].ParentID];
ID uid = a1.Owner;


//get the user id of the user running the trigger, anyone that changes the Account will added to the account team
for(Account a:trigger.new)
{
AccountTeamMember Teammemberad=new AccountTeamMember();
Teammemberad.AccountId=a.id;
Teammemberad.UserId=uid;
Teammemberad.TeamMemberRole = 'Account Modifier';
newmembers.add(Teammemberad);
}
Database.SaveResult[] lsr = Database.insert(newmembers,false);
//insert any valid members then add their share entry if they were successfully added Integer newcnt=0;
for(Database.SaveResult sr:lsr)
{
if(!sr.isSuccess())
{
Database.Error emsg =sr.getErrors()[0];

system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
}
else
{
newShare.add(new AccountShare(UserOrGroupId=newmembers[newcnt].UserId, AccountId=newmembers[newcnt].Accountid, AccountAccessLevel='Read',OpportunityAccessLevel='Read'));
}
newcnt++;
}
Database.SaveResult[] lsr0 =Database.insert(newShare,false);
//insert the new shares Integer newcnt0=0;
for(Database.SaveResult sr0:lsr0)
{
if(!sr0.isSuccess())
{
Database.Error emsg0=sr0.getErrors()[0];
system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0); } newcnt0++; }
}

 

 

Thank you inadvance

How to calculate average amount ?if a company pays amt1, amt 2,........amt n/n.
how to calculate this and show as a formula field?
Hi, 

Trying to write a method to get Approver from an approval process. Not sure if this is the way to do it. But getting this error on a trigger

trigger UpdateActor on Expense__c (before update) {

    ProcessInstanceStep instance = new ProcessInstanceStep();
  
    Expense__c  exp = new Expense__c();
    exp = [select id from Expense__c where id=:trigger.new[0].Id];
   
    if(trigger.isUpdate && !exp.isEmpty())
    {
        instance = [select id from ProcessInstanceStep where id=:exp.id];
       
        exp.Approved_by__c = instance.ActorId;
    }
   
   

}

If anyone knows anything, please help!

Hi All

      

       Am using Datetime datetype in sfdc my doubt is if i havng 1 string date='' & string time='' here how to store the date&time in Datetime datatype field....

 

Thanks

=========

Venkatsforce

Hi All,

Here is the batch apex for capturing system generated lastlogin date into a custom field.

1.Batch Apex

global class CaptureLastLoginDate implements Database.Batchable<sObject>{

//This is the query that is passed to the execute method. .

String ids = UserInfo.getUserId();
String query = 'SELECT id, LastLoginDate,LastLoginDate__c FROM User ';

global database.queryLocator start(Database.BatchableContext BC) {
System.debug(query);
return database.getQueryLocator(query);
}
//close start method
global void execute(Database.BatchableContext BC, List<sObject> scope){
    List<Schema.User> u = new List<Schema.User> ();
    for(sObject s: Scope){
        Schema.User inv = (Schema.User)s;
        inv.LastLoginDate__c= inv.LastLoginDate;
        u.add(inv);
        System.debug(u);
    }
    update u;

}

    global void finish(Database.BatchableContext sc){
    }
    
}

 

2.Scheduled batch

global class scheduledMerge1 implements Schedulable {
   global void execute(SchedulableContext SC) {
       CaptureLastLoginDate M = new  CaptureLastLoginDate(); 
       database.executebatch(M,100);
      scheduledMerge1 pa= new scheduledMerge1();
String cronStr = '0 0 * * * ? *';
 System.schedule('scheduledMerge1 Job', cronStr, pa);
 }
 }

 

4.Test Class for Batch APex

@IsTest(SeeAllData=true)
 Private class LastLogintest
 {
 
 static testMethod void CaptureLastLoginDate()
 {
String ids = UserInfo.getUserId();

    // Making the assumption that at least one user will match this. Better to assign to list and check that has at least one record.
    Schema.User testUser = new Schema.User();
    testUser=[SELECT id, LastLoginDate,LastLoginDate__c FROM User limit 1];
    // Set it to anything other than LastLoginDate so we can tell it has changed.
   
   //insert testUser;

    Test.startTest();
    CaptureLastLoginDate captureBatch = new CaptureLastLoginDate();
    // Modify the query here so we only get our one testing user of interest
    //captureBatch.query = 'SELECT id, LastLoginDate,LastLoginDate__c FROM User where Id =:testUser.Id';
    ID batchprocessid = Database.executeBatch(captureBatch,1);
    Test.StopTest();

    Schema.User afterBatchUser = [Select Id, LastLoginDate, LastLoginDate__c from User where Id =:testUser.Id limit 1];
    System.AssertEquals(afterBatchUser.LastLoginDate, testUser.LastLoginDate__c);
}
}

5.Test Class for scheduled apex

@istest
Private class Capturetest{
static testMethod void scheduledMerge()
 {

Test.StartTest();
scheduledMerge pa= new scheduledMerge();
String cronStr = '0 0 * * * ? *';
 
Test.stopTest();

}
}

 

Note:There were no errors in the code. test class for scheduled apex was running fine.but the test class for batch apex failed.Suggest

Hi all,

I'm trying to create a batch apex to capture system generated lastlogindate on to custom field.But this is firing an error.

Here is the code

global class CaptureLastLoginDate implements Database.Batchable<sObject>{
 
    //This is the query that is passed to the execute method.  .
    
    String query = 'SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()';
 
    global database.queryLocator start(Database.BatchableContext BC) {
        return database.getQueryLocator(query);
 
    }
    //close start method
 global void  Execute(Database.BatchableContext BC, List<User> scope) {
 User u = [SELECT id, LastLoginDate FROM User WHERE Id=:UserInfo.getUserId()];
 
      
       // Iterate through the whole query
        for(User a : scope) {
            
                a.LastLoginDate__c = u.LastLoginDate;
            } //close if statement
         update LastLoginDate__c;
         }
        
        //close for-loop
      
     //close execute method
 
    global void finish(Database.BatchableContext BC) {
 
        
    } //close finish method

 

Could anyone help me.Thank you in advance

error:

Error: Compile Error: Argument type of global method must also be global: LIST<User> at line 12 column 15

 

hi

I want to execute the below code if VPA(custom field on Account of type checkbox) is true

trigger AccountTeam on Account (before insert,after update) {
if(trigger.isafter && Account.VPA__c!=null)
{
 Integer newcnt=0;
 Integer newcnt0=0;
 AccountTeamMember[] newmembers = new AccountTeamMember[]{};
  //list of new team members to add
  AccountShare[] newShare = new AccountShare[]{};
   //list of new shares to add
   Account a1 = [select id, parent.Id,OwnerId from account Where Id=:trigger.new[0].ParentID];
   ID uid =  a1.OwnerId;
    
   
   //get the user id of the parent Account, anyone that changes the Account will added to the account team
   for(Account a:trigger.new)
   {
   
   
    AccountTeamMember Teammemberad=new AccountTeamMember();
    Teammemberad.AccountId=a.id;
     Teammemberad.UserId=uid;
     Teammemberad.TeamMemberRole = 'Account Modifier';
     newmembers.add(Teammemberad);
     }
        Database.SaveResult[] lsr = Database.insert(newmembers,false);
     //insert any valid members then add their share entry if they were successfully added Integer newcnt=0;
     for(Database.SaveResult sr:lsr)
     {
     if(!sr.isSuccess())
     {
     Database.Error emsg =sr.getErrors()[0];
     
      system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
       }
       else
       {
       newShare.add(new AccountShare(UserOrGroupId=newmembers[newcnt].UserId, AccountId=newmembers[newcnt].Accountid, AccountAccessLevel='Read',OpportunityAccessLevel='Read'));
       }
        newcnt++;
        }
        Database.SaveResult[] lsr0 =Database.insert(newShare,false);
         //insert the new shares Integer newcnt0=0;
         for(Database.SaveResult sr0:lsr0)
         {
         if(!sr0.isSuccess())
         {
         Database.Error emsg0=sr0.getErrors()[0];
         system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0); } newcnt0++; }
          }
          }

But this is executing though VPA==null.

Quick response highly appriciated

Hi All,

 

I'm trying to add Account team member dynamically but my code fires error msg.Please go through the steps below.

 

Parent Account(Lookup Field)----------------on Account Object

VPA(Checkbox)------------------------------------on Account Object.

If VPA==true

then the owner of parent account to which it is lookup should be added as account teammember on account page.

trigger AccountTeam on Account (after update) {
Integer newcnt=0;
Integer newcnt0=0;
AccountTeamMember[] newmembers = new AccountTeamMember[]{};
//list of new team members to add
AccountShare[] newShare = new AccountShare[]{};
//list of new shares to add
Account a1 = [select id, parent.Id,Owner from account Where Id=:trigger.new[0].ParentID];
ID uid = a1.Owner;


//get the user id of the user running the trigger, anyone that changes the Account will added to the account team
for(Account a:trigger.new)
{
AccountTeamMember Teammemberad=new AccountTeamMember();
Teammemberad.AccountId=a.id;
Teammemberad.UserId=uid;
Teammemberad.TeamMemberRole = 'Account Modifier';
newmembers.add(Teammemberad);
}
Database.SaveResult[] lsr = Database.insert(newmembers,false);
//insert any valid members then add their share entry if they were successfully added Integer newcnt=0;
for(Database.SaveResult sr:lsr)
{
if(!sr.isSuccess())
{
Database.Error emsg =sr.getErrors()[0];

system.debug('\n\nERROR ADDING TEAM MEMBER:'+emsg);
}
else
{
newShare.add(new AccountShare(UserOrGroupId=newmembers[newcnt].UserId, AccountId=newmembers[newcnt].Accountid, AccountAccessLevel='Read',OpportunityAccessLevel='Read'));
}
newcnt++;
}
Database.SaveResult[] lsr0 =Database.insert(newShare,false);
//insert the new shares Integer newcnt0=0;
for(Database.SaveResult sr0:lsr0)
{
if(!sr0.isSuccess())
{
Database.Error emsg0=sr0.getErrors()[0];
system.debug('\n\nERROR ADDING SHARING:'+newShare[newcnt0]+'::'+emsg0); } newcnt0++; }
}

 

 

Thank you inadvance

how to capture the last login date of a user into a custom field