• Debajyoti Dhal
  • NEWBIE
  • 55 Points
  • Member since 2017

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi  I hope  someone can help me here .  I am new to writting test classes.  

My test class is falinig do to  following error. 
System.QueryException: List has no rows for assignment to SObject  ( line 4, column 1) 

In this test,  User with Role  CAG EMEA Animana CS Rep  should be blocked from  editing field on the  account page: Number of Doctors. 

@istest
private class Test_VR_DontAllowEditforAnimana {
    private static testmethod void updateAccount(){
        User testUser = [Select Id,UserRole.Name,Profile.Name From User 
                        Where UserRole.Name = 'CAG EMEA Animana CS Rep' 
                        AND Profile.Name = 'Field Sales Rep- CAG EMEA'
                        AND Reporting_Role__c = 'FSR DX'
                        AND isActive = true LIMIT 1];

        insert testUser;

        Account testAccount = [SELECT Id FROM Account WHERE Name = 'Test Account' AND SAP_Customer_Number__c ='5678111111' LIMIT 1];
        Insert testAccount;
        Test.startTest();
        system.runAs(testUser){
            
              testAccount = New Account(Number_of_Doctors__c  = 2.00);
            try{
                update testAccount;    
            }catch(Exception e){
                system.debug(e.getMessage());
                system.assertEquals(true,e.getMessage().contains('This modification is not allowed. Please contact your CAG colleague for this field.'));
            }
            System.assertEquals(null,testAccount.id);
            
            
        }
         test.stopTest();
        
    }
}
 


 
Hi!

I'm trying to get information of a custom object related to an account. To do this, I've created a flow and a process, of which the process should trigger on an update to the custom object.

When I edit a random field of the custom object, the process either does not trigger or does not work. I've got 2 questions:

1. Does any change to an object qualify as an "Update", or is "Update" more narrowly defined?
2. If it does not qualify, how would I go about testing such a process/flow?

Apologies if this is the wrong topic and regards,

Erik 
Hi  I hope  someone can help me here .  I am new to writting test classes.  

My test class is falinig do to  following error. 
System.QueryException: List has no rows for assignment to SObject  ( line 4, column 1) 

In this test,  User with Role  CAG EMEA Animana CS Rep  should be blocked from  editing field on the  account page: Number of Doctors. 

@istest
private class Test_VR_DontAllowEditforAnimana {
    private static testmethod void updateAccount(){
        User testUser = [Select Id,UserRole.Name,Profile.Name From User 
                        Where UserRole.Name = 'CAG EMEA Animana CS Rep' 
                        AND Profile.Name = 'Field Sales Rep- CAG EMEA'
                        AND Reporting_Role__c = 'FSR DX'
                        AND isActive = true LIMIT 1];

        insert testUser;

        Account testAccount = [SELECT Id FROM Account WHERE Name = 'Test Account' AND SAP_Customer_Number__c ='5678111111' LIMIT 1];
        Insert testAccount;
        Test.startTest();
        system.runAs(testUser){
            
              testAccount = New Account(Number_of_Doctors__c  = 2.00);
            try{
                update testAccount;    
            }catch(Exception e){
                system.debug(e.getMessage());
                system.assertEquals(true,e.getMessage().contains('This modification is not allowed. Please contact your CAG colleague for this field.'));
            }
            System.assertEquals(null,testAccount.id);
            
            
        }
         test.stopTest();
        
    }
}
 


 
Hi!

I'm trying to get information of a custom object related to an account. To do this, I've created a flow and a process, of which the process should trigger on an update to the custom object.

When I edit a random field of the custom object, the process either does not trigger or does not work. I've got 2 questions:

1. Does any change to an object qualify as an "Update", or is "Update" more narrowly defined?
2. If it does not qualify, how would I go about testing such a process/flow?

Apologies if this is the wrong topic and regards,

Erik