Example validation scenario: prevent campaign edits

This example explains how to use validation to prevent specific edits to a campaign.

If you are trying to prevent someone who is editing a campaign from changing the campaign code, you can use a custom campaign validation routine. The routine ensures that the following check is done when the campaign is saved:

new_campaign_code == old_campaign_code

To handle the case when the campaign is first being created, pass to the routine a flag that indicates whether the campaign being validated is new (creation) or existing (edit). If this flag indicates edit, then compare the campaign codes.

The Campaign application sets this flag in the InputValidationData object that it then passes to the plug-in. The plug-in reads the flag when it determines whether the validation is for a new or changed campaign.