The Zurich release has arrived! Interested in new features and functionalities? Click here for more

sushmapinapati
Tera Contributor

ATF - Custom Step Configuration4 - Get Future/Prior Date from current date

Hi,

This Step Config gets Future/Prior Date from current date as per user datetime format

Step Environment: Server Independent

Category: Server

Input variable:

find_real_file.png

 

Output variable:

find_real_file.png

Description generation script:

function generateDescription(step) {
// the global variable 'step' represents the current glide record
var description = gs.getMessage("Future/Prior Date from current date as per user datetime format");
return description;
}
generateDescription(step);

 

Step execution script:

(function executeStep(inputs, outputs, stepResult, timeout) {

var days = inputs.u_future_or_prior_days_to_currentdate;
var MESSAGE_KEY_SUCCESS = "Success: Date information is passed to the output variable";

function logic() {

var timeFormat = gs.getSession().getUser().getDateFormat();
var date = new Date();
date.setDate(date.getDate() + days);
var yyyy = date.getFullYear().toString();
var mm = (date.getMonth() + 1).toString(); // getMonth() is zero-based
var dd = date.getDate().toString();

if (mm <= 9) {
mm = "0" + mm;
}

if (dd <= 9) {
dd = "0" + dd;
}

timeFormat = timeFormat.replace('dd', dd).replace('MM', mm).replace('yyyy', yyyy);
timeFormat = timeFormat + " 00:00:00";

outputs.u_date = timeFormat;
stepResult.setOutputMessage(MESSAGE_KEY_SUCCESS);
stepResult.setSuccess();

}
logic();
}(inputs, outputs, stepResult, timeout));

Comments
Mayank Das3
Tera Contributor

Hello Sushma

 

Thank you for the solution that you provided. This solution was running fine in Quebec but it is not working in Rome version in my PDI.

I tried setting the values for a date field in a record producer on portal. Getting the following error:

FAILURE: Unable to set values, g_form is not defined. A valid form must be open before setting values

find_real_file.png

 

find_real_file.png

 

find_real_file.png

sushmapinapati
Tera Contributor

Hi Mayank,

Custom step run on server, i see custom step is run in step 4 and later the form has to be open after that step. 

Suggestion: Run the custom step first and later start with form opening.

Version history
Last update:
‎10-30-2021 11:21 PM
Updated by: