You need to sign in to do that
Don't have an account?
Surya.236
Hi, I am Getting this following error while running the Test class.
System.DmlException: Insert failed. First exception on row 0; first error: LIMIT_EXCEEDED, limit exceeded: [].
While Inserting the user im Getting this error.
While Inserting the user im Getting this error.
It would be extremely difficult to answer this without looking at the code. Its most likely some part of your code is doing stuff which is taking up a lot of time to complete.. kinldy share your test class please.
Thanks
karthik
Which line you are getting error? coz its may DML operation in thi test class.
NOTE: make sure all your DML statement excutes only one whe you run test class. this may help you to resolve this error.
Thanks
karthik
*User usr = [select id,name from user where Profile.name='HBT RR Partner Community Login User' AND IsActive = true AND Contactid!=null limit 1];
Now I am Getting this error System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: 0030U00000UChDC: []
This Error was at Line Insert cs.
I think this error was that User has no access to Case. How to resolve this? IS my Approach right instead of inserting User im Queried?
you approach is right. but need to assign static profile id insted of dunamic. so that you make sure the test user will have all rights to perform the operation.
ProfileId = profileList[0].Id,
try to assign sysadmin static profile id.
Thanks
karthik
something like below.
UserRole portalRole = [Select Id From UserRole Where PortalType = 'None' Limit 1];
UserRoleId = portalRole.Id;
Thanks
karthik
Following is the changed code :
assgned static profileId and added userroleid.
-------------------------------------------------------------------------------------------------------------------------------------------------------------
List<Profile> profileList = [select id,name from profile where name='System Administrator'];
//List<Profile> profileList = [SELECT Id FROM Profile WHERE Name='HBT RR Partner Community Login User']; //HBT RR Partner Community Login User, Partner Community Login
if(!profileList.isEmpty()){
account a = new account(name='testacc',recordtypeid=EESAcctRecordTypeId );//End user
insert a;
contact c = new contact(lastname='test',Contact_Role__c='End user',Contact_Status__c='Inactive',accountid=a.id,Partner_Account__c=a.id,recordtypeid=EESContactRecordTypeId,email='testtesttesttesttest@honeywell.com' );
insert c;
UserRole portalRole = [Select Id From UserRole Where PortalType = 'Partner' Limit 1];
User usr = new User(Alias = 'standt', Email='standarduser@testorg.com', UserRoleId = portalRole.Id,
EmailEncodingKey='UTF-8', LastName='Testingusername', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = '00e36000001WjFyAAK',
TimeZoneSidKey='America/Los_Angeles', UserName='TestingusernameASN@testorg.com',
contactId=c.id);
//User usr = [select id,name from user where Profile.name='HBT RR Partner Community Login User' AND IsActive = true AND Contactid!=null AND UserRoleId = '00E0U000000NBhqUAG' limit 1];
// User usr = [select id,name from user where Profile.id='00e36000001WjFyAAK' AND IsActive = true limit 1];
System.runAs(usr) {
list<string> ss = new list<string>();
case cs = new case();
cs.recordtypeid = ASNTechCaseRecordTypeId;
cs.contactid=c.id;
cs.accountid=a.id;
insert cs;
ss.add(cs.id);
.
.
Remaining code as Above.
..
insted of using System.runAs(usr) replace Test.startTest(); and "Test.stopTest();" like below,
Test.startTest();
list<string> ss = new list<string>();
case cs = new case();
cs.recordtypeid = ASNTechCaseRecordTypeId;
cs.contactid=c.id;
cs.accountid=a.id;
insert cs;
ss.add(cs.id);
.
.
Test.stopTest();
Thanks
karthik