06-30-2022 07:19 AM - last edited on 05-02-2023 10:11 AM by JackLacava
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?
Solved! Go to Solution.
06-30-2022 03:43 PM
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.
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
06-30-2022 10:05 AM
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)
06-30-2022 10:11 AM
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
06-30-2022 10:15 AM
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)
06-30-2022 11:18 AM
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?
06-30-2022 03:43 PM
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.
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
07-01-2022 02:34 AM
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
01-26-2024 03:30 AM
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.
07-01-2022 08:57 AM - edited 07-01-2022 08:58 AM
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.