1

I am trying to update ValidationRules via the tooling API via PATCH and the endpoint: /services/data/v33.0/tooling/sobjects/ValidationRule/{Id}

Every time I try to update a field i get this error and cannot figure it out:

Request Body: {"Description": "testing...."} Error: message: You must provide a valid Metadata field for ValidationFormula errorCode: REQUIRED_FIELD_MISSING

I cannot seem to find the field for ValidationFormula..

UPDATE: I am doing this all via the workbench. I am using the PATCH http method with the following URI and Body:

URI: /services/data/v33.0/tooling/sobjects/ValidationRule/03di00000006TPHAA2
BODY: {"Description": "testing...."}
1
  • can you include your code?
    – Bartley
    Commented Jul 2, 2015 at 13:36

2 Answers 2

3

Only the Metadata and FullName fields can be updated. Description tag should be included in Metadata as below. Also, include other required Metadata fields and its values. Below request successfully updated the validation rule using Workbench PATCH method.

Request Body:

{
    "Metadata": {
        "description": "Updated via WorkBench",
        "active": true,
        "errorConditionFormula": "NOT(ISNULL(TestField__c))",
        "errorMessage": "Test message"
    }
}
1
  • Thanks for this - after posted this question I figured out that PATCH on the ValidationRule does in fact require the 2 fields: "errorConditionFormula" and "errorMessage" Commented Jul 3, 2015 at 16:54
0

Have you all tried disabling a validation rule that is associated with an object which is part of a managed package?

For example:

{ "Metadata": {
    "active":  false,
    "errorConditionFormula": "ISPICKVAL(PRIORVALUE(somecolumn),'Completed') && !( ISPICKVAL(somecolumn,'Completed') || ISPICKVAL(somecolumn,'Cancelled') )",
    "errorMessage": "Error updating somecolumn."
  }
}

I received the error:

[
  {
"message": "Cannot modify managed object: entity=ValidationFormula, component=03d6A000000Jp0U, field=ValidationFormula, state=installed: newValue='ISPICKVAL(PRIORVALUE(somecolumn),'Completed') && !( ISPICKVAL(somecolumn,'Completed') || ISPICKVAL(somecolumn,'Cancelled') )', oldValue='ENCODED:[treatNullAsNull]ISPICKVAL(PRIORVALUE({!ID:00N6A00000694uR}),'Completed') && !( ISPICKVAL({!ID:00N6A00000694uR},'Completed') || ISPICKVAL({!ID:00N6A00000694uR},'Cancelled') )'",
"errorCode": "CANNOT_MODIFY_MANAGED_OBJECT",
"fields": [],
}
],

Any insight would be appreciated.

Thanks!

1
  • Hi, Richard, and welcome to SFSE! In order to get an answer to your question, you'll want to ask a new question. Also feel free to search for an answer to see if someone might have already answered this type of question. Finally, please see How to Ask for additional information on how to ask a good question.
    – sfdcfox
    Commented Aug 15, 2017 at 22:01

You must log in to answer this question.

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