Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Unable to set date field value from ATF in yyyy:MM:dd HH:mm:ss

SangyM
Tera Contributor

Hi,

 

So, here I am trying to put the value in this scheduled date combo field but everytime it is only putting the yy:MM:dd values instead of my designated format.

This is the code that have written :

(function executeStep(inputs, outputs, stepResult, timeout) {
// Get current datetime and add 48 hours
var gdt = new GlideDateTime();
gdt.addSeconds(48 * 60 * 60); // 48 hours

// Return GlideDateTime object directly (this is what the datetime field expects)
stepResult.setSuccess();
outputs.u_date_after_48_hrs = gdt.getValue(); // returns date in Glide format: yyyy-MM-dd HH:mm:ss
})(inputs, outputs, stepResult, timeout);
 
FYI : it is 48 hours later date.
 
Can someone please help me refractor it?
1 REPLY 1

Shaqeel
Mega Sage
Mega Sage

Hi @SangyM 

 

The field (u_date_after_48_hrs ) may expect a javascriopt date object not a GlideDateTime string, or the atf step may be applying a string formatting mismatch.

 

You should try returning a javascript date object:

(function executeStep(inputs, outputs, stepResult, timeout) {
    // Add 48 hours using JavaScript date
    var now = new Date();
    now.setHours(now.getHours() + 48); // Add 48 hours
 
    // Return JavaScript Date object
    outputs.u_date_after_48_hrs = now;
    stepResult.setSuccess();
})(inputs, outputs, stepResult, timeout);

 

Kindly do let me know if it works.

 

Regards

Shaqeel


***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

***********************************************************************************************************************





Regards

Shaqeel