Skip to end of metadata
Go to start of metadata

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:

Script Sample
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); 
        

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

 LPS version 9.5 and higher

Environment

All supported installation environments.