Tuesday
Hello Experts,
Is there a way to update 500+ member names in OneStream using XML file. Manually changing each member is time consuming there seems to be no functionality available with XML load?
Thank You,
Manoj
Solved! Go to Solution.
Wednesday - last edited Wednesday
I just had this use case come up recently. I wrote a business rule that renames members based on a member filter. I needed this rule to rename a number of members with a suffix/prefix due to extensibility in the account dimension. See code below. I have the code set up to be just base members of a top parent member, any member filter will work. (See line 43 for member Filter)
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.IO
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports OneStream.Shared.Common
Imports OneStream.Shared.Wcf
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Database
Imports OneStream.Stage.Engine
Imports OneStream.Stage.Database
Imports OneStream.Finance.Engine
Imports OneStream.Finance.Database
Namespace OneStream.BusinessRule.Extender.BulkRenameMembers
Public Class MainClass
Dim m_LogBuilder As StringBuilder = New StringBuilder()
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
Dim dimName As String = "Dimension Name"
Dim topMember As String = "Top Member in Dimension"
Dim preSufFlag As String = "Prefix"
Dim renameString As String = "PREFIX"
Me.RenameBaseMembers(si, dimName, topMember)
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
Public Sub RenameBaseMembers(ByVal si As SessionInfo, dimName As String, topMember As String, preSufFlag As String, renameString As String)
Dim dimPk = BRAPI.Finance.Dim.GetDimPk(si, dimName)
'Modify below as needed for use case.
Dim baseMemberLst = BRAPI.Finance.Members.GetMembersUsingFilter(si, dimPk, $"A#[{topMember}].Base.Remove(None)", True)
Me.AddToLog(si, "Member Rename Process Triggered" & vbCrLf & $"Dimension Name: {dimName}" & vbCrLf & $"Top Member: {topMember}" & vbCrLf & $"Members to be Modified: {baseMemberLst.Count}")
For Each mbrInfo As MemberInfo In baseMemberLst.AsEnumerable()
Dim oldMbrName = mbrInfo.Member.Name
Dim newMbrName As String
If preSufFlag.XFContainsIgnoreCase("Prefix") Then
'Prefix all member names
newMbrName = renameString & "_" & oldMbrName
Else
'Suffix all member names
newMbrName = oldMbrName & "_" & renameString
End If
Try
BRAPI.Finance.MemberAdmin.RenameMember(si,dimPk, oldMbrName, newMbrName) ' Comment this out to test...
AddToLog(si, $"Member Renamed." & vbCrLf & $"Old Member Name: {oldMbrName}" & vbCrLf & $"New Member Name: {newMbrName}")
Catch ex As Exception
AddToLog(si, $"Error Renaming Member - {oldMbrName}")
BRAPI.ErrorLog.LogMessage(si, m_LogBuilder.ToString())
Continue For
End Try
Next
BRAPI.ErrorLog.LogMessage(si, m_LogBuilder.ToString())
End Sub
#Region "Logging"
Public Sub AddToLog(ByVal si As SessionInfo, ByVal message As String)
m_LogBuilder.AppendLine(message)
m_LogBuilder.AppendLine("---------------------------------------")
End Sub
#End Region
End Class
End Namespace
Thursday
Thank you for the sample script. In our case there was no logic behind it and the changes are random. I had got the following script and it works. (I will be populating the Key Value Pairs in Excel and paste in script)
Wednesday
You can't rename members using the XML file because it will see the renamed member as a new member. You could write a Business Rule and use the function BRApi.Finance.MemberAdmin.RenameMember.
Wednesday
Thank you for the suggestion!
a) I am assuming that Extensibility Rule is required here?
b) Is the following code is what you are suggesting or am I way off?
Dim ProductDim As String = "Total_Products"
Dim objDimPk As DimPk = BRApi.Finance.Dim.GetDimPk(si, PRoductDim)
BRApi.Finance.MemberAdmin.RenameMember(si, objDimPk, memberName, newMemberName) '(Repeat this line for all memebrs to be renamed in Product Dim)
Dim SubProductDim As String = "Sub_Products"
Dim obj1DimPk As DimPk = BRApi.Finance.Dim.GetDimPk(si, SubProductDim)
BRApi.Finance.MemberAdmin.RenameMember(si, obj1DimPk, memberName, newMemberName) '(Repeat this line for all memebrs to be renamed in Sub Product dim)
Wednesday
Hi, may I ask for the exact reason to do this? Is this for a live customer, or during development?
Keep in mind that changing member names in the metadata does not change the member references e.g. in reports.
Wednesday
Hi Henning, this is for a live customer. The purpose of this change to shorten the member's name where possible
Wednesday
Thanks for the insight!
Doing this for that many members requires careful execution and rigorous testing in a development application before migration this to Prod. If the application has been set up as dynamic as possible, maybe you are lucky and renaming the members does not have that many knock on-effects.
Transformation Rules, Cube Views, Dashboards, Formulas, Business Rules and other items that reference any of those members will need to be automatically changed as well. If you really go through this exercise and were hopefully able to capture most items, this will need to be tested, probably in some parallel runs that also cover year end and the rollover to the next year.
This is potentially a big change effort - though admittedly I do not know anything about the customer and the solution.
Wednesday
The member changes only refer to UD dimension and not been hard coded any where so that is not a concern. We do have to test for Data Loss in dev app to be sure once I can get the rule ready.
Wednesday
If the members already contain data as it kind of sounds like is the case, then your options are as follows
If these members have not been used, then an additional option is as follows:
Wednesday - last edited Wednesday
I just had this use case come up recently. I wrote a business rule that renames members based on a member filter. I needed this rule to rename a number of members with a suffix/prefix due to extensibility in the account dimension. See code below. I have the code set up to be just base members of a top parent member, any member filter will work. (See line 43 for member Filter)
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.IO
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports OneStream.Shared.Common
Imports OneStream.Shared.Wcf
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Database
Imports OneStream.Stage.Engine
Imports OneStream.Stage.Database
Imports OneStream.Finance.Engine
Imports OneStream.Finance.Database
Namespace OneStream.BusinessRule.Extender.BulkRenameMembers
Public Class MainClass
Dim m_LogBuilder As StringBuilder = New StringBuilder()
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
Dim dimName As String = "Dimension Name"
Dim topMember As String = "Top Member in Dimension"
Dim preSufFlag As String = "Prefix"
Dim renameString As String = "PREFIX"
Me.RenameBaseMembers(si, dimName, topMember)
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
Public Sub RenameBaseMembers(ByVal si As SessionInfo, dimName As String, topMember As String, preSufFlag As String, renameString As String)
Dim dimPk = BRAPI.Finance.Dim.GetDimPk(si, dimName)
'Modify below as needed for use case.
Dim baseMemberLst = BRAPI.Finance.Members.GetMembersUsingFilter(si, dimPk, $"A#[{topMember}].Base.Remove(None)", True)
Me.AddToLog(si, "Member Rename Process Triggered" & vbCrLf & $"Dimension Name: {dimName}" & vbCrLf & $"Top Member: {topMember}" & vbCrLf & $"Members to be Modified: {baseMemberLst.Count}")
For Each mbrInfo As MemberInfo In baseMemberLst.AsEnumerable()
Dim oldMbrName = mbrInfo.Member.Name
Dim newMbrName As String
If preSufFlag.XFContainsIgnoreCase("Prefix") Then
'Prefix all member names
newMbrName = renameString & "_" & oldMbrName
Else
'Suffix all member names
newMbrName = oldMbrName & "_" & renameString
End If
Try
BRAPI.Finance.MemberAdmin.RenameMember(si,dimPk, oldMbrName, newMbrName) ' Comment this out to test...
AddToLog(si, $"Member Renamed." & vbCrLf & $"Old Member Name: {oldMbrName}" & vbCrLf & $"New Member Name: {newMbrName}")
Catch ex As Exception
AddToLog(si, $"Error Renaming Member - {oldMbrName}")
BRAPI.ErrorLog.LogMessage(si, m_LogBuilder.ToString())
Continue For
End Try
Next
BRAPI.ErrorLog.LogMessage(si, m_LogBuilder.ToString())
End Sub
#Region "Logging"
Public Sub AddToLog(ByVal si As SessionInfo, ByVal message As String)
m_LogBuilder.AppendLine(message)
m_LogBuilder.AppendLine("---------------------------------------")
End Sub
#End Region
End Class
End Namespace
Thursday
Thank you for the sample script. In our case there was no logic behind it and the changes are random. I had got the following script and it works. (I will be populating the Key Value Pairs in Excel and paste in script)