• Bhaskar Muli 6
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Error:  Illegal Assignment from List to Id

on lines: 24, 32, 40, 48, 56, 64

Thank you
@isTest
private class ContactDNCOpportunityTest {
       
    private static testMethod void testCloseOpps(){
        //Create Account
        
        Account newAcc = FlowTestUtils.createHouseholdAccount();
    		insert newAcc;  
        
        
       //Create Contacts
           List<Contact> conList = new List<Contact> {
		new Contact(FirstName='test1',LastName='tester',AccountId = newAcc.Id, Email = 'test1@testing.com', Phone = '1234567891', Phone_Status__c = 'Do Not Call'),  //Has Phone Number - Do not call, Closed Opp
        new Contact(FirstName='test2',LastName='tester',AccountId = newAcc.Id, Email = 'test2@testing.com'), //Blank No Numbers  Closed Opp
        new Contact(FirstName='test3',LastName='tester',AccountId = newAcc.Id, Email = 'test3@testing.com', Normalized_Work_Phone__c = '1234567891',Work_Phone_Status__c = 'Active'), // Has Work Number, Active, Do Not Close Opp
		new Contact(FirstName='test4',LastName='tester',AccountId = newAcc.Id, Email = 'test4@testing.com', Phone = '1234567891', Phone_Status__c = 'Active'), //Has Phone Number, Active, Do not Close Opp
        new Contact(FirstName='test5',LastName='tester',AccountId = newAcc.Id, Email = 'test5@testing.com', Normalized_Mobile_Phone__c = '1234567891', Mobile_Phone_Status__c = 'Do Not Call'), //Has mobile number, DNC, Close Opp      
        new Contact(FirstName='test6',LastName='tester',AccountId = newAcc.Id, Email = 'test6@testing.com', Normalized_Work_Phone__c = '1234567891', Work_Phone_Status__c = 'Do Not Call') //Has Worknumber DNC is checked
            };	
                
            insert conList;
       
        
        Opportunity opptest1 = new Opportunity(Name = 'Opp1', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Primary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test1']);
        Test.startTest();
            insert opptest1;
        Test.stopTest();   
        
        System.assertEquals('Closed', opptest1.StageName);
                
            
        Opportunity opptest2 = new Opportunity(Name = 'Opp2', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Primary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test2']);
        Test.startTest();
            insert opptest2;
        Test.stopTest();   
        
        System.assertEquals('Closed', opptest2.StageName);
          
        
         Opportunity opptest3 = new Opportunity(Name = 'Opp3', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Primary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test3']);
         Test.startTest();
            insert opptest3;
         Test.stopTest();   
        
        System.assertEquals('Closed', opptest3.StageName);
           
        
         Opportunity opptest4 = new Opportunity(Name = 'Opp4', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Secondary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test4']);
         Test.startTest();
            insert opptest4;
         Test.stopTest();   
        
        System.assertNotEquals('Closed', opptest4.StageName);
           
        
         Opportunity opptest5 = new Opportunity(Name = 'Opp5', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Secondary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test5']);  
         Test.startTest();
            insert opptest5;
         Test.stopTest();   
        
        System.assertEquals('Closed', opptest5.StageName);
            
        
         Opportunity opptest6 = new Opportunity(Name = 'Opp6', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today(), Secondary_Contact__c = [SELECT Id FROM Contact WHERE FirstName = 'test6']);
         Test.startTest();
            insert opptest6;
         Test.stopTest();   
        
        System.assertEquals('Closed', opptest6.StageName);
            
         Opportunity opptest7 = new Opportunity(Name = 'Opp7', AccountId = newACC.id, StageName = 'Ready to Call/Schedule', CloseDate = Date.today());                                            
         Test.startTest();
            insert opptest7;
         Test.stopTest();   
        
        System.assertEquals('Closed', opptest7.StageName);
        
    }
             
}



 
Hi, 

  I need to get all the user role and sub roles within sub role that are associated to a parent role using soql query. Below is the code which i am using to get role and sub-roles data. 

 /* Here I pass user name get the userrole id */
 user gurs = [Select UserRoleId,Email,ForecastEnabled 
                     from user where id = :runningUserId LIMIT 1];

/*  Here I pass the userrole id to see parentroleid */
 List<User> UsrList = [Select FirstName, Id, LastName, UserRoleId, UserRole.Name 
                            from User 
                            Where UserRole.ParentRoleId = :gurs.UserRoleId];

I am able to see below roles when i run the above soql code. 

 Example : 
     EMEA - Level - 1
          EMEA- Sub Level -2 

My new requirement is 

 Example 
     EMEA - Level - 1
          EMEA- Sub Level -2 
              EMEA - Super Sub Level-3

If I pass user name I should be able to see all the 3 level hierarchy data if there are ever 4 I should be able to see all the 4 level 

Please suggest me apex experts how i can achive this requirement need you suggestion 

Thanks
Sudhir