Unable to populate the results into the destination intersection using GetDataBufferUsingFormula

BCG
New Contributor II

Hi All,

I have written below rule where, I am not able to see the results, But rule is executed without any errors.

Rule is about : Writing up the source values based on the Tex1 and Tex2 assigned in the source Accounts. where Text1 & Text2 are target Intersections to to actually be written to...

Kindly help me if something is missing in the code.

Dim ResulDataBuf As DataBuffer = New DataBuffer()

Dim DestinationInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("V#Periodic")
Dim DataBufFilter As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(V#Periodic,[A#[BS].Base.Where(Text1 <> vbnullstring And Text2 <> vbnullstring)])")
For Each sourceCell As DataBuffercell In DataBufFilter.DataBufferCells.Values

	Dim cashflowCell As New DataBufferCell(sourceCell) 'Temp buffercell within the loop to copy my cashflow cell

	Dim sText1 As String = api.Account.Text(cashflowCell.DataBufferCellPk.AccountId, 1) 'Source Mvmt
	Dim sText2 As String = api.Account.Text(cashflowCell.DataBufferCellPk.AccountId, 2) 'Target Account:Mvmnt.

	If (Not sText1 = vbNullString) And (Not sText2 = vbNullString) AndAlso instr(sText2, ":") > 0 Then

		Dim vSrcUD2Split As String() = Split(sText2, ":")
		Dim GetUD1Ac = Trim(vSrcUD2Split(0)) : Dim GetUD1Mvt = Trim(vSrcUD2Split(1))

		Dim vTgtActID As Integer = api.Members.GetMember(DimType.Account.Id, GetUD1Ac).MemberId
		Dim vTgtMvmntID As Integer = api.Members.GetMember(DimType.Flow.Id, GetUD1Mvt).MemberId

		cashflowCell.DataBufferCellPk.AccountId = vTgtActID
		cashflowCell.DataBufferCellPk.FlowId = vTgtMvmntID

		Dim ResultCell As New DataBuffercell(cashflowCell)

		If (Not sourceCell.CellStatus.IsNoData) Then
			ResulDataBuf.LogDataBuffer(api, "ResultCell", 100)
			ResulDataBuf.setcell(si, ResultCell, False)

		End If
	End If
Next
api.Data.setdatabuffer(ResulDataBuf, DestinationInfo) 'Save the data into destination.
4 REPLIES 4

JackLacava
Community Manager
Community Manager

I'd make sure your source databuffer is not empty, try logging that.

BCG
New Contributor II

Error msg.png

Thank you JackLacav for swift reply. i can see this error

MarcusH
Contributor III

This message usually means that the dimension member in the data buffer is XFCOMMON rather than the actual member name. The LogDataBuffer call you have will show the values that are being saved. If you have XFCommon in any dimension you will need to update the DataBufferCellPk with the correct value.

On another note I don't think <> vbnullstring is working as you expect. I think it is actually looking for the string vbnullstring rather than an empty value. It will work because I guess you don't have the text vbnullstring in your Text1 and Text2 fields but it will also bring back members where Text1 and Text2 are blank. I would change vbnullstring to '' (2 single quotes). I am not 100% about whether the single quote character works - I know it's not necessary, I just don't know if it must not be used.  

JackLacava
Community Manager
Community Manager

you're filtering on View, which means the view id gets set to common, and then you never set a new one.