Quantcast
Channel: Active questions tagged fields - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 59

Setting checkbox fields via trigger

$
0
0

I'm in the process of learning Apex triggers, and I've been attempting to write code that runs before updating a field.

The code should change the Primary Contact field to FALSE if the checkbox field No Longer with Company is TRUE and 'Primary Contact' is also TRUE.

However I keep running into some errors on line 3. Could someone help me understand what is missing?

Here's the code I have:

trigger UpdatePrimaryContact on Contact(before update) {    for (Contact record : Trigger.new) {        if (record.No_Longer_with_company__c && record.Primary_Contact__c {            record.Primary_Contact__c = false;        }    }}

Viewing all articles
Browse latest Browse all 59

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>