SWilyums
3 years agoContributor
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 t...
- 3 years ago
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)