cancel
Showing results for 
Search instead for 
Did you mean: 

(Expression Library) Pull Account based on Parsed Path call

mmussitsch
New Contributor II

I’ve searched for examples but not having much luck.
My data in the .expr file looks similar to this:
Accounts:
{
projectspace:
{
ProjectName:
{
Salesforce
{
Dev:
{
account_name : “Salesforce CIDEV”
},
}

I wrote a parsePath function call that would pull the project space and project. The function whereAmI uses getOrgName to determine the environment. Then ultimately, I’d like one call to get the Account based on the projectPath + type + env to get a single result.

getOrgName: pipe.plexPath.split(‘/’)[1],
parsePath: x => (x.split(“/”)[x.split(“/”).length-2].replaceAll(" “,”“) + “.” + x.split(”/“)[x.split(”/“).length-1].replaceAll(” “,”")),
whereAmI: this.getOrgName.toLowerCase().contains(‘prod’) ? “Prod” : (this.getOrgName.toLowerCase().contains(‘test’) ? “Test” : “Dev”),
getAccount: (path,type) => this.Accounts[this.parsePath(path)][type][this.whereAmI],

parsePath returns “projectspace.ProjectName” and whereAmI returns “Dev”. I’d like to pass in type as “Salesforce”. I know getAccount isn’t right. I just wanted to represent what I’m trying to do. I’ve made many variations to it without luck. I basically want to call lib.expr_lib.getAccount(pipe.projectPath,“Salesforce”) and return the value “Salesforce CIDEV”.

Appreciate any help!
Thanks.
Melissa

8 REPLIES 8

mmussitsch
New Contributor II

Hmm, no reply yet. If I’ve gone too complicated, perhaps I can ask a simpler question, given my Accounts definition above, is there a function call that can be written to check if a value exists? Basically, if the “project” section doesn’t exist, then I want to grab the account name from the “project space” section which will always be there. In my testing, I just keep getting errors or null values that I can’t seem to test for. I can do it via a Mapper, but that defeats the purpose of my expression library and being able to reference the Account Name directly in other snaps and not have to pass them around.

Any advise is appreciated.

viktor_n
Contributor II

Hi @mmussitsch,

Problem I think was in this part

I don’t think that it can be mapped though multiple elements with only one set of square brackets.
Each square bracket is for only one element. I am not sure 100% about this but I think this was the problem.

I’ve changed the functions inside expression file a little bit.
Replaced projectPath with two other functions: getProjectSpace and getProject.

    "getOrgName": pipe.plexPath.split("/")[1],
    "getProjectSpace": x => x.split('/')[2],
    "getProject": x => x.split("/")[3],
    "whereAmI": this.getOrgName.toLowerCase().contains("prod") ? "Prod" : (this.getOrgName.toLowerCase().contains("test") ? "Test" : "Dev"),
    "getAccount": (path,type) => this.Accounts[this.getProjectSpace(path)][this.getProject(path)][type][this.whereAmI]

Here is the Accounts object.

    "Accounts": {
        "projectSpace": {
            "projectName": {
                "Salesforce": {
                    "Dev": {
                        "account_name": "Salesforce CIDEV"
                        }
                    }
                }
            }
        }

And here is the output.
image

Hope this will help you 🙂

Regards,
Viktor

amit_saroha
New Contributor III

@viktor_n - I am sorry to hijack this thread but I have a similar situation and I am struggling to understand. I would heartily appreciate it if you can describe what you have done here and how they function you have written is working for me to understand.

My expression file is as below -

{
applications:
{
OracleEBS:
{
dev:
{
FNTS :
{
srcDB: ‘shared/Snaplogic_FNTS’,
tgtDB: ‘’
},
FNDV :
{
srcDB: ‘shared/Snaplogic_FNDV’,
tgtDB: ‘’
},
FNPJ :
{
srcDB: ‘shared/Snaplogic_FNPJ’,
tgtDB: ‘’
},
FNIG :
{
srcDB: ‘shared/Snaplogic_FNIG’,
tgtDB: ‘’
},
FNU1 :
{
srcDB: ‘shared/Snaplogic_FNU1’,
tgtDB: ‘’
},
FNU2 :
{
srcDB: ‘shared/Snaplogic_FNU2’,
tgtDB: ‘’
},
DRYR :
{
srcDB: ‘shared/Snaplogic_DRYRA’,
tgtDB: ‘’
}
},
test:
{
},
prod:
{
FNPD :
{
srcDB: ‘shared/Snaplogic_FNPD’,
tgtDB: ‘’
}
}
},
OracleCloud:
{
dev:
{
DEV1:
{
URL: ‘https://oraclecloud.com’,
Account: ‘shared/Oracle_Cloud_Dev1’,
Rest_Account: ‘shared/Oracle_Cloud_REST_Dev1’
},
DEV2:
{
URL: ‘https://oraclecloud.com’,
Account: ‘shared/Oracle_Cloud_Dev2’,
Rest_Account: ‘shared/Oracle_Cloud_REST_Dev2’
},
TEST:
{
URL: ‘https://oraclecloud.com’,
Account: ‘shared/Oracle_Cloud_Test’,
Rest_Account: ‘shared/Oracle_Cloud_REST_Test’
}
},
test:
{
},
prod:
{
PROD:
{
URL: ‘https://oraclecloud.com’,
Account: ‘shared/Oracle_Cloud_Prod’,
Rest_Account: ‘shared/Oracle_Cloud_REST_Prod’
}
}
},
HCMCloud:
{
dev:
{
DEV1:
{
URL: ‘’,
Soap_Account: ‘shared/HCM_Cloud_SOAP_Dev1’,
Rest_Account: ‘shared/HCM_Cloud_REST_Dev1’
},
DEV2:
{
URL: ‘’,
Soap_Account: ‘shared/HCM_Cloud_SOAP_Dev2’,
Rest_Account: ‘shared/HCM_Cloud_REST_Dev2’
},
TEST:
{
URL: ‘https://oraclecloud.com’,
Soap_Account: ‘shared/HCM_Cloud_SOAP_Test’,
Rest_Account: ‘shared/HCM_Cloud_REST_Test’
}
},
test:
{
},
prod:
{
PROD:
{
URL: ‘’,
Soap_Account: ‘shared/HCM_Cloud_SOAP_Prod’,
Rest_Account: ‘shared/HCM_Cloud_REST_Prod’
}
}
},
FileWriter:
{
dev:
{
GroundPlex: ‘shared/Groundplex_File_Access’
},
test:
{
},
prod:
{
GroundPlex: ‘shared/Groundplex_File_Access’
}
},
Email:
{
dev:
{
Account: ‘shared/SMTP_Mail’,
From: ‘a@b.com’,
CC: ‘a@b.com’
},
test:
{
},
prod:
{
Account: ‘shared/SMTP_Mail’,
From: ‘a@b.com’,
CC: ‘a@b.com’
}
}
},
errors: ‘shared/captureDataWarnings’,
timezoneSync: ‘US/Eastern’,
maxRetryCount: 24,
getOrgName: pipe.plexPath.split(‘/’)[1],
whereAmI: this.getOrgName.toLowerCase().contains(‘dev’) ? “dev” : (this.getOrgName.toLowerCase().contains(‘test’) ? “test” : (this.getOrgName.toLowerCase().contains(‘prod’) ? “prod” : null)),
getAppConf: x => (this.applications[this.whereAmI])
}

mmussitsch
New Contributor II

Thanks so much Viktor for the help. You’ve helped me simplify some things and build upon them. I now have a pretty comprehensive file. In addition to the other functions, I have new ones like getProjectSpace, getProject, findProject, findProjectSpace, findAreabyProject, findAreabyProjectSpace so that if an item doesn’t have a “Project” definition it will default to the Project Space definition. They all work together in one call pullObject(“Salesforce”). It’s working very well.

One quick question, your code snippet, what editor/file format is that with all the colors. Sure is nicer to read than an unknown .expr file via Notepad++.

Thanks!
Melissa