Java Script Basic Sample to Modify Expire Date
Description
This article describes a Java script that calculates a future date, based on a date passed to a field on the label.
Solution
The script parses the date passed to the label and then can be configured to add a specified number of days to the date which is passed into a new field on the label.
The script used in ExpirationDateSample.lwl (attached) is below:
<pre class="syntaxhighlighter-pre" xml:space="preserve">var input = String(label.fields.field.(@name == 'Date_Input').@data);
var twomonth = input.substr(0,2);
var twoday = input.substr(2,2);
var fouryear = input.substr(4,4);
var twoyear = input.substr(6,2);
//define javadate
javadate = new Date(fouryear,(twomonth -1),twoday);
javadate.setDate(javadate.getDate()+3) //today now is set to be 3 days into the future
label.fields.field.(@name=='OutDate').@data=javadate (mailto:.@data=javadate); </pre>
The sample label requires a date format of mmddyyyy, the output is configured to print into a paragraph field which can be modified.
Article Number
2014038
Versions
Loftware Label A label is a design area on the computer screen where a label format is created or edited. Manager / Loftware Print Server versions 9.5.2.0 - 11.1
Environment
All supported installation environments.