Formating options print layout (eg. date, integer, part of a field)

Solution
For all users having the same problems. I habe solved all of them and like to show how:

1 Change date format
This can be done by using a custom script (Setup → Customize → Custom script). My next example shows howto create a nice datestring out of an existing date.

custom script:
cur_frm.cscript.custom_refresh = function(doc) {
// define the month names (german here). See the first empty (‘’) entry.
// This is done to easy access the corresponding value to a month
// Arrays always start counting on zero!!!
var myMonths = [‘’,‘Januar’,‘Februar’,‘März’,‘April’,‘Mai’,‘Juni’,‘Juli’,‘August’,‘September’,‘Oktober’,‘November’,‘Dezember’];
var currentMonth;

// get the month out of an existing date field (in this example field transaction_date)
// and change to INT
currentMonth = parseInt(doc.transaction_date.toString().substring(5,7));

// set the result in a text field. Resulting format “DD. MMMM YYYY”
doc.myNiceDateField = doc.transaction_date.toString().substring(8,10) + '. ’ + myMonths [currentMonth] + ’ ’ + doc.transaction_date.toString().substring(0,4);
}

2 Format of currency
The format of the currency values can be defined in the system settings (Setup → Settings → System Settings → Field “Number format”. But if you have currency fields on a form, the format of the currency is used instead. If you like to change the number format of the currency you have to configure this using currency settings (Setup → Accounts → Currency). Within the currency you can define the number format of any currency in detail by changing the number format of the currency itself.

3 Cut details of an existing string
This can be done by using a custom script (Setup → Customize → Custom script). My next example uses a part of the counting number (doc_name) of a form, (Example: doc_name = SO2015-1234, expected result “1234”). I like to add a prefix and use the number part only and save it to another field. To get the result we have to cut out the number part. This can be done with "substring(startINT,endINT). !!! Attention: startINT starts counting at 0 and endINT is not included !!!

custom script:
cur_frm.cscript.custom_refresh = function(doc) {
doc.myNewField = ‘Prefix-’ + ‘-’ + doc.name.toString().substring(7,11)
}

Hope that helps anybody.
Thilo

@rmehta: Can you please close this question. Thanks

3 Likes