• p vr
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

I am getting an error while running the test class , Leads are not getting created in the system ..

 

Test class snipet :


  Lead testLead = Class_Test.createLead('Test Lead', 'Test Company', '02s30000000000dAAB', 'Core');
    testLead.OwnerId = user.Id;
    insert testLead;

    system.assertEquals(testLead.OwnerId, uSBS.Id);  

 ---------------------

Class_Test :

 

public static Lead createLead(String lastName, String company, Id divId, String status){
   
    Datetime t = Datetime.now();
    Date da = Date.newInstance(t.year(), t.month(), t.day());
    Lead lead = new Lead(LastName = lastName, Company = company, Division = divId, Status = status, Phone = '1234', Start_Date__c = da);
   
    return lead;
  } 

 

Error :

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, EZAssign.CS_Lead: execution of AfterInsert

caused by: System.DmlException: Upsert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, EZAssign.CS_UserInfo: execution of AfterInsert

caused by: System.DmlException: Update failed. First exception on row 0 with id 005e00000012MJJAA2; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): User, original object: Lead: []

(EZAssign)
: []

(EZAssign)


: []

 

 

Any idea how to rectify this error

This list is adding duplicates accounts to the list .

-----------------------------------------------------------------------------------------------------------------------------------------------------


List<ID> accountIds = new List<ID>(); 

 List<Account> accounts = new List<Account>();
        //This is an empty list of contacts which will soon hold all contacts related to the 
                List<Contact> allContacts = new List<Contact>();
                
        //For every contact in our list of contacts...
        for(Contact c: contacts)
        {
            //... if the contact is associated to an account
            if(c.AccountId != null)
            {
                //... add the Contact.AccountId to our list of account Ids.
                accountIds.add(c.AccountId);
            }
           
        }

----------------------------------------------------------<->

 

What Can i use or modify to remove duplicate accounts in the lst .Any help?

I've been researching different ways to determine if an SFDC org has Person Accounts enabled, and most say that the best way to do so was to look to see if the Account.IsPersonAccount field exists, like this.

 

Map<String, Schema.SObjectField> M = Schema.SObjectType.Account.fields.getMap();

string fieldList = '';

for(string field : m.keySet())

{

fieldList += field + ', ';

}

Boolean IsPersonAccountFieldExists = fieldList.contains('ispersonaccount');

 

However, we've found that even in orgs that doesn't have Person Accounts enabled still has the Account.IsPersonAccount field accessible via this code.  In submitting a ticket to support, they said, "IsPersonAccount is the field that exists as default for the account but it's value can be true or false."

 

Hmm...

 

How else can we determine if an organization has Person Accounts enabled, if, by default, every Salesforce org has this field accessible?

Hello,

For the project I'm working on, I need to be able to link one opportunity to one or more others.

 

But when the link is made in one direction, it has to be done in the other.

If A is linked to B, B is automatically linked to A.

 

Looks trivial but your help is welcome!

Thks & Rgds