Forum Discussion

ChristianW's avatar
ChristianW
Valued Contributor
4 years ago

Is there an equivalent to the the HS.con function?

If I like to migrate a HFM rules file, is there an equivalent to the HS.con function?
  • ChristianW's avatar
    4 years ago

    Yes, there is, it is called setCell and it is a method of the databuffer class. It doesn't use a string as input, so it is a little different to use

    resultDataBuffer.SetCell(si As SessionInfo, cell as DataCell, accumulateIfCellAlreadyEsists as boolean)
    
    or
    
    resultDataBuffer.SetCell(si As SessionInfo, cell as DataBufferCell, accumulateIfCellAlreadyEsists as boolean) 

    The Onestream help is giving a similar example like this one for the whole process.

    'Copy all "U2#Input:U3#Input" numbers for this dataUnit to the UD2 none Members and the UD3 member with the name "Target Member Name".
    Dim destinationInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("")
    Dim sourceDataBuffer As DataBuffer = api.Data.GetDataBuffer(DataApiScriptMethodType.Calculate, "U2#Input:U3#Input", destinationInfo)
    If Not sourceDataBuffer Is Nothing Then
        Dim resultDataBuffer As DataBuffer = New DataBuffer()
        For Each cell As DataBufferCell In sourceDataBuffer.DataBufferCells.Values
           If (Not cell.CellStatus.IsNoData) Then
              cell.DataBufferCellPk.UD2Id = DimConstants.None
              cell.DataBufferCellPk.UD3Id = api.Members.GetMemberId(dimtypeid.UD3, "Target Member Name")
              resultDataBuffer.SetCell(si, cell)
           End If
        Next
        api.Data.SetDataBuffer(resultDataBuffer, destinationInfo, True)
    End If