Forum Discussion

grillin7's avatar
grillin7
New Contributor II
2 years ago

get data value from BRApi.Finance.Data.GetDataCellUsingMemberScript

Hi, I'm trying to get the amount of an objDataCellInfoUsingMemberScript but I couldn't get the data, I'm trying this: objDataCellInfoUsingMemberScript = BRApi.Finance.Data.GetDataCellUsingMemberScri...
  • JackLacava's avatar
    2 years ago

    Not sure what you're trying to do with that string roundtrip. This should work:

    Dim myCell As DataCellInfoUsingMemberScript = BRApi.Finance.Data.GetDataCellUsingMemberScript(si, _
        "myCube", _
        "S#MyScenario:E#MyEntity: ... etc etc") 
    Dim myValue as Decimal = myCell.DataCellEx.DataCell.CellAmount
    						

    Generally speaking, it's safer to work with Decimal values than Doubles, as they are less prone to "surprises" when rounding. If you have to drop it into a formula, there are a number of approaches, this is the one I like:

    api.Data.FormulaVariables.SetDecimalVariable("myFixedAmount", myValue)
    api.Data.Calculate("A#Target = A#Source * $myFixedAmount")