• Siva Admin
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 14
    Replies
HI am a newbee to SF. Kindly suggest what's wrong with the below test class. 

@IsTest
public class testclassownerassignmanager{
 static testmethod void metest(){
    Profile pro = [SELECT Id FROM Profile WHERE Name='Standard User']; 
User testUserA = new User(
    Alias = 'standard', Email='standarduser@testorg.com',  
    EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
    LocaleSidKey='en_US', ProfileId = pro.Id, 
    TimeZoneSidKey='America/Los_Angeles', 

UserName='testUserA@testorganise.com'); 
  insert testUserA ;

User testUserB = new User(
    Alias = 'standard', Email='standarduser@testorg.com',  
    EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
    LocaleSidKey='en_US', ProfileId = pro.Id,  
    TimeZoneSidKey='America/Los_Angeles', 
     UserName='testUserB@testorganise.com'); 
     testUserB.ManagerID = testUserA.id;
     
     insert testUserB;


  
  List<Account> acclist= new List<Account>();
  for(Integer i=0;i<=10;i++){
  account a = new account(Name='Test' + i, ownerid=testUserB.id);
    acclist.add(a);
  
  List<Account> TobUpdateAcclist= new List<Account>();
  for(Account ac: acclist){
     if (ac.owner.isactive == false )
      {
       ac.ownerid=testUserB.managerid;
       TobUpdateAcclist.add(a);
      }
      }
  
  test.starttest();
  if (Test.isRunningTest()) {
      System.runAs(new User(Id = Userinfo.getUserId())) {
       update TobUpdateAcclist;
      }
    } else {
       update TobUpdateAcclist;
    }
  test.stoptest();
  
  List<Account> updatedaccs = [select id,name from Account where ID IN: TobUpdateAcclist];
   system.assertEquals(a.owner.Managerid, a.ownerid);
  
  
 }}}
Hi all, I'm a newbee to SF. working on creating a test class below. Not getting the coverage at help. You help will be much appreciated. Thanks/

@IsTest
public class testclassownerassignmanager{
 static testmethod void metest(){
    Profile pro = [SELECT Id FROM Profile WHERE Name='Standard User']; 
User testUserA = new User(
    Alias = 'standard', Email='standarduser@testorg.com',  
    EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
    LocaleSidKey='en_US', ProfileId = pro.Id, 
    TimeZoneSidKey='America/Los_Angeles', 

UserName='testUserA@testorganise.com'); 

User testUserB = new User(
    Alias = 'standard', Email='standarduser@testorg.com',  
    EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
    LocaleSidKey='en_US', ProfileId = pro.Id,  
    TimeZoneSidKey='America/Los_Angeles', 

UserName='testUserB@testorganise.com'); 
testUserB.ManagerID = testUserA.id;

List<User> usersToInsert = new List<User>();
usersToInsert.add(testUserA);
usersToInsert.add(testUserB);
insert usersToInsert;
  
  List<Account> acclist= new List<Account>();
  for(Integer i=0;i<=10;i++){
  account a = new account(Name='Test' + i, ownerid=testUserB.id);
    acclist.add(a);
  
  List<Account> TobUpdateAcclist= new List<Account>();
  for(Account ac: acclist){
     if (ac.owner.isactive == false )
      {
       ac.ownerid=testUserB.managerid;
       TobUpdateAcclist.add(a);
      }
      }
  
  test.starttest();
  if (Test.isRunningTest()) {
      System.runAs(new User(Id = Userinfo.getUserId())) {
       update TobUpdateAcclist;
      }
    } else {
       update TobUpdateAcclist;
    }
  test.stoptest();
  List<Account> updatedaccs = [select id,name from Account where id IN:TobUpdateAcclist];
   system.assertEquals(a.owner.Managerid, a.ownerid);
   }}}
Hi all I'm a newbee to SF, trying to get some hand on Test Classes. Have been trying to write a test class for it, but cannot. 

trigger RecordOwnerChange on user (after update){
if (trigger.isafter & trigger.isupdate){

   List<Id> recordIds = new List<Id>();
   
  List<account> aclst = [select id, ownerid, owner.isActive, owner.Managerid from Account where OwnerId IN:trigger.new];
  for (Account ac: aclst){
   if (ac.owner.isActive == false && ac.owner.managerid != null){
    recordIds.add(ac.id);
    }
  }
 if(!recordIds.isEmpty()){
  RecordOwnerChange_4Handler.updateaccounts(recordIds);
    }

CLASS:
public class RecordOwnerChangeHandler {
@future
 public static void updateaccounts(List<Id> recordIds){
 List<Account> updateacclist = new List<Account>();
 for (Account ac:[select ownerid, owner.Managerid from Account where Id IN:recordIds]){
 ac.ownerid= ac.owner.managerid;
 updateacclist.add(ac);
 }
 if(updateacclist.size()>0){
 update updateacclist ;
}}}

kindly help me on this regards. Thanks.
Hello all, I'm newly learning SF working on this requirement. It follows like this:

While inserting a text value as 'someName' ended with 'text' ex: 'JohnText' On Account Object it should through an error.
While updating, the same text value as 'JohnText' should accept it.
How to achive this? Kindly help. 
Hi all I'm new to Salesforce. Can someone plz explain what are the different coponents of Visualforce?
I'm a newly learning SF. While doing challenge (Create a process to update child record when the parent is updated using process builder) in trailhead, following error popping up. Kindly help. 

"Challenge Not yet complete... here's what's wrong: 
An update to an account record failed to update the mailing address fields of all child contact records. Make sure that the process is correct and that it is activated."
plz help me with this.
1) I am having an User (let’s say Stephan). Who has a custom Field called : Immediate Manager. (Hierarchy Field)
2) We have an Account (let’s Say : Google). Whose owner is Stephan.
3) Whenever I will deactivate that user, then that User’s Immediate manager will become owner of all Account, which Stephan owned. Code with all best practices. (Bulkifying).
Also write Test method for this , which should cover at least 85%. functionality should be checked if working or not in test Class also.

trigger RecordOwnerChangeEx on User (after update) {   
 list<user> u=[select id, isActive, ManagerId from user where id in:trigger.new];
  // list<account> acc=[select id, ownerId from Account where ownerId in: ids ];
    list<account> ac=new list<account>();
    for(User uu:u){
        if(uu.IsActive == false && uu.ManagerId != null){
        for(account a:[select id, ownerId from Account where ownerId =:uu.id ]){
            a.ownerId = uu.ManagerId;
            ac.add(a);
        }
    }
    }
    update ac;

Tried with this but not working. 
plz help me with this.
1) I am having an User (let’s say Stephan). Who has a custom Field called : Immediate Manager. (Hierarchy Field)
2) We have an Account (let’s Say : Google). Whose owner is Stephan.
3) Whenever I will deactivate that user, then that User’s Immediate manager will become owner of all Account, which Stephan owned. Code with all best practices. (Bulkifying).
Also write Test method for this , which should cover at least 85%. functionality should be checked if working or not in test Class also.

trigger RecordOwnerChangeEx on User (after update) {   
 list<user> u=[select id, isActive, ManagerId from user where id in:trigger.new];
  // list<account> acc=[select id, ownerId from Account where ownerId in: ids ];
    list<account> ac=new list<account>();
    for(User uu:u){
        if(uu.IsActive == false && uu.ManagerId != null){
        for(account a:[select id, ownerId from Account where ownerId =:uu.id ]){
            a.ownerId = uu.ManagerId;
            ac.add(a);
        }
    }
    }
    update ac;

Tried with this but not working. 
HI am a newbee to SF. Kindly suggest what's wrong with the below test class. 

@IsTest
public class testclassownerassignmanager{
 static testmethod void metest(){
    Profile pro = [SELECT Id FROM Profile WHERE Name='Standard User']; 
User testUserA = new User(
    Alias = 'standard', Email='standarduser@testorg.com',  
    EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
    LocaleSidKey='en_US', ProfileId = pro.Id, 
    TimeZoneSidKey='America/Los_Angeles', 

UserName='testUserA@testorganise.com'); 
  insert testUserA ;

User testUserB = new User(
    Alias = 'standard', Email='standarduser@testorg.com',  
    EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
    LocaleSidKey='en_US', ProfileId = pro.Id,  
    TimeZoneSidKey='America/Los_Angeles', 
     UserName='testUserB@testorganise.com'); 
     testUserB.ManagerID = testUserA.id;
     
     insert testUserB;


  
  List<Account> acclist= new List<Account>();
  for(Integer i=0;i<=10;i++){
  account a = new account(Name='Test' + i, ownerid=testUserB.id);
    acclist.add(a);
  
  List<Account> TobUpdateAcclist= new List<Account>();
  for(Account ac: acclist){
     if (ac.owner.isactive == false )
      {
       ac.ownerid=testUserB.managerid;
       TobUpdateAcclist.add(a);
      }
      }
  
  test.starttest();
  if (Test.isRunningTest()) {
      System.runAs(new User(Id = Userinfo.getUserId())) {
       update TobUpdateAcclist;
      }
    } else {
       update TobUpdateAcclist;
    }
  test.stoptest();
  
  List<Account> updatedaccs = [select id,name from Account where ID IN: TobUpdateAcclist];
   system.assertEquals(a.owner.Managerid, a.ownerid);
  
  
 }}}
Hi all I'm a newbee to SF, trying to get some hand on Test Classes. Have been trying to write a test class for it, but cannot. 

trigger RecordOwnerChange on user (after update){
if (trigger.isafter & trigger.isupdate){

   List<Id> recordIds = new List<Id>();
   
  List<account> aclst = [select id, ownerid, owner.isActive, owner.Managerid from Account where OwnerId IN:trigger.new];
  for (Account ac: aclst){
   if (ac.owner.isActive == false && ac.owner.managerid != null){
    recordIds.add(ac.id);
    }
  }
 if(!recordIds.isEmpty()){
  RecordOwnerChange_4Handler.updateaccounts(recordIds);
    }

CLASS:
public class RecordOwnerChangeHandler {
@future
 public static void updateaccounts(List<Id> recordIds){
 List<Account> updateacclist = new List<Account>();
 for (Account ac:[select ownerid, owner.Managerid from Account where Id IN:recordIds]){
 ac.ownerid= ac.owner.managerid;
 updateacclist.add(ac);
 }
 if(updateacclist.size()>0){
 update updateacclist ;
}}}

kindly help me on this regards. Thanks.
Hello all, I'm newly learning SF working on this requirement. It follows like this:

While inserting a text value as 'someName' ended with 'text' ex: 'JohnText' On Account Object it should through an error.
While updating, the same text value as 'JohnText' should accept it.
How to achive this? Kindly help. 
Hi all I'm new to Salesforce. Can someone plz explain what are the different coponents of Visualforce?
I'm a newly learning SF. While doing challenge (Create a process to update child record when the parent is updated using process builder) in trailhead, following error popping up. Kindly help. 

"Challenge Not yet complete... here's what's wrong: 
An update to an account record failed to update the mailing address fields of all child contact records. Make sure that the process is correct and that it is activated."
plz help me with this.
1) I am having an User (let’s say Stephan). Who has a custom Field called : Immediate Manager. (Hierarchy Field)
2) We have an Account (let’s Say : Google). Whose owner is Stephan.
3) Whenever I will deactivate that user, then that User’s Immediate manager will become owner of all Account, which Stephan owned. Code with all best practices. (Bulkifying).
Also write Test method for this , which should cover at least 85%. functionality should be checked if working or not in test Class also.

trigger RecordOwnerChangeEx on User (after update) {   
 list<user> u=[select id, isActive, ManagerId from user where id in:trigger.new];
  // list<account> acc=[select id, ownerId from Account where ownerId in: ids ];
    list<account> ac=new list<account>();
    for(User uu:u){
        if(uu.IsActive == false && uu.ManagerId != null){
        for(account a:[select id, ownerId from Account where ownerId =:uu.id ]){
            a.ownerId = uu.ManagerId;
            ac.add(a);
        }
    }
    }
    update ac;

Tried with this but not working.