cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Is there a better way to calculate a value and use it throughout a pipleine?

wpenfold
New Contributor III

Hi, often I have a need to calculate a value and then use it several places throughout the pipeline. It gets a little ugly, because using pass-through, I often end up with something like $original.original.original.original.THISTERM. Is there any better way to do that?..some syntax to reference THISTERM wherever it is in the hierarchy? Like with XML, I can use โ€˜//THISTERMโ€™

7 REPLIES 7

dave_cartlidge
New Contributor

Depending on your use case you can try the expression libraries too.

Iโ€™ve created a couple of โ€œhelperโ€ libraries that calculate things like File Paths which vary depending on the project or user or pipeline thatโ€™s calling them and then store the function in an expression library which gets loaded at run time in the pipeline. These can then act like global variables.

eg I can then use โ€œlib.helpers.file_pathโ€ in any snap and itโ€™s always going to be correct and I never have to traverse the $original.original.original tree (something which gets very messy when you add another snap into the flow)

Iโ€™ve been looking for thatโ€ฆHow do you create expression libraries? I donโ€™t recall seeing that anywhere. That would be really helpful for file paths that vary based on the snaplex being used.

@wpenfold
Here is the documentation for creating Expression Libraries:

Expression Libraries In Snaplogic