0

I'm using Java 8 and v 33.0 of the SalesForce API. We are trying to update a single field on a record. Basically we are trying to do it like this

                    final CventSession__c cventSession = new CventSession__c();
                    cventSession.setNewData__c(newData);
                    cventSession.setId(id);

The complete code is below. The issue we're running into is that there's a validation check that's getting called on the SalesForce side that's complaining about the fact that another attribute is empty.

Trigger.CventSessionTrigger: line 19, column 1
...
 
 
CventSessionTrigger: execution of AfterUpdate

caused by: System.DmlException: Update failed. First exception on row 64 with id a1uF0000001Q0WOIA0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [RelatedtoOpportunity__c]

My question is, how do we update only a single attribute of our record and keep everything else the same? The code for how we're updating all of our records is below ...

                final Set<CventSession__c> cventSessions = new HashSet<CventSession__c>();
                for (final SimpleEntry<String, CventSession__c> entry : cventSessionList)
                {
                    final String id = entry.getKey();
                    ...
                    final CventSession__c cventSession = new CventSession__c();
                    cventSession.setNewData__c(newData);
                    cventSession.setId(id);
                    cventSessions.add(cventSession);
                }   // for

                final SaveResult[] saveResults = connection.update(cventSessions.toArray(new CventSession__c[subList.size()]));
                for (final SaveResult saveResult : saveResults)
                {
                    if (saveResult.getErrors().length > 0)
                    {
                        final Error[] errors = saveResult.getErrors();
                        for (int j=0; j< errors.length; j++) {
                            LOG.error("ERROR updating record: " + errors[j].getMessage());
                        }
                    }   // if
                }   // for
0

The issue we're running into is that there's a validation check that's getting called on the SalesForce side that's complaining about the fact that another attribute is empty.

My question is, how do we update only a single attribute of our record and keep everything else the same?

If you have a validation rule written which does not consider which User is updating the record, you won't be able to get past that error.

There are different ways of implementation as how you can bypass a particular validation rule using different mechanism but if not handled/written that way in Salesforce, there's no way using any way that you can update your record without providing that field's value.

0

If a record did not meet the validation criteria before the validation rule was implemented, then this error is expected if you do not update the records that violate the rule, regardless if you specify the field or not. Every time a record is created or updated, all validation rules are evaluated. After implementing a validation rule, always make sure that you update any records that would violate the rule to prevent problems like this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.