{"id":88848,"date":"2017-07-10T15:53:43","date_gmt":"2017-07-10T15:53:43","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=88848"},"modified":"2021-07-16T12:27:48","modified_gmt":"2021-07-16T12:27:48","slug":"write-basic-trigger-in-apex","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/","title":{"rendered":"Write a Basic trigger in apex"},"content":{"rendered":"\n<p><strong>Trigger<\/strong>, to any mind trained in the art of writing <strong>SQL<\/strong> or <strong>PL-SQL<\/strong>, this word will always ring a bell. As the name suggest it is something which will be fired when an event occurs. In simple words we can say that trigger is just a piece of code which works if anything happens which we have programmed the trigger for, like insert, delete, update, etc. Likewise we have an option to write trigger in <strong>APEX<\/strong> too. And that&#8217;s what we are going to see today. How to write a basic trigger in APEX on insert and update operation.<\/p>\n\n\n\n<div class=\"wk-index-wrap\"><h3 class=\"index-title\">Types Of triggers in APEX<\/h3><\/div><div class=\"margin-bottom-50\">\n<p>APEX provides two types of trigger based on the time of execution:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Before Trigger:<\/strong> These triggers run before the records are inserted, updated, deleted or undeleted in any object. Simply, the trigger runs before the record is provided an id.<\/li><li><strong>After Trigger:<\/strong> These trigger run right after the records are inserted, updated, deleted or undeleted in any object, and before the commit is called.<\/li><\/ul>\n\n\n\n<p>Triggers can also be categorized on the basis of the event for which they occur like insert trigger happens before of after the insert operation, or update trigger occur right after or before update. Upsert operation calls both insert and update triggers. For merge operations the winning record will call before update trigger and the other record will call before and after delete trigger.<\/p>\n<\/div>\n\n\n\n<div class=\"wk-index-wrap\"><h3 class=\"index-title\">APEX Trigger example<\/h3><\/div><div class=\"margin-bottom-50\">\n<p>Now that we have enough information about triggers, let&#8217;s move on to writing a trigger. For this example we will write a trigger to add a &#8216;<strong>code-<\/strong>&#8216; at the beginning of every newly created <strong>product2<\/strong> record&#8217;s product code, if it&#8217;s not empty.<\/p>\n\n\n\n<p>To write the trigger on product2 object go to <strong>Setup | Customize | Products | Triggers:<\/strong> then click on new button<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">trigger changecode on Product2 (before insert) {\n\n    \/**\n     * Webkul Software.\n     *\n     * @category  Webkul\n     * @author    Webkul\n     * @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https:\/\/webkul.com)\n     * @license   https:\/\/store.webkul.com\/license.html\n     **\/\n\n    list&lt;product2&gt; productlist = trigger.new;\n    for(product2 pro:productlist){\n        if(pro.productcode != null &amp;&amp; pro.productcode != &#039;&#039;)\n            pro.productcode = &#039;code-&#039;+pro.productcode;\n    }\n}<\/pre>\n\n\n\n<p>In this code the first line defines the trigger, like the prototype of a function. &#8216;<strong>trigger<\/strong>&#8216; keyword tells that this is a trigger, <strong>changecode<\/strong> is the name of the trigger, and we are writing this trigger on product2. The <strong>before insert<\/strong> tells that this trigger will run before insert of a record. We can add more events by separating them with comma.<\/p>\n\n\n\n<p>The <strong>trigger.new<\/strong> provides the records that are about to be inserted, or updated. Likewise <strong>trigger.old<\/strong> returns the value of records before update or delete. Rest is simple code to update the values of the new records. You&#8217;ll see on thing in this code, that an update command or insert command is missing. This is because the trigger is already a part of the <strong>DML<\/strong> process and hence we do not need to call another DML command, or else there are chances of having and trigger <strong>recursion<\/strong>. So it is always a good habit to avoid DML for the same object in a trigger.<\/p>\n\n\n\n<p>Next up is after trigger, for which we will write a trigger to add a standard price to every new or updated product which does not already have a standard price.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">trigger addprice on Product2 (after insert, after update) {\n\n    \/**\n     * Webkul Software.\n     *\n     * @category  Webkul\n     * @author    Webkul\n     * @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https:\/\/webkul.com)\n     * @license   https:\/\/store.webkul.com\/license.html\n     **\/\n\n    list&lt;product2&gt; prolist = trigger.new;\n    pricebook2 pb= &#091;select id from pricebook2 where isstandard = true];\n    list&lt;pricebookentry&gt; pbe= new list();\n    for(product2 pro: prolist){\n        try{\n            pricebookentry pbe = &#091;select id from pricebookentry where product2id=:pro.id and pricebook2id=:pb.id];\n        }catch(exception e){\n            pbe.add(new pricebookentry(product2id=pro.id,pricebook2id=pb.id,unitprice=100));\n        }\n    }\n    insert pbe;\n}<\/pre>\n\n\n\n<p>The only difference in the way of writing this trigger is the after insert in the place of before insert.<\/p>\n<\/div>\n\n\n\n<div class=\"wk-index-wrap\"><h3 class=\"index-title\">Output<\/h3><\/div><div class=\"margin-bottom-50\">\n<p>Once you have created the triggers, you can see the changes by creating a new product normally. Go to the product tab, click on new and add details.<br><a href=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/1kvq5ll8kie5qao.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"alignnone wp-image-88856 size-full\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/1kvq5ll8kie5qao.jpg\" alt=\"\" width=\"1366\" height=\"662\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/1kvq5ll8kie5qao.jpg 1366w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/1kvq5ll8kie5qao-250x121.jpg 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/1kvq5ll8kie5qao-300x145.jpg 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/1kvq5ll8kie5qao-768x372.jpg 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/1kvq5ll8kie5qao-1200x582.jpg 1200w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" loading=\"lazy\" \/><\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" width=\"1366\" height=\"613\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm.jpg\" alt=\"\" class=\"wp-image-88857\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm.jpg 1366w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm-250x112.jpg 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm-300x135.jpg 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm-768x345.jpg 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm-1200x539.jpg 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/q23chwhvvnkrcnm-604x270.jpg 604w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" loading=\"lazy\" \/><\/a><\/figure>\n\n\n\n<p>As you can see that the product code was updated and a standard price was added too by the triggers that we created<\/p>\n<\/div>\n\n\n\n<div class=\"wk-index-wrap\"><h3 class=\"index-title\">SUPPORT<\/h3><\/div><div class=\"margin-bottom-50\">\n<p>That\u2019s all for how to write a basic trigger, for any further queries feel free to add a ticket at:<\/p>\n\n\n\n<p><a href=\"https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/\">https:\/\/webkul.uvdesk.com\/en\/customer\/create-ticket\/<\/a><\/p>\n\n\n\n<p>Or let us know your views on how to make this code better, in comments section below.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Trigger, to any mind trained in the art of writing SQL or PL-SQL, this word will always ring a bell. As the name suggest it is something which will be fired when an event occurs. In simple words we can say that trigger is just a piece of code which works if anything happens which <a href=\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":144,"featured_media":88906,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1889,1887,1],"tags":[1884,5040,5038,5041,1885,5039],"class_list":["post-88848","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apex","category-salesforce","category-uncategorized","tag-apex","tag-apex-salesforce-trigger","tag-apex-trigger","tag-dml-salesforce","tag-salesforce","tag-trigger"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to write a Basic Trigger in Apex Salesforce for Insert and Update<\/title>\n<meta name=\"description\" content=\"Write a Basic trigger in Apex. Trigger, to any mind trained in the art of writing SQL or PL-SQL this word will always ring a bell.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to write a Basic Trigger in Apex Salesforce for Insert and Update\" \/>\n<meta property=\"og:description\" content=\"Write a Basic trigger in Apex. Trigger, to any mind trained in the art of writing SQL or PL-SQL this word will always ring a bell.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-07-10T15:53:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-16T12:27:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Yathansh Sharma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yathansh Sharma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\"},\"author\":{\"name\":\"Yathansh Sharma\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/2cf74c97cc99e81430138433b2e5a342\"},\"headline\":\"Write a Basic trigger in apex\",\"datePublished\":\"2017-07-10T15:53:43+00:00\",\"dateModified\":\"2021-07-16T12:27:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\"},\"wordCount\":617,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png\",\"keywords\":[\"Apex\",\"apex salesforce trigger\",\"apex trigger\",\"DML salesforce\",\"Salesforce\",\"trigger\"],\"articleSection\":[\"Apex\",\"Salesforce\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\",\"url\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\",\"name\":\"How to write a Basic Trigger in Apex Salesforce for Insert and Update\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png\",\"datePublished\":\"2017-07-10T15:53:43+00:00\",\"dateModified\":\"2021-07-16T12:27:48+00:00\",\"description\":\"Write a Basic trigger in Apex. Trigger, to any mind trained in the art of writing SQL or PL-SQL this word will always ring a bell.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Write a Basic trigger in apex\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/2cf74c97cc99e81430138433b2e5a342\",\"name\":\"Yathansh Sharma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/631dfbfdb0f359990ee300274cf444e7dc7da6005653e2b711d3c9197caa4ab3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/631dfbfdb0f359990ee300274cf444e7dc7da6005653e2b711d3c9197caa4ab3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Yathansh Sharma\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/yathansh-sharma081\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to write a Basic Trigger in Apex Salesforce for Insert and Update","description":"Write a Basic trigger in Apex. Trigger, to any mind trained in the art of writing SQL or PL-SQL this word will always ring a bell.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/","og_locale":"en_US","og_type":"article","og_title":"How to write a Basic Trigger in Apex Salesforce for Insert and Update","og_description":"Write a Basic trigger in Apex. Trigger, to any mind trained in the art of writing SQL or PL-SQL this word will always ring a bell.","og_url":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2017-07-10T15:53:43+00:00","article_modified_time":"2021-07-16T12:27:48+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png","type":"image\/png"}],"author":"Yathansh Sharma","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Yathansh Sharma","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/"},"author":{"name":"Yathansh Sharma","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/2cf74c97cc99e81430138433b2e5a342"},"headline":"Write a Basic trigger in apex","datePublished":"2017-07-10T15:53:43+00:00","dateModified":"2021-07-16T12:27:48+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/"},"wordCount":617,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png","keywords":["Apex","apex salesforce trigger","apex trigger","DML salesforce","Salesforce","trigger"],"articleSection":["Apex","Salesforce"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/","url":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/","name":"How to write a Basic Trigger in Apex Salesforce for Insert and Update","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png","datePublished":"2017-07-10T15:53:43+00:00","dateModified":"2021-07-16T12:27:48+00:00","description":"Write a Basic trigger in Apex. Trigger, to any mind trained in the art of writing SQL or PL-SQL this word will always ring a bell.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/07\/download-7.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/write-basic-trigger-in-apex\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Write a Basic trigger in apex"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/2cf74c97cc99e81430138433b2e5a342","name":"Yathansh Sharma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/631dfbfdb0f359990ee300274cf444e7dc7da6005653e2b711d3c9197caa4ab3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/631dfbfdb0f359990ee300274cf444e7dc7da6005653e2b711d3c9197caa4ab3?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Yathansh Sharma"},"url":"https:\/\/webkul.com\/blog\/author\/yathansh-sharma081\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/88848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/144"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=88848"}],"version-history":[{"count":13,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/88848\/revisions"}],"predecessor-version":[{"id":296555,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/88848\/revisions\/296555"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/88906"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=88848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=88848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=88848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}