
To write a trigger on a field of custom object you need to create trigger on that custom object. As Per your requirement you want to fire this trigger if the field have the certain value. So you need to update below code as per you custom object Name and field Name:
Full Answer
How to write a trigger on a custom sobject (vehicle__C)?
As you want to write trigger on your custom sobject (Vehicle__c) if the record is existing it should display a system.debug (Record is already exisiting) message in the log file. Step 1 ==> Write a Trigger for your custom object specifying the condition as below.
How to find the ID of an event object in Salesforce?
Welcome to Salesforce/Apex development! If you check out the Salesforce.com documentation, you'll see that the field you're looking for on the Event object is called WhatId: WhatId: ID of a related Account, Opportunity, Campaign, Case, or custom object.
How to create a test class for a custom object?
Step 1 ==> Write a Trigger for your custom object specifying the condition as below. Step 2 ==> Come to your developer console and create a test class as below. Step 3 ==> Copy the below code into your anonymous block and execute.

Can we write trigger on custom object in Salesforce?
Apex triggers enable you to perform custom actions before or after changes to the Salesforce records, such as insertions, updates, or deletions. The trigger code is stored as metadata under the custom object. window appears. Enter a name for the trigger.
How do I create an object trigger in Salesforce?
Configure Objects and TriggersFrom Sales or Service Cloud, click Setup.Under Build, click Customize.Select desired object.Click Triggers.Click New.In the Apex Trigger window, select Is Active.Enter the following code, substituting the desired object name where indicated with Object Name. ... Save the trigger.More items...
How do I write a trigger to a file object in Salesforce?
While creating the trigger on Attachment object, we should be careful as it will be triggered for any Standard or Custom Object with Attachments....Add trigger on Attachment and NoteInside Developer Console Click "File"New | Apex Trigger.Give a name and select "Attachment" or "Note" SObject from drop down.
How do you control trigger using custom settings?
All you need to do is setup a hierarchy custom setting object by going to Setup -> Custom Settings and then create Checkbox (Boolean) fields for each object you have a trigger for that you may want to bypass. After you're done setting that bad boi up.
How do I add a trigger to a record?
To create a trigger, we need to change the delimiter. Inserting the row into Table1 activates the trigger and inserts the records into Table2. To insert record in Table1. To check if the records are inserted in both tables or not.
What are the types of triggers in Salesforce?
Here is a list of trigger events in salesforce:before insert.before update.before delete.after insert.after update.after delete.after undelete.
Can we write trigger on ContentDocumentLink?
In Lightning Experience, both the ContentDocument and related ContentDocumentLink records are deleted, and by design Salesforce only fires the trigger on ContentDocument, not the trigger on ContentDocumentLink.
How do you write a trigger attachment?
Trigger on Attachment in SalesforceGo to File -> New -> Apex Trigger.Select name of SObject and enter name of trigger.Click on submit button. In this way we can create trigger on attachment. In similar way we can also create trigger using force.com IDE.
How do I enable a trigger in Salesforce?
Note Permission for Triggered Sends Configuration is required to complete these tasks.From Sales or Service Cloud, click Setup.Under Build, click Customize.Select desired object.Click Triggers.Click New.In the Apex Trigger window, select Is Active.More items...
Can we write trigger on custom setting?
Its not possible to write a trigger on the Custom Settings. Though you are able to write a trigger on Custom Settings..you will not be able to Update the Records as Custom Settings do not have the Lookup Fields to associate your Custom Setting with any of the Objects(be it Standard or Custom).
Can we use custom setting in trigger?
So your custom settings will store the trigger name and its status in IsActive checkbox. Then in your apex trigger, add an IF condition at the top to check if the Trigger status in Custom settings is TRUE, only then run the entire apex trigger code. yes, i can try this.
Can we write trigger on custom metadata?
It's not possible to write a trigger/Workflow on custom metadata object. If you need trigger you will need to use custom object .