0

I'm trying to find a way to disallow users from adding Leads to campaigns that are inactive. My current workaround is through an Apex trigger that removes a lead from any inactive campaign when the lead is edited, but it would be great to disallow users from adding leads to inactive campaigns up front. Is there an explicit way to accomplish this?

7
  • Use a trigger to throw an error when it is created with an inactive campaign.
    – dphil
    Jun 24, 2014 at 18:57
  • Is this possible to do on a Lead that already exists? Jun 24, 2014 at 19:16
  • Well, what is your exact use case? Does the lead already exist and then someone tries to attach it to a campaign? Or are you talking about trying to go back and catch all the ones that already skipped this criteria? Giving us enough detail lets us know what exactly your problem is.
    – dphil
    Jun 24, 2014 at 19:21
  • I don't want users to be able to add an existing lead to an inactive campaign. Ideally, users wouldn't be able to access/see inactive campaigns, but I'm fine with throwing an error if it's added to an inactive campaign. Jun 24, 2014 at 19:27
  • 1
    This is definitely something that can be done in a trigger. You would need to query for the related Campaigns and check the status. If it's inactive you can do something like yourLead.CampaignId.addError('Inactive Campaign');
    – dphil
    Jun 24, 2014 at 19:35

1 Answer 1

1

A validation rule should work: (ISNEW()&&NOT(Campaign.IsActive)) || (ISCHANGED(CampaignId) && NOT(Campaign.IsActive))

0

You must log in to answer this question.

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