1

I want to create validation rule on Object 1 to check date on another custom object Object 2. The Object 1 has a look-up field to Object 2. I want to compare create date of record of Object 1 and custom date field of Object 2. I try validation rule on Object 1 but can't make it work. Here is what I tried:

 $ObjectType.SCMC__Purchase_Order__c.Fields.SCMC__End_Date__c <  CreatedDate 

And I get this error message:

Error: Incorrect parameter type for operator '<'. Expected Object, received DateTime

Is this kind of validation possible through validation rule?

Thanks

0

Assuming you are using the standard Salesforce UI to build your validation rule, you should be able to use a cross object formula to access the related object (Object 2).

This should look something like:

SCMC__Purchase_Order__r.SCMC__End_Date__c < CreatedDate

If you were using standard objects, say from Opportunity to Account, it'd look like this:

Account.CreatedDate < CreatedDate
1
  • Thanks, but still the same error: Error: Incorrect parameter type for operator '<'. Expected Date, received DateTime. Should I use something like DATEVALUE? I tried but without success.
    – mascot
    Apr 30 '15 at 8:42
0

Considering the custom field, which is of type date and CreatedDate being Datetime, you need to modify your formula a bit to make it as:

SCMC__Purchase_Order__r.SCMC__End_Date__c < DATEVALUE(CreatedDate)

DATEVALUE returns the date part of CreatedDate, enabling you to compare the two fields.

Hope this helps!

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.