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...."}
  • can you include your code? – Bartley Jul 2 '15 at 13:36
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"
    }
}
  • 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" – tauren.kristich Jul 3 '15 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!

  • 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 Aug 15 '17 at 22:01

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.