{"id":388,"date":"2020-08-30T00:29:30","date_gmt":"2020-08-29T18:59:30","guid":{"rendered":"https:\/\/blog.techcrm.in\/?p=388"},"modified":"2024-11-20T15:05:26","modified_gmt":"2024-11-20T09:35:26","slug":"how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/","title":{"rendered":"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script"},"content":{"rendered":"\n<p>Greetings from TechCRM!<\/p>\n\n\n\n<p>Here is an code snippet how SugarCRM parse an Email Template.<\/p>\n\n\n\n<p>Let&#8217;s have an example<\/p>\n\n\n\n<p>Here I have created email template from Emails-&gt;Create Email Template<\/p>\n\n\n\n<p>Template body :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello $contact_name,\nGreetings from TechCRM.\nHere we have example of some variable.\nFirst Name :\t$contact_first_name\nLast Name :\t$contact_last_name\nEmail :\t$contact_email1\nThanks\n$contact_user_full_name\n\n$contact_user_phone_mobile<\/code><\/pre>\n\n\n\n<p>any any_name.php<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$template_name = 'Greetings from TechCRM';\nrequire_once('modules\/EmailTemplates\/EmailTemplate.php');\n$template = new EmailTemplate();\n$template->retrieve_by_string_fields(array('name' => $template_name,'type'=>'email'));\n\n$oContact = new Contact();\n$oContact->retrieve(\"36CharacterContactID\");  \/\/Contact ID\n\n\/\/Parse Subject If we used variable in subject\n$template->subject = $template->parse_template_bean($template->subject,$oContact->module_dir, $oContact);\n\n\/\/Parse Body HTML\n$template->body_html = $template->parse_template_bean($template->body_html,$oContact->module_dir, $oContact);\n\n\n\/\/Here you will have a result\nprint \"&lt;pre>\";\nprint_r(from_html($template->body_html));<\/code><\/pre>\n\n\n\n<p>Output of script will be this.<br>Michael Servetnick is the name of contact which i used at time of contact retrieve.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nHello Sallie Elzey,\nGreetings from TechCRM.\nHere we have example of some variable.\nFirst Name :\tMichael \nLast Name :\tServetnick \nEmail :\texample-sugarcrm@techcrm.in\nThanks\nNavin Rakhonde<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note :<\/strong><\/p><cite><em>1.&nbsp;Here, &lt;modulename&gt; means the module name you see in the URL, for example, Contacts, Leads, Accounts, etc.<\/em><br><em>2. &lt;any_name&gt;&nbsp;means anything&nbsp;as per your requirements<\/em><\/cite><\/blockquote>\n\n\n\n<p>Hope you find this blog post helpful.<\/p>\n\n\n\n<p>Feel free to add comments and queries, that helps us to improve the quality of posts.<\/p>\n\n\n\n<p>You can contact us at&nbsp;<a rel=\"noreferrer noopener\" href=\"mailto:contact@urdhva-tech.com\" target=\"_blank\">info@techcrm.in<\/a><\/p>\n\n\n\n<p>Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Greetings from TechCRM! Here is an code snippet how SugarCRM parse an Email Template. Let&#8217;s have an example Here I have created email template from Emails-&gt;Create Email Template Template body : any any_name.php Output of script will be this.Michael Servetnick is the name of contact which i used at time of contact retrieve. Note : [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[83,97,96,12,13],"class_list":["post-388","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-email","tag-email-template","tag-parse","tag-sugarcrm","tag-suitecrm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script - TechCRM<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script - TechCRM\" \/>\n<meta property=\"og:description\" content=\"Greetings from TechCRM! Here is an code snippet how SugarCRM parse an Email Template. Let&#8217;s have an example Here I have created email template from Emails-&gt;Create Email Template Template body : any any_name.php Output of script will be this.Michael Servetnick is the name of contact which i used at time of contact retrieve. Note : [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-29T18:59:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-20T09:35:26+00:00\" \/>\n<meta name=\"author\" content=\"Navin Rakhonde\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Navin Rakhonde\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/\",\"name\":\"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2020-08-29T18:59:30+00:00\",\"dateModified\":\"2024-11-20T09:35:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/\",\"name\":\"TechCRM\",\"description\":\"Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\",\"name\":\"Navin Rakhonde\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"caption\":\"Navin Rakhonde\"},\"sameAs\":[\"https:\/\/www.techcrm.in\/\"],\"url\":\"https:\/\/www.techcrm.in\/blogs\/author\/navin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script - TechCRM","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:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/","og_locale":"en_US","og_type":"article","og_title":"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script - TechCRM","og_description":"Greetings from TechCRM! Here is an code snippet how SugarCRM parse an Email Template. Let&#8217;s have an example Here I have created email template from Emails-&gt;Create Email Template Template body : any any_name.php Output of script will be this.Michael Servetnick is the name of contact which i used at time of contact retrieve. Note : [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/","og_site_name":"TechCRM","article_published_time":"2020-08-29T18:59:30+00:00","article_modified_time":"2024-11-20T09:35:26+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/","url":"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/","name":"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2020-08-29T18:59:30+00:00","dateModified":"2024-11-20T09:35:26+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/how-to-parse-email-template-variable-in-sugarcrm-suitecrm-by-custom-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.techcrm.in\/blogs\/"},{"@type":"ListItem","position":2,"name":"How To Parse Email Template Variable In SugarCRM \/SuiteCRM By Custom Script"}]},{"@type":"WebSite","@id":"https:\/\/www.techcrm.in\/blogs\/#website","url":"https:\/\/www.techcrm.in\/blogs\/","name":"TechCRM","description":"Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc","name":"Navin Rakhonde","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","caption":"Navin Rakhonde"},"sameAs":["https:\/\/www.techcrm.in\/"],"url":"https:\/\/www.techcrm.in\/blogs\/author\/navin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/comments?post=388"}],"version-history":[{"count":2,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/388\/revisions"}],"predecessor-version":[{"id":445,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/388\/revisions\/445"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}