on 04-10-2015 12:29 PM
Hi Experts,
We have a requirement that Validity end date for external users, be set upon pre-determined condition. The UI (Task) has MX_VALIDTO in Editable format. In the workflow below the Task, Job is written to modify the validity end date via JScript.
We are facing error whenever the day or month has a zero in it. ie., 1st March which should be stored as '2015-03-01' is getting stored in Database as '2015-3-1' even though the debug line shows the returing Output as '2015-03-01'.
We have tried returning the value as String and as a Date Object, but it isn't working. The value is still getting stored without zero.
Somewhere after the data is returned by the script and before being stored in Database, the error happens. Believe we are missing something here.
Please find below the screenshots of the JScript and the Log.
Your support is highly appreciated.
Regards,
Ganesh S
Hi Ganesh,
What data type do you use to store the Z valid to dates? Did you try string/text instead of Datetime?
Cheers,
Chenyang Xiong
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ganesh,
I am not well versed in JS so I couldn't point out issue in your JS.
But we had the same kinda requirement and we added 0 to string.
try the below statement and let me know if it works.
var validtodate=todateInDateFmt.getFullYear() + "-" + ("0"+(todateIntDateFmt.getMonth()+1).toString()).slice(-2)+"-"+("0"+todateIntDateFmt.getDate().toString()).slice(-2);
Kind regards,
Jai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ganesh,
We passed the date in string format and it worked.
Please try the below. It comes after line 76 in your code
var monthPart = (todateInDateFmt.getMonth()+1).toString();
if(monthPart.length==1){
monthPart="0"+monthPart;
}
var datePart = (todateInDateFmt.getDate()).toString();
if(datePart.length==1){
datePart="0"+datePart;
}
var validtodate=todateInDateFmt.getFullYear() + "-" + monthPart + "-"+ datePart;
Kind regards,
Jai
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.