Giving me error as: {"code":"invalidDateFormat","message":"Invalid date format. Valid date format is

deepikamara
Tera Contributor

Hi,

 

In pre processing script : I am taking current and past 3 days date and passing it in response body as shown in the SS

-------------------------------------------------

(function execute(inputs, outputs) {
var now = new GlideDateTime();
    var threeDaysAgo = new GlideDateTime();
    threeDaysAgo.addDaysUTC(-3);  // Subtract 3 days
    outputs.updatedDateTo = now.getValue().replace(' ', 'T') + 'Z';
    outputs.updatedDateFrom = threeDaysAgo.getValue().replace(' ', 'T') + 'Z';
    gs.info("testing dates::"+typeof(outputs.updatedDateTo)+"::"+typeof(outputs.updatedDateFrom));
})(inputs, outputs);
 Giving me ouput: 2024-11-25T12:11:11Z
 
In Rest step:
---------------------------------------
deepikamara_0-1739276915191.png

 

Giving me error as: {"code":"invalidDateFormat","message":"Invalid date format. Valid date format is YYYY-MM-DDThh:mm:ssZ."}

 

But if i give custom date it is working fine

deepikamara_1-1739277139203.png

Can you please help me here.

12 REPLIES 12

@deepikamara 

it means logic is correct. the output variables are of type string.

the flow action output to which these output variables are mapped are also of type string?

share the complete screenshots.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

deepikamara_0-1739283523389.png

 

deepikamara_1-1739283556531.pngdeepikamara_2-1739283624190.png

 

@deepikamara 

both the output variables are in Step 1 since you are using the script there and then in next step using that in REST Step

there the type should be String

Did you change that?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

my output type is string only

@deepikamara 

share the output type for Step 1

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader