Support of JQuery has taken up the Sage CRM customization to the higher level as JQuery has wide range of built in functions as well as its syntax to manipulate DOM elements reduces lines of code which is something every developer will like.
New Stuff: Adding Documents Tab to Leads in Sage CRM 2014 R2
Working with dates on client side scripts is always been quite difficult. Sage CRM has different date formats which user can set for his own instance in User Preferences. Once user selects date format, all the date fields in CRM shows date in selected date format. Now, one of our customer walked in with the requirement that he needed date format like “24 March 2015 (DD Month YYYY)”. How this can be done?
With little tweaking with JQuery it was possible to display dates in said format. Here is how this can be done. We can get current user’s date format using CurrentUser object of client side API. Below is the syntax for the same.
<snippet>
//’Get user date format
var CRM_USER_DATEFORMAT=””;
CRM_USER_DATEFORMAT=new String (CurrentUser.userpref_dateformat);
</snippet>
With this we will be able to identity dateformat of the date being displayed on the screen. Now, you need to write a function which will take date as input and return date in mm/dd/yyyy format. Below link would be useful for date conversion.
Once you have date converted in mm/dd/yyyy format, JQuery formatdate function can be used to get date in required format. Below is syntax for the same.
<snippet>
var formatted_date = $.datepicker.formatDate(‘dd M yy’, new Date(<date in mm/dd/yyyy format>));
</snippet>
Above function will return date in 24 March 2015 format if 03/24/2015 is passed as a parameter. This way we can format dates in required format. In Sage CRM, this function is to be called on the screen in view mode so that date will be displayed in new date format on summary pages. While on edit screen date will be displayed in user date format. Hope you will use this.
Happy scripting!!!
Also Read –
1. Set Default Value for Date Field through Script
2. Default quote expiration/Delivery date setting in Sage CRM
3. Setting Default Date Time while progressing through Sage CRM Workflow
4. Disable Date Time Picker in Sage CRM v7.2
5. Print Current Date on Mail Merge Document in Sage CRM
Pingback: wing888
Pingback: Darknet Market
Pingback: แผ่นปูทางเดิน
Pingback: Destination Wedding in France