Retrieve member name

MStucchi
New Contributor III

Hi all,

I'm bit new in developing rules in one stream and I have a simple question.

I'm trying to retrieve the accountId member name from a member formula on the account itself.

I'm using the below code but it seems api.Pov.Account.Name is not working, if I replace it with the account name it works.

Dim AcctName As String = api.Pov.Account.Name
Dim AcctId As Integer = api.Members.GetMember(DimType.Account.Id,AcctName).MemberId

Any suggestion?

1 ACCEPTED SOLUTION

TonyToniTone
Contributor II

In general, stored calculations use the Data Unit Dimensions with the Cube to drive calculation execution.  Data Unit Dimensions are Entity, Parent, Scenario, Time, and Consolidation, in addition with Cube.  These Dimensions are known at the time of execution of calculations.  Therefore, these Dimensions CAN use api.Pov.xxxx.  All the Account related Dimensions have no concept of api.POV at the time of calculation execution for stored calculations or Business Rules.  For example, a stored calculation can do an If statement such as If api.Pov.Entity.Name.XFEqualsIgnoreCase("EntityA") Then.  

In order to use api.Pov.Account in stored calculations, you can do it if you wanted to evaluate an Account and Account settings properties of Account members after the Data Unit calculations have executed.  Something like this would be acceptable.  Getting an Account Type of Account Dimension members ( or many of the Settings Properties from the Member Properties tab ).  Api.Pov.Account.MemberId can be used inside the api.Account.GetAccountType function.  

TonyToniTone_0-1656616845933.png

For Dynamic Calc, there is no concept of a Data Unit in the same manner as stored calculations.  If you have an Account setup as a Formula Type as Dynamic Calc, then api.Pov.Account will work

 

View solution in original post

8 REPLIES 8

Mattb_0124
New Contributor III

If you are trying to get the account ID from the member name then use this.

 Dim ActId As Integer = api.Members.GetMemberId(DimType.Account,AcctName)

MStucchi
New Contributor III

Thanks, in the end i need to retrieve the accountID, but to do that I need the account name.

I'm trying to retrieve account name using api.pov.account.name but it returns blank.

If I write the account name like this 

Dim AcctId As Integer = api.Members.GetMember(DimType.Account.Id,"<account name>").MemberId

it works.

So I'm wondering why the api.pov.account.mame doesn't

 

Mattb_0124
New Contributor III

Ah, is this a member formula? You can always run a log message to see if anything is being picked up. This is a pretty simple call so as long as an account is present it should pick it up. 

brapi.errorlog.logmessage(si, "Account =" & api.pov.account.name)

Not sure where you are doing this, is it a member formula? If the rule is initiated from a DM job do you have an account in the DM job's POV?

 

TonyToniTone
Contributor II

In general, stored calculations use the Data Unit Dimensions with the Cube to drive calculation execution.  Data Unit Dimensions are Entity, Parent, Scenario, Time, and Consolidation, in addition with Cube.  These Dimensions are known at the time of execution of calculations.  Therefore, these Dimensions CAN use api.Pov.xxxx.  All the Account related Dimensions have no concept of api.POV at the time of calculation execution for stored calculations or Business Rules.  For example, a stored calculation can do an If statement such as If api.Pov.Entity.Name.XFEqualsIgnoreCase("EntityA") Then.  

In order to use api.Pov.Account in stored calculations, you can do it if you wanted to evaluate an Account and Account settings properties of Account members after the Data Unit calculations have executed.  Something like this would be acceptable.  Getting an Account Type of Account Dimension members ( or many of the Settings Properties from the Member Properties tab ).  Api.Pov.Account.MemberId can be used inside the api.Account.GetAccountType function.  

TonyToniTone_0-1656616845933.png

For Dynamic Calc, there is no concept of a Data Unit in the same manner as stored calculations.  If you have an Account setup as a Formula Type as Dynamic Calc, then api.Pov.Account will work

 

I thought it was related to the fact that Account is not part of the POV.

Thanks for your expplanation,perfectly clear and detailed.

I'm wondering anyway why when compiling a member formula with api.pov.account does not rise any warning, it probably checks syntax correctness.

Thanks for your help

Many thanks Tony, we encountered the same issue when we tried to call a function of MemberFormula BR to be used in a DynamicCalc. Now we understand that we have to write scripts for DynamicCalc directly from dimension member. Your reply is very clear and helpful.

TonyToniTone
Contributor II

Happy to hear that the answer is clear and helps. 

The compiler checks for syntax accuracy.  However, it does not check the context in which you use the function.  That is up to the rule writer and having the foundational knowledge on how/when to use these functions.