Validate lookup-field before create

Posted by smartsysISV on 13-May-2015 11:28

How can I validate (trigger) a lookup-file before create?

This is before the values is "created"?

All Replies

Posted by Ranjana sinha on 14-May-2015 03:55


There is a trigger "Validate Record Data" which can be used with "before create" or "before update" timing option to validate for any lookup field before record creation.

Please let me know your use case so that we can suggest better options.


Ranjana Sinha

Posted by smartsysISV on 14-May-2015 04:19

Yes, this is the trigger I use.

But I can't check the value of a lookup-field because the lookup field is not updated yet.


{RXXXXX#id} is always -1

{} is always ""

{RXXXXX} is always ""

Posted by Ranjana sinha on 14-May-2015 05:34

The trigger works such that when user selects the lookup field value and then clicks on save the trigger is evaluated and if the condition is not met an error is thrown.

In your case you have mentioned the lookup field is not populated yet. What does that exactly mean ? Could you please provide some steps so that we can replicate the issue at our end.

Posted by smartsysISV on 14-May-2015 06:04

Yes, I understand how the trigger works.

But I need to specify what I want the trigger to validate.

In this example I want to validate that a lookup-value is selected (not empty).


if ({!}<1) {return "Error"};


if ({!R70031225#id}<1) {return "Error"};

Even If the user has selected a lookup-value, none of the exaples above willreturn a value, and I always got an errer.

Posted by pvorobie on 14-May-2015 11:20

Please try this:

if ("{!R873944}"=="" || "{!R873944}"=="-1") return "ERROR: no X attached";

This thread is closed