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