- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-30-2021 11:21 PM
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:
Output variable:
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));
- 1,669 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
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
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
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.