1

I am having a "global with sharing" class which has a method(which is webservice static) that is called from Javascript. This javascript is defined on click of a button on opportunity object.I am clicking this button.

Now, inside this method I am reteiving various fields of opportunity object and modifying one of these fields. After this, I am updating that opportunity as:

Database.SaveResult updateResult = Database.update(Opp, false);

Here, "AllOrNone" is put as "false" meaning partial update will be success.

Now I have certain fields that are violating some validation rules of opportunity, however the field that I had updated is consistent with requirement. So when this update happens, in database.error I get the message whatever the validation rule message was defined for opportunity

For Ex:

Errors: Database.Error[getFields=(SampleField__C);getMessage=Total amount should be >100000.;getStatusCode=FIELD_CUSTOM_VALIDATION_EXCEPTION;]

However, the field that I had updated did not get updated and still shows old value on UI and in Database.

Is this expected behavior? If yes then won't be putting "AllOrNone" as False be ineffective in this case? And if yes, then how to update that field successfully without having to handle the validation errors.(I have requirement that these validation errors should be ignored in a specific case that I am handling)

1 Answer 1

4

In order to bypass validation rules for that specific scenario or on the basis of a specific field, you need to include that field in your validation rule formula.

Also, partial update means that if you are working on 10 records suppose, and out of 10, 5 are successfully updated and 5 have some errors, then the ones which are successfully updated would only be processed and the remaining will have errors associated with them.It is not at all related to a record level partial update(updating some fields and rest remain same inspite of some validation rule error....this can never happen)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .