{"id":9018,"date":"2014-10-22T05:11:49","date_gmt":"2014-10-22T05:11:49","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/?p=9018"},"modified":"2014-10-22T05:11:49","modified_gmt":"2014-10-22T05:11:49","slug":"set-default-value-for-date-field-through-script","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/","title":{"rendered":"Set Default Value for Date Field through Script"},"content":{"rendered":"<p>In Sage CRM customizations, scripting has been proved essential for developers to justify trivial requirements with an ease. It provides the flexibility to set validations or values in field at screen level. Though this can be achieved through few configurations in CRM, but it does not allows you to limit the setting up to certain level. Today I will share one idea of setting default value for Date field.<br \/>\n<span style=\"color: #993300;\"><em><strong>New Stuff:<\/strong><\/em><\/span><a title=\"Using Primary Key Column of an Entity to Search\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/14\/using-primary-key-column-of-an-entity-to-search\/\" target=\"_blank\">Using Primary Key Column of an Entity to Search<\/a><br \/>\nWhile working on Sage CRM, I came across a requirement where I had to set current date and time as default value for one of the date field. I was able to achieve this through field level settings but it reflected the current date value on every screen whenever I progressed with the workflow. However the prerequisite was to set the current date value for one particular screen.<br \/>\nCRM did not provide any such setting at field level but writing one line of code on <strong>\u201cCreate Script\u201d<\/strong> of date field worked like a treat. Please find below code snippet for the same.<br \/>\n<em>DefaultType=6;<\/em><br \/>\nJust paste above code in <strong>\u2018Create Script\u2019<\/strong> section of Date field and it will set current date time value by default for the same field. Refer below given steps to do the same.<br \/>\n1) Go to <strong>Administration || Customization || Leads<\/strong>. (Here I am working with Lead entity, you can use this for any other entity as per your requirement.)<br \/>\n2) Click and open the screen i.e. LeadCustomScreen.<br \/>\n3) Select the date field.<br \/>\n4) Write \u201c<strong><em>DefaultType=6;<\/em><\/strong>\u201d in Create Script section of the same.<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1.jpg\" target=\"_blank\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-9019 size-large\" src=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg\" alt=\"Img1\" width=\"595\" height=\"222\" \/><\/a><br \/>\n5) Update and Save the changes. Now go to new lead screen and will look as shown in below screen shot.<br \/>\n<a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img2.jpg\" target=\"_blank\"><img decoding=\"async\" class=\"aligncenter wp-image-9020 size-large\" src=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img2-1024x356.jpg\" alt=\"Img2\" width=\"595\" height=\"206\" \/><\/a><br \/>\n<span style=\"color: #993300;\"><em><strong>Also Read:<\/strong><\/em><\/span><br \/>\n1) <a title=\"Default quote expiration\/Delivery date setting in Sage CRM\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/09\/25\/default-quote-expirationdelivery-date-setting-in-sage-crm\/\" target=\"_blank\">Default quote expiration\/Delivery date setting in Sage CRM<\/a><br \/>\n2) <a title=\"Setting Default Date Time while progressing through Sage CRM Workflow\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/02\/10\/setting-default-date-time-while-progressing-through-sage-crm-workflow\/\" target=\"_blank\">Setting Default Date Time while progressing through Sage CRM Workflow<\/a><br \/>\n3) <a title=\"Disable Date Time Picker in Sage CRM v7.2\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/11\/12\/disable-date-time-picker-in-sage-crm-v7-2\/\" target=\"_blank\">Disable Date Time Picker in Sage CRM v7.2<\/a><br \/>\n4) <a title=\"Print Current Date on Mail Merge Document in Sage CRM\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/08\/31\/print-current-date-on-mail-merge-document-in-sage-crm\/\" target=\"_blank\">Print Current Date on Mail Merge Document in Sage CRM<\/a><br \/>\n5) <a title=\"Date fields in task and appointment\" href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2013\/02\/04\/date-fileds-in-task-and-appointment\/\" target=\"_blank\">Date fields in task and appointment<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Sage CRM customizations, scripting has been proved essential for developers to justify trivial requirements with an ease. It provides the flexibility to set validations or values in field at screen level. Though this can be achieved through few configurations in CRM, but it does not allows you to limit the setting up to certain\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,103,104,111,155,332,351,352,1],"tags":[924,937,1138,2231,2232,2548],"class_list":["post-9018","post","type-post","status-publish","format-standard","hentry","category-configuration","category-date","category-date-time-picker","category-default","category-fields","category-sage-crm","category-screen-sage-crm","category-script","category-uncategorized","tag-date","tag-default","tag-field","tag-screen","tag-script","tag-value"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Set Default Value for Date Field through Script - 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\/2014\/10\/22\/set-default-value-for-date-field-through-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Set Default Value for Date Field through Script - Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"og:description\" content=\"In Sage CRM customizations, scripting has been proved essential for developers to justify trivial requirements with an ease. It provides the flexibility to set validations or values in field at screen level. Though this can be achieved through few configurations in CRM, but it does not allows you to limit the setting up to certain\u2026 Read More &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/\" \/>\n<meta property=\"og:site_name\" content=\"Sage CRM \u2013 Tips, Tricks and Components\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-22T05:11:49+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg\" \/>\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\/2014\/10\/22\/set-default-value-for-date-field-through-script\/\",\"url\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/\",\"name\":\"Set Default Value for Date Field through Script - Sage CRM \u2013 Tips, Tricks and Components\",\"isPartOf\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg\",\"datePublished\":\"2014-10-22T05:11:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#primaryimage\",\"url\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg\",\"contentUrl\":\"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.greytrix.com\/blogs\/sagecrm\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Set Default Value for Date Field through Script\"}]},{\"@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":"Set Default Value for Date Field through Script - 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\/2014\/10\/22\/set-default-value-for-date-field-through-script\/","og_locale":"en_US","og_type":"article","og_title":"Set Default Value for Date Field through Script - Sage CRM \u2013 Tips, Tricks and Components","og_description":"In Sage CRM customizations, scripting has been proved essential for developers to justify trivial requirements with an ease. It provides the flexibility to set validations or values in field at screen level. Though this can be achieved through few configurations in CRM, but it does not allows you to limit the setting up to certain\u2026 Read More &raquo;","og_url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/","og_site_name":"Sage CRM \u2013 Tips, Tricks and Components","article_published_time":"2014-10-22T05:11:49+00:00","og_image":[{"url":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg","type":"","width":"","height":""}],"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\/2014\/10\/22\/set-default-value-for-date-field-through-script\/","url":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/","name":"Set Default Value for Date Field through Script - Sage CRM \u2013 Tips, Tricks and Components","isPartOf":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#primaryimage"},"image":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#primaryimage"},"thumbnailUrl":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg","datePublished":"2014-10-22T05:11:49+00:00","author":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/#\/schema\/person\/e7ff1c8f4763b47730d6bc5e74d59c1f"},"breadcrumb":{"@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#primaryimage","url":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg","contentUrl":"http:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-content\/uploads\/2014\/10\/Img1-1024x383.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/2014\/10\/22\/set-default-value-for-date-field-through-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/"},{"@type":"ListItem","position":2,"name":"Set Default Value for Date Field through Script"}]},{"@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\/9018","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=9018"}],"version-history":[{"count":0,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/posts\/9018\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/media?parent=9018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/categories?post=9018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/sagecrm\/wp-json\/wp\/v2\/tags?post=9018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}