11-09-2021
03:24 AM
- last edited
a month ago
by
JackLacava
Does anyone have a piece of code to clear data on the origin Forms member for just a few accounts? The api.data.clearcalculateddata is not possible (data is not calculated) and api.data.setdatacell doesn't work. Thanks.
Solved! Go to Solution.
11-09-2021 04:38 AM
You can combine calculate with clearcalculateddate like this:
Dim script as string = pov
api.data.calculate($"{script} = 0 * {script}")
api.data.clearcalculateddata(script)
The first row will make it calculated, the second row will delete it, because now it is calculated.
11-09-2021 05:05 AM
Thanks Christian, tested this and works as expected.
11-09-2021 04:38 AM
You can combine calculate with clearcalculateddate like this:
Dim script as string = pov
api.data.calculate($"{script} = 0 * {script}")
api.data.clearcalculateddata(script)
The first row will make it calculated, the second row will delete it, because now it is calculated.
11-22-2021 05:28 PM
I've tried this, but I'm not following how to do this. I have several accounts where I only want to clear the Forms data.
I need the forms data cleared for all the accounts where Text 8 Startswith VarPercentofSales
This was the code I tried:
Dim script As String = "A#All:F#EndBal_Input:V#Periodic:O#Forms:U1#Local_Input:U2#None:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None.Where(Text8 Startswith VarPercentofSales)"
api.data.calculate($"{script} = 0 * {script}")
api.data.ClearCalculatedData("TRUE","TRUE","TRUE","TRUE","A#IncStmnt.Base.Where(Text8 Startswith VarPercentofSales)",,"O#Forms",,,,,,,,,)
11-25-2021 11:50 AM
The script and the syntax is not correct, try this:
Dim script As String = "A#All"
api.data.calculate($"{script} = 0 * {script}","A#IncStmnt.Base.Where(Text8 Startswith VarPercentofSales)",,"O#Forms")
api.data.ClearCalculatedData(True,True,True,True,"A#IncStmnt.Base.Where(Text8 Startswith VarPercentofSales)",,"O#Forms")
11-29-2021 04:04 PM
This worked. You showed me something different when working with variables. Usually I see variables used like this:
api.data.calculate (script & "= 0* "& script, "A#IncStmnt.Base.Where(Text8 Startswith VarPercentofSales)",,"O#Forms")
Instead the script appears like this:
api.data.calculate ($"{script} = 0* {script}", "A#IncStmnt.Base.Where(Text8 Startswith VarPercentofSales)",,"O#Forms")
Does the $ sign have to be used with the "{ }" brackets?
Where do you find these different formats that can be used? Does it have to do with how VB.net script is setup?
04-27-2023 06:54 AM
For reference: this is called "string interpolation", and is a relatively recent feature of VB.Net - no extra setup required in recent OneStream versions (I'd say 6+, but might work on earlier ones too).
01-28-2022
09:52 AM
- last edited on
04-27-2023
06:56 AM
by
JackLacava
The below code will also work.
Dim Parent As Member = api.Members.GetMember(DimType.Account.Id,"IS")
Dim ActMembers As List (Of Member) = api.members.GetBaseMembers( _
api.Pov.AccountDim.DimPk, Parent.MemberId, Nothing)
If Not ActMembers Is Nothing Then
For Each ActMember As Member In ActMembers
If ((Not api.Entity.HasChildren()) ) Then
api.Data.ClearCalculatedData("A#" & ActMember.Name,True,True,True,True)
End If
Next
End If
11-09-2021 05:05 AM
Thanks Christian, tested this and works as expected.
11-19-2021 08:28 AM
Can also use the below where amount is 0.0 and isNoData is True.
api.Data.SetDataCell(memberScript, amount, isNoData, isDurableCalculatedData)