{"id":5996,"date":"2013-12-07T11:09:48","date_gmt":"2013-12-07T11:09:48","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/?p=5996"},"modified":"2013-12-07T11:09:48","modified_gmt":"2013-12-07T11:09:48","slug":"retrieve-primary-keys-in-tls","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/","title":{"rendered":"Retrieve Primary Keys in TLS"},"content":{"rendered":"<p style=\"text-align: justify;\">Table Level Scripts (TLS) are an alternative method of creating SQL triggers that can be performed in Sage CRM system. Table Level Script (TLS) are used to perform various operations after inserting records, updating or deleting records in Sage CRM. To perform operations, it is necessary to fetch the primary ID of the\u00a0current entity in TLS. However, most of the users find it difficult to retrieve the Primary Keys in TLS. To find the resolution, please continue to read below:<\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #993300;\"><b><i>The New Stuff: <\/i><\/b><\/span><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/11\/30\/creating-order-with-existing-opportunity-in-gumu-integration\/\" target=\"_blank\">Creating Order with existing Opportunity in GUMU&#x2122; Integration<\/a><\/p>\n<p style=\"text-align: justify;\">Consider an example where you want to retrieve Primary entity ID of Cases table and use it for further development using a Table Level Script. Here are the ways with which you can achieve the same.<\/p>\n<p><b>Way 1:<br \/>\n<\/b>\/\/\u2019Get Case ID<br \/>\nvar sCaseid = new String(CRM.GetContextInfo(&#8220;Case&#8221;,&#8221;case_caseid&#8221;));<br \/>\n\/\/\u2019Get Case Data<br \/>\nobjCase = CRM.FindRecord(\u201ccases\u201d,\u201dcase_caseid=\u201d+ sCaseid)<br \/>\n<b>Way 2:<br \/>\n<\/b><span style=\"line-height: 1.6em;\">\/\/\u2019Get Case ID<br \/>\n<\/span>var sCaseid = new String(Values(&#8220;case_caseid&#8221;));<br \/>\n\/\/\u2019Get Case Data<br \/>\nobjCase = CRM.FindRecord(\u201ccases\u201d,\u201dcase_caseid=\u201d+ sCaseid)<br \/>\n<b>Way 3:<br \/>\n<\/b><span style=\"line-height: 1.6em;\">Now if you print WhereClause variable in the TLS, you will get the value something as shown below.<br \/>\n<\/span>case_caseid=&lt;&lt; Primary field value of Cases entity&gt;&gt;<br \/>\n<span style=\"line-height: 1.6em;\">In this case, you can fetch case data as follows.<br \/>\n<\/span>\/\/\u2019Get Case Data<br \/>\nobjCase = CRM.FindRecord(\u201ccases\u201d, WhereClause)<br \/>\n<span style=\"line-height: 1.6em;\">All the above syntaxes can be used on PostInsert, Update and Delete functions of TLS. Moreover, the same set of instructions can be applied for other similar entities.<\/span><br \/>\n<strong>About Us<\/strong><\/p>\n<p style=\"text-align: justify;\">Greytrix is one stop solution provider for Sage ERP and Sage CRM needs. We provide complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0has some unique integration solutions for Sage CRM with Sage ERP\u2019s (<a href=\"http:\/\/www.greytrix.com\/Product\/81\/Sage-CRM\/GUMU---Sage-ERP-X3-Integration\">Sage X3<\/a>,\u00a0<a href=\"http:\/\/www.greytrix.com\/Product\/18\/Sage-CRM\/GUMU---Sage-100-ERP-Integration\">Sage 100<\/a>,\u00a0<a href=\"http:\/\/www.greytrix.com\/Product\/19\/Sage-CRM\/GUMU---Sage-500-ERP-Integration\">Sage 500<\/a>\u00a0and\u00a0<a href=\"http:\/\/www.greytrix.com\/Product\/93\/Sage-CRM\/GUMU---Sage-300-ERP-Integration\">Sage 300<\/a>).We also offer best-in-class\u00a0<a href=\"http:\/\/www.greytrix.com\/product\/erp-development\/sage-x3\">Sage ERP<\/a> and <a href=\"http:\/\/www.greytrix.com\/product\/crm-development\/sage-crm\">Sage CRM<\/a> customization and development services\u00a0to\u00a0Business\u00a0Partners,\u00a0End\u00a0Users and Sage PSG worldwide.<a href=\"http:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0helps in\u00a0<a href=\"http:\/\/www.greytrix.com\/Product\/68\/Sage-CRM\/ACT-to-Sage-CRM-Migration\">migrating to Sage CRM from ACT<\/a>,\u00a0<a href=\"http:\/\/www.greytrix.com\/Product\/26\/Sage-CRM\/Goldmine-to-Sage-CRM-Migration\">Goldmine<\/a>\u00a0and other CRM\u2019s.<\/p>\n<p>For more information on our integration solutions, please contact us at\u00a0<a href=\"mailto:sage@greytrix.com\">sage@greytrix.com<\/a>. We will be glad to assist you.<br \/>\n<b><b>Also Read:<br \/>\n<\/b><\/b>1)\u00a0<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/11\/29\/3-easy-steps-to-add-sage-crm-custom-entity-in-advanced-find\/\" target=\"_blank\">Quick look on Sage CRM tables<br \/>\n<\/a>2)\u00a0<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2009\/07\/06\/writing-table-level-script-is-a-hectic-job-try-this-instead\/\" target=\"_blank\">Writing Table Level Script a hectic job? \u2013 Try this instead\u2026<\/a><br \/>\n3)\u00a0<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/10\/25\/retrieve-deleted-records-in-sage-crm\/\" target=\"_blank\">Retrieve deleted records in Sage CRM<\/a><br \/>\n4)\u00a0<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/02\/22\/how-to-access-views-of-different-database-in-crm\/\" target=\"_blank\">How to access views of Different Database in CRM<\/a><br \/>\n5)\u00a0<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2011\/10\/11\/remove-secterr-field-from-secondary-entity\/\" target=\"_blank\">Remove Secterr Field from Secondary Entity<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table Level Scripts (TLS) are an alternative method of creating SQL triggers that can be performed in Sage CRM system. Table Level Script (TLS) are used to perform various operations after inserting records, updating or deleting records in Sage CRM. To perform operations, it is necessary to fetch the primary ID of the\u00a0current entity in\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[83,293,332,336,337,393],"tags":[2010,2030,2031,2033,2403,2450],"class_list":["post-5996","post","type-post","status-publish","format-standard","hentry","category-crm72","category-primary-keys","category-sage-crm","category-sage-crm-7-1-sp2","category-sage-crm-7-2","category-tables","tag-sage-crm","tag-sage-crm-7-0","tag-sage-crm-7-1","tag-sage-crm-7-2","tag-table-level-script","tag-tls"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Retrieve Primary Keys in TLS - Sage CRM \u2013 Tips, Tricks and Components<\/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.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Retrieve Primary Keys in TLS - Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"og:description\" content=\"Table Level Scripts (TLS) are an alternative method of creating SQL triggers that can be performed in Sage CRM system. Table Level Script (TLS) are used to perform various operations after inserting records, updating or deleting records in Sage CRM. To perform operations, it is necessary to fetch the primary ID of the\u00a0current entity in\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/\" \/>\n<meta property=\"og:site_name\" content=\"Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"article:published_time\" content=\"2013-12-07T11:09:48+00:00\" \/>\n<meta name=\"author\" content=\"greysagecrm\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"greysagecrm\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/\",\"name\":\"Retrieve Primary Keys in TLS - Sage CRM \u2013 Tips, Tricks and Components\",\"isPartOf\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\"},\"datePublished\":\"2013-12-07T11:09:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Retrieve Primary Keys in TLS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\",\"name\":\"Sage CRM \u2013 Tips, Tricks and Components\",\"description\":\"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\",\"name\":\"greysagecrm\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g\",\"caption\":\"greysagecrm\"},\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Retrieve Primary Keys in TLS - Sage CRM \u2013 Tips, Tricks and Components","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.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/","og_locale":"en_US","og_type":"article","og_title":"Retrieve Primary Keys in TLS - Sage CRM \u2013 Tips, Tricks and Components","og_description":"Table Level Scripts (TLS) are an alternative method of creating SQL triggers that can be performed in Sage CRM system. Table Level Script (TLS) are used to perform various operations after inserting records, updating or deleting records in Sage CRM. To perform operations, it is necessary to fetch the primary ID of the\u00a0current entity in\u2026 Read More &raquo;","og_url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/","og_site_name":"Sage CRM \u2013 Tips, Tricks and Components","article_published_time":"2013-12-07T11:09:48+00:00","author":"greysagecrm","twitter_card":"summary_large_image","twitter_misc":{"Written by":"greysagecrm","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/","name":"Retrieve Primary Keys in TLS - Sage CRM \u2013 Tips, Tricks and Components","isPartOf":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website"},"datePublished":"2013-12-07T11:09:48+00:00","author":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f"},"breadcrumb":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/12\/07\/retrieve-primary-keys-in-tls\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/"},{"@type":"ListItem","position":2,"name":"Retrieve Primary Keys in TLS"}]},{"@type":"WebSite","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/","name":"Sage CRM \u2013 Tips, Tricks and Components","description":"Explore the possibilities with Sage CRM insights through our comprehensive blogs. As a leading Sage partner, Greytrix helps businesses maximize their Sage CRM potential with its rich expertise and immense knowledge. Here, you will find blogs that feature expert advice, tips &amp; tricks, best practices, and comprehensive guides on customizing and configuring Sage CRM for your business. Stay informed with our regular updates and expert insights!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f","name":"greysagecrm","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c3b4325cb326e36467f945b9b9adf2bb85e907fe092d42eb36b39743b492e626?s=96&d=mm&r=g","caption":"greysagecrm"},"url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/author\/greysagecrm\/"}]}},"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/5996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/comments?post=5996"}],"version-history":[{"count":0,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/5996\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/media?parent=5996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/categories?post=5996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/tags?post=5996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}