I am trying to perform a lookup and extend the object using the expression library
I wanted to perform a extend by performing a lookup using the expression library and it is giving me “this.comparator is undefined” error. Below is my expression Library Content: { embedbusinessUnit: x => x.extend({"Demo":this.comparator[0]}), embedbusinessUnit1: x => x.merge(this.comparator[0]), "comparator": [ { "KSCHL": "EPE", "VKORG": "1000", "BusinessType": "E", "KSCHLN": "LPE", "VKORGN": "1000" }, { "KSCHL": "EP0", "VKORG": "RG", "BusinessType": "N", "KSCHLN": "LP0", "VKORGN": "1000" } ] } When I access the lib.businessUnitExpr.embedbusinessUnit($) gives me a comparator undefined error. But when I access lib.businessUnitExpr.embedbusinessUnit1($) then it is able to identify the comparator Any help would be appreciated. BusinessUnitComparator.expr (382 Bytes)4.8KViews0likes5CommentsExpression Library: Start and end dates of previous month
The following expression library can be used to generate the start date and end date of the previous month in several formats. { // Convert the given Date-with-time object into a Date with only the year and month to_month_date: x => Date.UTC(x.getFullYear(), x.getMonth() - 1), // Get the start of the previous month based on the given date or the current time if no parameters are given prev_month_start: x => this.to_month_date((x || Date.now()).minusMonths(1)), // Get the end time of the previous month based on the given date or the current time if no parameters are given prev_month_end: x => this.to_month_date((x || Date.now()).withDayOfMonth(1)).minusSeconds(1), prev_month_start_string: x => this.prev_month_start(x).toString().split('T')[0], prev_month_end_string: x => this.prev_month_end(x).toString().split('T')[0], prev_month_start_epoch: x => this.prev_month_start(x).getTime(), prev_month_end_epoch: x => this.prev_month_end(x).getTime() }4.1KViews1like0CommentsExpression Library evaluates to ArrowFunction
Hello, i’m trying to nest a function in a map within an expression library, however what i get returned just the ‘callstack’ of the function. Here’s the outcome: [ { "test": "/* ArrowFunction @ line 5:10 */ () => __parent__.salesRegionMapper('accountableUnit', 8)" } ] The expression library is called like this: lib.map.responsibleUnit['8'] Here is the expression library: { "responsibleUnit": { "10": "Delivery", "9": "Operation", "8" : () => __parent__.salesRegionMapper('accountableUnit', 8), "16": "Tolling Services" }, "accountableUnit": [ [5, "Sales APAC"], [7, "Sales EMENA"], [8, "Sales EMENA"], [19, "Sales LAM"], [20, "Sales NAM"], [21, "Sales Africa"], [22, "Sales EMENA"], [23, "Other"], [24, "Sales EMENA"], [37, "Tolling Services"], [39, "Other"] ], salesRegionMapper: (mappingTable, value) => this[mappingTable].find(x => x[0] == value)[1], } How can i get the function to actually execute and not just be ‘listed’? Best regards ThomasSolved4KViews0likes5CommentsExpression Library: Database DateTime Conversion
The expressions for database datetime conversions listed in the topic SnapLogic DateTime Conversion Guidelines can be updated as follows to build an expression library: { /* * Database DateTime Conversions * Sample conversions between the SnapLogic DATETIME variable and several known 3rd party data types normalized to the US/Pacific time zone. */ toRedshiftDate: x => LocalDate.parse(x.toLocaleDateString({"timeZone":"US/Pacific”})) , toRedshiftTimestamp: x => LocalDateTime.parse(x.toLocaleDateTimeString({"timeZone":"UTC”})) , toMongoDBDateTime: x => LocalDateTime.parse(x.toLocaleDateTimeString({"timeZone":"US/Pacific”})) , toMySQLDate: x => LocalDate.parse(x.toLocaleDateString({“timeZone”:"US/Pacific”})) , toMySQLDateTime: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) , toMySQLTime: x => LocalTime.parse(x.toLocaleTimeString({“timeZone”:"US/Pacific”})) , toMySQLTimeStamp: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"US/Pacific”})) , toOracleDate: x => LocalDate.parse(x.toLocaleDateString({“timeZone”:"US/Pacific”})) , toOracleTimeStamp: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) , toOracleTimeStampTMZ: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"US/Pacific”})) , toOracleTimeStampLocalTMZ: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"US/Pacific”})) , toPostgresDate: x => LocalDate.parse(x.toLocaleDateString({“timeZone”:"US/Pacific”})) , toPostgresTime: x => LocalTime.parse(x.toLocaleTimeString({“timeZone”:"UTC”})) , toPostgresTimeTMZ: x => LocalTime.parse(x.toLocaleTimeString({“timeZone”:"US/Pacific”})) , toPostgresTimeStamp: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) , toPostgresTimeStampTMZ: x => LocalTime.parse(x.toLocaleTimeString({“timeZone”:"US/Pacific”})) , toSAPHANADate: x => LocalDate.parse(x.toLocaleDateString({“timeZone”:"US/Pacific”})) , toSAPHANATime: x => LocalTime.parse(x.toLocaleTimeString({“timeZone”:"US/Pacific”})) , toSAPHANASecondDate: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) , toSAPHANATimeStamp: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) , toSalesforceDate: x => LocalDate.parse(x.toLocaleDateString({“timeZone”:"US/Pacific”})) , toSalesforceDateTime: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) , toSalesforceTime: x => LocalTime.parse(x.toLocaleTimeString({“timeZone”:"US/Pacific”})) , toSQLDateTime: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) , toSQLDateTime2: x => LocalDateTime.parse(x.toLocaleDateTimeString({“timeZone”:"UTC”})) }3.6KViews1like0CommentsEnable editing of expression library file
When designing pipelines we have environment specific parameters (Dev, Test, Prod) in expression libraries. This renders our pipeline development independent of having to alter pipeline parameters or tasks between environments and deploys. However, the managing of the expression library files are a bit tedious. The file has to be downloaded, edited and uploaded again. It would be awesome to enable editing of the content of expression library file in the preview window. Example mockup: Of course having environment variables in a more accessible and standardised way would be the ideal solution, such as a new entity in SL manager, there could be an environment variables section in the projects as well as having the possibility to access shared env vars.3.4KViews1like3CommentsExpression Library - Environment Variable
Hi all, We are looking at building a solution for loading variables into pipelines via the expression library feature. One feature we would like to include is when loading the external library it will select the file based on the environment(ORG) that it is in. we have seen a method of doing this via the pipeline path.plexpath (Expression language) however this would involve a large query to select the path e.g.(…SLDev\Shared\Tools) Just wondering how other customers may have implemented this kind of solution in order to get environment variables. many thanks, KiranI have a use case where I have to invoke the one library function with another library function with in same expression library
I have created an expression library as below: { ‘DEPT’: { “EG” : “Engineering”, “HR” : “Human Resource”, “FIN” : “FInance” }, AddDescription : element => (element.filter(x=>x.sector==‘USA’).map(x=> x.extend({‘Description’:this.DEPT.get(x.deptId)})).filter(x=>x.get(‘Description’)!=null)) } Below is the expression I am using in mapper: lib.mapping_new.AddDescription($dept) The exception I am getting: Failure: this.DEPT is undefined., Reason: ‘DEPT’ was not found while evaluating the sub-expression ‘this.DEPT’, Resolution: Check the spelling of the property or, if the property is optional, use the get() method (e.g. this.get(‘DEPT’)) Check Expression_2022_03_23.slp (3.8 KB) For Ex: for the below input Array: { “dept”: [ {“deptId”: “HR”,“sector”: “USA”}, {“deptId”: “FIN”,“sector”: “USA”}, {“deptId”: “DE”,“sector”: “EU”}, {“deptId”: “EG”,“sector”: “USA”}, {“deptId”: “HR”,“sector”: “EU”}] } I want the below output: { “dept”: [{“deptId”: “HR”,“sector”: “USA”,“Description”: “Human Resource”}, {“deptId”: “FIN”,“sector”: “USA”,“Description”:“FInance”}, {“deptId”: “EG”,“sector”: “USA”,“Description”:“Engineering”}] } I know if we have two different libraries we can invoke one function from another, but I wanted to achieve this with a single expression library.Solved2.9KViews0likes2CommentsDynamically change the Delimiter in CSV parser
I’m designing ah pipeline that will handle multiple delimiters in a single CSV parser. I’m using a expression library that has the delimiter details of the respective files as below. [ { “src_file”: “aab”, “Delimit”: “PIPE”, “tgt_table”: “T_STG_AAB” } }, { “src_file”: “abc”, “Delimit”: “TAB”, “tgt_table”: “T_STG_ABC” } }, { “src_file”: “efg”, “Delimit”: “COMMA”, “tgt_table”: “T_STG_EFG” } } ] On the mapper snap I can write expression to refer this expression library lib.sample.find(x => x.src_file==“incoming_filename”).get(‘Delimit’). But when I try to use the same in CSV parser it doesnt accept. can we really do this.2.8KViews0likes2CommentsMongo DB Update Snap - Expression for Query
The following query works in MongoDB Atlas to update a record: db.mytable.update ( { _id : ObjectId(‘1234’) }, { $set : { “org_name” : “new org name” } } ) How do we configure this for use with the Mongo DB -Update snap? any one have an example?Solved2.3KViews0likes1Comment