Forum Discussion

patan's avatar
patan
New Contributor III
4 years ago
Solved

I 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=...
  • del's avatar
    4 years ago

    In your code, try changing “this.DEPT” to “__parent__.DEPT”. I think “this” is scoped to the new object you’re creating, so you need to reference the object parent.

    {
        "DEPT": {
            "EG": "Engineering",
            "HR": "Human Resource",
            "FIN": "FInance"
        },
        "AddDescription": element => (element.filter(x=>x.sector=='USA').map(x=> x.extend({"Description":__parent__.DEPT.get(x.deptId)})).filter(x=>x.get('Description')!=null))
    }
    

    reference: https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439367/Object+Functions+and+Properties