Forum Discussion

MarkHoughton's avatar
MarkHoughton
Contributor
2 years ago

How do I get the Text property value stored in a UD that varies by Scenario and Time ?

Hi, I want to retrieve into a Business Rule and pass it on to a CubeView row label the value stored in a UD text property. ie UD4 Text3 for example presuming that this is relative to the current ...
  • MarkHoughton's avatar
    MarkHoughton
    2 years ago

    Hi Eric,

    Thanks for all the guidance, I had to rework some of the elements after your pointers, but here is the completed code which now provides my expected result for anyone else who may be interested.

    The request from my finance team was for additions to multiple fixed asset long term "projects" to be captured. I did not want to create endless UD items for projects which will go 'out of life' within 3 to 5 years. So, as there were not likely to be more than 10 projects per operating division active at any one time, then I decided to create just 11 UD4 PPEAdditions dimensions. Item 11 being 'an everything else dump which did not fit into the 10 live projects'

    The cubeview then has 11 rows of UD4 with this text

    'Text in CubeView cell = U4#PPEAdditions02:Name(BRString(MyBusinessRuleName,GetMyUD4Text,PPEid=s02,WFT=|WFText1|,Scenario=|CVScenario|,Time=|WFTime|)

    'By using WFTime rather than CVTime it allows for the variations by month for different entries stored in the Text field.
    'It did not pick up variations when CVTime was used
    'also the PPEid would not build As a text String unless I prefixed it with "s" as just "01" Or "02" did not work.

    'This is not the only item in the BR rule so we start with...

    '=============================================================================

    Else If (args.FunctionName.Equals("GetMyUD4Text", StringComparison.InvariantCultureIgnoreCase)) Then

    Dim MH2ClusterPK As WorkflowUnitClusterPk = si.WorkflowClusterPk
    Dim MH2ScenarioTypeID As Integer = BRApi.Workflow.General.GetScenarioTypeId(si, MH2ClusterPK)
    Dim my2wftlong As String = BRApi.Workflow.Metadata.GetParent(si, args.SubstVarSourceInfo.WorkflowUnitInfo.ProfileName).GetAttributeValue(MH2ScenarioTypeID, 18000)


    'Where the Attribute Index in the WorkFlow Profile Is: Text1 = 18000, Text2 = 20000, Text3 = 22000, Text4 = 24000
    Dim mydiv As String = left(my2wftlong,3)
    'Value set in the WorkFlow Text1 field that identified the operating division of the entity

    Dim myPPE As String = args.NameValuePairs.XFGetValue("PPEid")
    Dim myPPEid As String ="PPEAddition" & myPPE

    ' ie builds "PPEAddition" with "s02"
    'PPEAdditions01,PPEAdditions02,PPEAdditions03 etc are the names in the UD4 dimension

    Dim scenario As String = args.NameValuePairs.XFGetValue("Scenario")
    Dim mytime As String = args.NameValuePairs.XFGetValue("Time")
    Dim myTPI As Integer

    Select Case mydiv

    Case="BBG"  ' this is my division identifier that is entered in the entity workflow profile text1 field

    myTPI = 1

    Case="INV"
    myTPI = 2
    Case="AHD"
    myTPI = 3
    End Select

    Dim myMemberId As Integer = BRApi.Finance.Members.GetMemberId(si,DimType.UD4.Id, myPPEid)
    Dim myVaryByScenarioTypeId As Integer = BRApi.Finance.Scenario.GetScenarioType(si,BRapi.Finance.Members.GetMemberId(si,DimType.Scenario.Id, Scenario)).Id
    Dim myVaryByTimeId As Integer = BRApi.Finance.Members.GetMemberId(si,DimType.Time.Id, myTime)

    Dim PPEtxtValue As String = BRapi.Finance.UD.Text(si, dimType.UD4.Id, myMemberId, myTPI, myVaryByScenarioTypeId, myVaryByTimeId)
    Return PPEtxtValue

    '=============================================================================

    Hopefully this will be of some help to others. I have kept all the formatting so that it can be dropped directly into an existing business rule.