• VictorBV
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 12
    Replies

I am trying to deploy some changes I have done in one trigger and in a test class (for testing that trigger), and I receivede this error during deploying.

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, tareaToEvento_AI: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Event_AI: execution of AfterIns...

 

It happens in a test class which hasn't been modified.

 

Why is this happening?

How can I solve it?

 

Thanks very much

Hello,

 

I have to develope a trigger that creates a User when a contact is inserted or when a contact is updated (and insertion or update match certain criteria).

I've already done, but I have no idea how to test it.

 

I explain the problem.

 

In order to create that trigger I had to use a @future method, which executes asynchornous(due to DML on Setup sObjects limitation).

In order to test that trigger I had to insert several contacts and check if result is right according to it was expected, but if I want user to be created as the time I checked the result, those sentences must be between Test.startTest() and Test.stopTest(). No problem so far, I could check insert.

 

The problem is checking update.

In order to update data, I need data to be inserted so I have to put insert between startTest and stopTest.

But in order to check User creation on contact update, I need to put updates sentences between startTest and stopTest.....but, and here is the problem, in a test only one startTest can be used.

 

How can I solve it?

 

Thans very much.

 

Hi,

 

I am provisioning Customer Portal via Apex so I need to create users dinamically.

After some reading and developing I faced this problem that puzzles me.

I got next error executing testing

 

TestUserCreationForContact.singleInserTest277.0System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, La operación DML en el objeto de configuración no está permitida después de actualizar un objeto no configurado (o viceversa): User objeto original: Account: []Class.Utilities.createNominalUser: line 53, column 3 External entry point

 

I show you the method createNominalUser

 

 

  @future  public static void createNominalUser(String alias, String email, String emailEncodingKey, String lastName, String languageLocaleKey, String localesKey, 
ID profile, String timeZonesIdKey, String userName, ID userRole)
{
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = true;
User user = new User(alias = alias, email = email, emailencodingkey = emailEncodingKey, lastname = lastName, languagelocalekey = languageLocaleKey,
localesidkey = localesKey, profileid = profile, timezonesidkey = timeZonesIdKey, username = userName, userRoleId = userRole);

user.setOptions(dmo);
insert user; //line 53
  System.debug('Usuario nominal creado, Id:' + user.Id);
}

 How is that possible?

How can I fix it?

 

 

Hi,

 

I am trying to create a user for a customer portal.

In order to do so I use next code:

 

 

Profile portalProfile = [select id, Name from profile where name='Customer Portal Manager Custom'];

UserRole role = [select id, Name from UserRole where name = :companyName + ' Cliente Usuario'];
User portalUser = new User(alias = contact.UserCode__c, email = email, mailencodingkey = 'UTF-8', lastname = contact.LastName,                                             languagelocalekey= 'es', localesidkey= 'es', profileid = portalProfile.Id, timezonesidkey= 'Europe/Paris', username = userName, userRoleId = role.Id);

 

 

 

Role has been previously created.

I got next error:

 

INVALID_CROSS_REFERENCE_KEY, invalid cross reference id

 

And I think it is beacuse of profile. User is not identified as Portal User so I can not assign a Portal Profile.

But I dont know how to overcome that issue.

 

Someone knows how to do it?

 

I have checked

 

http://blog.sforce.com/sforce/2009/04/provisioning-customer-portal-users-with-apex.html

 

But field User.ContactId does not exist any longer....

 

Thanks in advance

Hi all,

 

I am testing some of my triggers and I realized that real data from salesforce can be used in testing.

Can I somehow avoid that?

I want to avoid using real data because some of my tests fail because uniques key, and I want just to test Insert data, without having to check first which key is not being used.

 

How can I do it?

 

Thanks in advance

Hi all

 

I am trying to Activate Customer Portal for Contacts of an Account with Apex so automatically I can create Users for a new contacts with a trigger just after Account and Contact are inserted, but I dont know how to do it.

 

I have already enabled the Customer Portal and I have created one portal, now I would like to automatically create Roles for an Account when it is inserted so when a Contact for that Account is inserted I can enable Login for Customer Portal for that user.

 

I studied the proccedure and I realize that, when first Contact is enabled to Login in Customer Portal 3 UserRoles and 6 Groups are created, related to the Account. I tried to do that with Apex and I couldnt beacuse RelatedId in Group is read only.

 

How can I do that?

 

Thanks in advance

 

 

I am trying to deploy some changes I have done in one trigger and in a test class (for testing that trigger), and I receivede this error during deploying.

 

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, tareaToEvento_AI: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Event_AI: execution of AfterIns...

 

It happens in a test class which hasn't been modified.

 

Why is this happening?

How can I solve it?

 

Thanks very much

Hello,

 

I have to develope a trigger that creates a User when a contact is inserted or when a contact is updated (and insertion or update match certain criteria).

I've already done, but I have no idea how to test it.

 

I explain the problem.

 

In order to create that trigger I had to use a @future method, which executes asynchornous(due to DML on Setup sObjects limitation).

In order to test that trigger I had to insert several contacts and check if result is right according to it was expected, but if I want user to be created as the time I checked the result, those sentences must be between Test.startTest() and Test.stopTest(). No problem so far, I could check insert.

 

The problem is checking update.

In order to update data, I need data to be inserted so I have to put insert between startTest and stopTest.

But in order to check User creation on contact update, I need to put updates sentences between startTest and stopTest.....but, and here is the problem, in a test only one startTest can be used.

 

How can I solve it?

 

Thans very much.

 

Hi,

 

I am provisioning Customer Portal via Apex so I need to create users dinamically.

After some reading and developing I faced this problem that puzzles me.

I got next error executing testing

 

TestUserCreationForContact.singleInserTest277.0System.DmlException: Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, La operación DML en el objeto de configuración no está permitida después de actualizar un objeto no configurado (o viceversa): User objeto original: Account: []Class.Utilities.createNominalUser: line 53, column 3 External entry point

 

I show you the method createNominalUser

 

 

  @future  public static void createNominalUser(String alias, String email, String emailEncodingKey, String lastName, String languageLocaleKey, String localesKey, 
ID profile, String timeZonesIdKey, String userName, ID userRole)
{
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = true;
User user = new User(alias = alias, email = email, emailencodingkey = emailEncodingKey, lastname = lastName, languagelocalekey = languageLocaleKey,
localesidkey = localesKey, profileid = profile, timezonesidkey = timeZonesIdKey, username = userName, userRoleId = userRole);

user.setOptions(dmo);
insert user; //line 53
  System.debug('Usuario nominal creado, Id:' + user.Id);
}

 How is that possible?

How can I fix it?

 

 

Hi all,

 

I am testing some of my triggers and I realized that real data from salesforce can be used in testing.

Can I somehow avoid that?

I want to avoid using real data because some of my tests fail because uniques key, and I want just to test Insert data, without having to check first which key is not being used.

 

How can I do it?

 

Thanks in advance

Hi all

 

I am trying to Activate Customer Portal for Contacts of an Account with Apex so automatically I can create Users for a new contacts with a trigger just after Account and Contact are inserted, but I dont know how to do it.

 

I have already enabled the Customer Portal and I have created one portal, now I would like to automatically create Roles for an Account when it is inserted so when a Contact for that Account is inserted I can enable Login for Customer Portal for that user.

 

I studied the proccedure and I realize that, when first Contact is enabled to Login in Customer Portal 3 UserRoles and 6 Groups are created, related to the Account. I tried to do that with Apex and I couldnt beacuse RelatedId in Group is read only.

 

How can I do that?

 

Thanks in advance