Check whether specified date is a holiday

Updated by Van Glass on

This custom trigger function checks to see if the supplied date matches against a list of holidays in defined input file. 

Two method signatures are provided, one for using the current system date, and a second for using a user supplied date.  Dates are formatted in MM/dd/YYYY format with a single date per line in input file.

See How to Create Custom Trigger Functions for details on installation.

Downloads

Source code and build instructions

How to check whether a day is holiday

 Let me now show you how to implement that.

 

1. Make sure you have IsHoliday function installed in the server

Before creating a custom trigger function IsHoliday, you need to have build installed in the server where JSCAPE MFT Server is running.

 

2. Create a Trigger using IsHoliday Function

Before creating a trigger, let us consider an example that a set of actions should not be performed on holidays. For example, Consider that a set of files (.zip files) should not be uploaded to external server on holidays.

In order to make this happen as a first step need to create a excel file where the column has list of date (Holidays) in MM/dd/YYYY format. Consider that you have the below values in a file named as isholiday.xlsx.

 

isholiday_img1

 

The above sheet shows that holiday falls on date 22/11/2018, 14/08/2018 and 07/07/2018. So as per the mapping in the sheet named isholiday.xlsx the .zip files should not be uploaded to the external server.

Once the excel document is ready, proceed to create a trigger.

Now login into admin console of JSCAPE MFT Server > Triggers and Click Add to create a Trigger.Give the trigger a Name and then select the File Upload event type from the drop-down list. as we need to upload the file to JSCAPE MFT Server.

 

isholiday_img2

 

Click Next to Step 2 where a condition can be set to execute the trigger, Now Click Functions button to select the IsHoliday function

 

Select the IsHoliday(file) from the Functions drop down. 

 

isholiday_img3

 

If the function not found read the build instructions (Source code and build instructions) . You will also find a another function named IsHoliday(file,date) in the list. The use of these functions are mentioned below.

  • IsHoliday(file) - Returns true if file contains current date, false otherwise.

Need to check in a different day; Do not worry we have the below method

  • IsHoliday(file,date) - Returns true if specified file contains date, false otherwise. The first argument is path to holiday file and second argument is date in milliseconds.

 

In this example, we use IsHoliday(file) function to check the day on file uploaded is mapped as holiday or not. Input the expression as below. The below expression returns true if the day on the file uploaded is mapped else false

"IsHoliday(LocalPath)=false"

 

isholiday_img4

Click Next to proceed. In step 3 an action has to be added to upload the files (.zip) to external server.

Add an action on click Add button and select the action "SFTP Regex File Upload" from drop down list. Below blog will help you more in understanding Regular expression in JSCAPE MFT Server.

Using Regular Expression in Triggers Part 1 

Using Regular Expression in Triggers Part 2

 

isholiday_img5

 

Click Ok to Proceed and fill out the parameters required for the action.

 

isholiday_img6

Click Ok to save the settings. That's it. Now you know how to use the custom function IsHoliday and not to process the action in Triggers on holidays

 

Downloads

Download JSCAPE MFT Server

Topics: JSCAPE MFT, SFTP, Functions

Get A Free Trial

Download Your 7-Day Free Trial Version of JSCAPE MFT Server.

Get Your Free Trial