06-20-2018 10:51 AM
I am attempting to write javascript for a script snap to manipulate dates, times, and date/times. I am having issues getting a date field plus a separate time field parsed as a DateTime and further having issues when I need to add a duration of time to the DateTime. Are there any examples of this somewhere?
Doug
06-29-2018 12:29 PM
Please share your json data , which are the input of your script.
06-29-2018 12:35 PM
An easy example (i.e. only three docs).
[
{
"groupBy": {
"resourceId": "999000641",
"EventDate": "07/24/2017"
},
"group": [
{
"resourceId": "999000641",
"punchInDate": "07/24/2017",
"EventDate": "07/24/2017",
"break": null,
"costCenter": "54770",
"timeType": "1",
"punchInTime": "06:53",
"resourceLastName": "brown",
"$rowCountPernull": 1,
"WorkedHours": "4",
"punchOutTime": "10:53",
"siteId": "500",
"punchOutDate": "07/24/2017",
"resourceFirstName": "Test",
"yalePayCode": "1",
"optPayTypeId": 1
},
{
"resourceId": "999000641",
"punchInDate": "07/24/2017",
"EventDate": "07/24/2017",
"break": null,
"costCenter": "54620",
"timeType": "1",
"punchInTime": "10:53",
"resourceLastName": "brown",
"$rowCountPernull": 2,
"WorkedHours": "3.5",
"punchOutTime": "14:23",
"siteId": "500",
"punchOutDate": "07/24/2017",
"resourceFirstName": "Test",
"yalePayCode": "1",
"optPayTypeId": 1
},
{
"resourceId": "999000641",
"punchInDate": "07/24/2017",
"EventDate": "07/24/2017",
"break": null,
"costCenter": "64990",
"timeType": "1",
"punchInTime": "14:23",
"resourceLastName": "brown",
"$rowCountPernull": 3,
"WorkedHours": "5.25",
"punchOutTime": "19:38",
"siteId": "500",
"punchOutDate": "07/24/2017",
"resourceFirstName": "Test",
"yalePayCode": "1",
"optPayTypeId": 1
}
]
}
]```
06-29-2018 12:50 PM
@doug.fossler
Use the pipeline. Ignore json generator part and go ahead the changes. Let me know the result.
DateConvertion_2018_06_29.slp (6.6 KB)
06-29-2018 01:02 PM
I can do what your pipeline does, the issue is when i have a sub-group of multiple docs that require editing of their fields based on prior and former docs. Unfortunately the attempt to work around the problem does not resolve the problem. It seems that it is not possible to combine two strings and create a date-time in a script snap.