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 Viktor is using the code format option on this site (</> from the toolbar above the text box.)


Diane Miller
Community Manager

mmussitsch
New Contributor II

Oh okay @dmiller - thank you! Do wish Notepad++ had these helpers. But good to know next time I post code.

The expression library should be fairly compatible with JavaScript syntax, so you could apply that syntax and formatting in Notepad++ (or other editors) for a decent way to grok the expression library.

Yes! Way better … thanks @tlikarish