Forum Discussion

BhavayMangla's avatar
BhavayMangla
New Contributor II
24 days ago

Updating Text1 using business rule

Hey Guys,

I was writing a rule to update a member description and text 1 field of the same member. I was able to update the member description, but can anyone help me with the text 1 field?

Please find the code below which I am using to update the description..

Dim SelectUD4 As String = args.NameValuePairs.XFGetValue("Param1")
Dim NewDescriptionUD4 As String = args.NameValuePairs.XFGetValue("Param2")
Dim UD4TextField As String = args.NameValuePairs.XFGetValue("Param3")
 
BRApi.ErrorLog.LogMessage(si,UD4TextField)
 
Dim member As Member = BRApi.Finance.Members.GetMember(Si,dimtype.UD4.Id,SelectUD4)
If member Is Nothing Then 
Throw New Exception("Selected UD4 member not found")
End If
Dim newmember As New WritableMember(member)
newmember.Description= NewDescriptionUD4
newmember
brapi.Finance.MemberAdmin.SaveMemberInfo(si, True, newmember, False, Nothing, False, Nothing, False)


Any help would be appreciated.
  • I used the following solution..

    Dim SelectUD4 As String = args.NameValuePairs.XFGetValue("Param1")
    Dim UD4TextField As String = args.NameValuePairs.XFGetValue("Param3")
     
    'BRApi.ErrorLog.LogMessage(si,UD4TextField)
     
    ' Get member info
    Dim memberinfo As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si,dimtype.UD4.Id,SelectUD4,True)
    'Get member property from member info
    Dim memberproperty As UDVMProperties = memberinfo.GetUDProperties()
    'Set Text2 property as New property
    memberproperty.Text2.SetStoredValue(Scenariotype.Unknown.Id,DimConstants.Unknown,UD4TextField)
    'Save member info with text value
    Dim isNew = TriStateBool.TrueValue
    BRApi.Finance.MemberAdmin.SaveMemberInfo(si,memberinfo,False,True,False,isNew)
  • BhavayMangla's avatar
    BhavayMangla
    New Contributor II

    I used the following solution..

    Dim SelectUD4 As String = args.NameValuePairs.XFGetValue("Param1")
    Dim UD4TextField As String = args.NameValuePairs.XFGetValue("Param3")
     
    'BRApi.ErrorLog.LogMessage(si,UD4TextField)
     
    ' Get member info
    Dim memberinfo As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si,dimtype.UD4.Id,SelectUD4,True)
    'Get member property from member info
    Dim memberproperty As UDVMProperties = memberinfo.GetUDProperties()
    'Set Text2 property as New property
    memberproperty.Text2.SetStoredValue(Scenariotype.Unknown.Id,DimConstants.Unknown,UD4TextField)
    'Save member info with text value
    Dim isNew = TriStateBool.TrueValue
    BRApi.Finance.MemberAdmin.SaveMemberInfo(si,memberinfo,False,True,False,isNew)
  • Here is a sample of some code I used.  Hope it helps.

    Dim anotherMember As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si, dimtypeid.UD1, UD1Attr1, True)
    'Set to Default Scenario and Time (-1=Default)
    Dim text1Property As New VaryingMemberPropertyItem(cubetypeid.Unknown, -1, -1, False, PropStorageType.TextType, 0, XYZ)
    'Update value in Text1 field for the project
    anotherMember.GetUDProperties.Text1.SetStoredPropertyItem(text1Property)
    'save Text1 Field
    brapi.Finance.MemberAdmin.SaveMemberInfo(si, anotherMember, False, True, False, False)