Forum Discussion

SWilyums's avatar
SWilyums
Contributor
3 years ago

Updating UD4 Default value in UD1 using extensibility rule

Hello,

In another post user KarlT suggested the use of the UD defaults available for UD1. 

I manually updated members, and the functionality is exactly what I need.

I need to update the field through a data load.  UD1 members (Projects), will always have a single UD4 value. 

In the current TransformationEventHandler rule I am updating text fields in my UD1 members.  I thought I could just duplicate the code an update UD4Default.  However it is not working.  I know it is trying to update the UD4Default value, because if I manually assign a value, it gets cleared when I load.

My 2nd thought was that since it is a member selection and not a text field I needed the member id.  Which is my attempt below. 

Any thoughts or suggestion?

'A3 is the department (UD4) example 189

'UD1Attr1 is the project (UD1) example 14123

'D1_Defaults Members
Dim DeptId As Integer = BRApi.Finance.Members.GetMemberId(si,dimtypeid.UD4, A3)
Dim UD1Dept As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si, dimtypeid.UD1, UD1Attr1, True)
Dim UD1DeptProperty As New VaryingMemberPropertyItem(cubetypeid.Unknown, scenariotypeid.Unknown, dimtypeid.Unknown, False, PropStorageType.TextType, 0, DeptId)
UD1Dept.GetUDProperties.UD4Default.SetStoredPropertyItem(UD1DeptProperty)
brapi.Finance.MemberAdmin.SaveMemberInfo(si, UD1Dept, False, True, False, False)

  • Try this:

    Dim strUD1Member As String = "14123"
    Dim strUD4DefaultMember As String = "189"

    'Get the UD1 Member Info
    Dim UD1Member As Member = BRApi.Finance.Members.GetMember(si, dimtypeId.UD1, strUD1Member)
    Dim UD1MemberInfo As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si, DimTypeid.UD1, UD1Member.Name, True)

    'Get the UD4 Member Info
    Dim UD4DefaultMember As Member = BRApi.Finance.Members.GetMember(si, dimtypeId.UD4, strUD4DefaultMember)
    Dim UD4DefaultMemberInfo As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si, DimTypeId.UD4, UD4DefaultMember.Name, True)

    'Get the UD1 Properties. This is what we need to update.
    Dim UD1Properties As UDVMProperties = UD1MemberInfo.GetUDProperties()

    'Update the UD4 Default for UD1
    UD1Properties.UD4Default.SetStoredValue(ScenarioType.Unknown.ID, UD4DefaultMemberInfo.Member.MemberId)

    'Save the member and its properties including the newly updated UD4 Default
    Dim isNew As TriStateBool = TriStateBool.FalseValue
    BRApi.Finance.MemberAdmin.SaveMemberInfo(si, UD1MemberInfo, False, True, False, isNew)

     

     

  • MattG's avatar
    MattG
    New Contributor

    Try this:

    Dim strUD1Member As String = "14123"
    Dim strUD4DefaultMember As String = "189"

    'Get the UD1 Member Info
    Dim UD1Member As Member = BRApi.Finance.Members.GetMember(si, dimtypeId.UD1, strUD1Member)
    Dim UD1MemberInfo As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si, DimTypeid.UD1, UD1Member.Name, True)

    'Get the UD4 Member Info
    Dim UD4DefaultMember As Member = BRApi.Finance.Members.GetMember(si, dimtypeId.UD4, strUD4DefaultMember)
    Dim UD4DefaultMemberInfo As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si, DimTypeId.UD4, UD4DefaultMember.Name, True)

    'Get the UD1 Properties. This is what we need to update.
    Dim UD1Properties As UDVMProperties = UD1MemberInfo.GetUDProperties()

    'Update the UD4 Default for UD1
    UD1Properties.UD4Default.SetStoredValue(ScenarioType.Unknown.ID, UD4DefaultMemberInfo.Member.MemberId)

    'Save the member and its properties including the newly updated UD4 Default
    Dim isNew As TriStateBool = TriStateBool.FalseValue
    BRApi.Finance.MemberAdmin.SaveMemberInfo(si, UD1MemberInfo, False, True, False, isNew)

     

     

    • SWilyums's avatar
      SWilyums
      Contributor

      thank you this worked.

      I am not familiar with 

      "UDVMProperties = UD1MemberInfo.GetUDProperties()"

      Dim UD1Properties As UDVMProperties = UD1MemberInfo.GetUDProperties()" 

       

  • RandyThompson's avatar
    RandyThompson
    New Contributor III

    SWilyums, you mention that you are using the TransformationEventHandler rule to automatically update a member's text value from an attribute field. Do you mind sharing the code you used to do this. Thanks.

    • SWilyums's avatar
      SWilyums
      Contributor

      I used the code above posted by MattG.

      • RandyThompson's avatar
        RandyThompson
        New Contributor III
        UD1Properties.UD4Default.SetStoredValue(ScenarioType.Unknown.ID, UD4DefaultMemberInfo.Member.MemberId)

        So, in the example above, to update a text field instead of the UD4Default, I simply have to change UD4Default to UD1Properties.Text1.SetStoredValue(ScenarioType.Unknown.ID, textName1) ?