Formatting date for Books Recurring Invoice
Hello,
I am writing a function to create a Recurring Invoice from CRM, but am getting an error when trying to set up the Start Date.
In the function, I'm getting a particular date field from the opp > find the next month > get the first day of that month; all of that part works. When I try to pass that value into the Create Recurring Invoice, I get an error
{"code":2,"message":"Invalid value passed for Start Date"}
My code:
- oneMonth = firstEngagementDate.addMonth(1);
- info "Initial Date Field Value: " + oneMonth;
- recTargetDate = oneMonth.toStartOfMonth();
- info "Beginning of Month: " + recTargetDate;
- recInvDate = recTargetDate.toString("yyyy-MM-dd");
- info "To String: " + recInvDate;
- backToDate = recInvDate.toDate("yyyy-MM-dd");
- info "Back to Date Format: " + backToDate;
My info statements return the following:
- Initial Date Field Value: 28-Jan-2024
Beginning of Month: 01-Jan-2024
To String: 2024-01-01
Back to Date Format: 01-Jan-2024
I've tried passing it as a String, I've tried passing the recTargetDate, I've tried the backToDate variable (obviously the same as recTargetDate). It doesn't seem like my .toDate("yyyy-MM-dd") is working.
Any help is appreciated!