Forum Discussion
The built-in date handling in Javascript isn’t the best, and the engine we’re on in snapLogic isn’t the latest. We’ve been using moment.js successfully to good effect. It’s a bit large but on the server nobody cares about download speeds. If you have to do a lot of date and/or time handling, especially converting between time zones, you might want to check it out.
The two following statements get it loaded for your from the public server, but we don’t do it that way. Once we settled on using it, we downloaded it ourselves to our Project Spaces so it’s available locally on the snaplex.
load("https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.26.0/moment.min.js");
load("https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.31/moment-timezone-with-data.min.js");
Then we use moment’s parsing and time zone corrections.
For example:
var zones = moment.tz.names();
zones.unshift("Not Set");
var timeZonedDate = moment.tz(theDateTimeString, zones[timeZoneId]);
return timeZonedDate.utc();
The above assumes you’re getting a date and time in a particular time zone and want it in UTC. And the return value is a “moment” object, which is an extension of the JavaScript DATE object. It has several formatting methods you can use to get just the date portion as a string in “yyyymmdd” format if that’s what you need.
You might want to read the moment.js documentation and then play around with it. Note that the authors do not recommend using moment for new development. At my employer, we feel this advice does not apply here, because many of the newer libraries don’t work well in snapLogic, and moment does.
@JPaps you can try join snap (select Left Outer join ), and go to view tab and select “Route Error Data to Error View” also select “Unmatched data to error view”. Make use you use correct name of ID in both the side.
Thanks for your help @Supratim your idea worked except I had to use Inner Join instead of Left Outer. Apparently the “Unmatched data to error view” property only does what it says when you are using an “Inner Join” as stated in the docs below:
I was able to achieve the titled objective by doing below:
- Using @Supratim’s recommendation except with the “Inner Join” option.
- Attaching my output document stream to the left side of the join.
- Attaching the excel file to the right side of the join.
- Attaching the write action of my output document stream to the error view of the join.
Related Content
- 2 years ago
- 3 years ago
- 5 years ago