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 Workflow Scenario/Time setting

In snippets I have found this :

'Dim sValue As String = BRApi.Finance.UD.Text(si, dimTypeId, memberId, textPropertyIndex, varyByScenarioTypeId, varyByTimeId)

I am aware that the Text1 property attached to the WorkFlowProfile has the folowing attributes to get the various values stored under each TextN property field.
Attribute Index Is: Text1 = 18000, Text2 = 20000, Text3 = 22000, Text4 = 24000

So what is the appropriate syntax in a Business Rule that I could bring in the UDN TextN values.

Thanks

Mark

 

 

  • 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.

     

  • EricOsmanski's avatar
    EricOsmanski
    Valued Contributor

    Dim memberId As Integer = api.Members.GetMemberId(DimType.UD4.Id, "MemberName")
    Dim textPropertyIndex As Integer = 3
    Dim varyByScenarioTypeId As Integer = api.Scenario.GetScenarioType(api.Members.GetMemberId(DimType.Scenario.Id, api.Pov.Scenario.Name)).Id
    Dim varyByTimeId As Integer = api.Members.GetMemberId(DimType.Time.Id, api.Pov.Time.Name)

    Dim sValue As String = api.UD4.Text(memberId, textPropertyIndex, varyByScenarioTypeId, varyByTimeId)

    • MarkHoughton's avatar
      MarkHoughton
      Contributor

      Hi Eric,

      Thanks for the reply, but I am getting a couple of errors.  I cannot get the "varyByScenarioTypeId". I know this because I have tried to trap it with 

      Dim MyErr04 = "Msg04  >" & varyByScenarioTypeId & "<" 
      BRApi.ErrorLog.LogMessage(si, MyErr04)

      Also I cannot seem to resolve the "name" correctly either.

      I have tried these variations.

      Dim memberId As Integer = api.Members.GetMemberId(DimType.UD4.Id, "PPEAdditions01")

      Dim memberId As Integer = api.Members.GetMember(DimType.UD4.Id, "PPEAdditions01").memberid

      PPEAdditions01 is the name and the description of the UD4 item I am trying to work with. If I lock in the actual index number then I can pass on to the next step, but ....

      Basically I keep getting an "Object variable or with block variable not set" error message.

      Cheers for your consideration of this.

      • EricOsmanski's avatar
        EricOsmanski
        Valued Contributor

        What type of rule are you using? Is this a Dashboard XFBR String? If so, can you post the XFBRString you are using the CV?

        I wrote the above in a Finance BR, so I can re-write it for the Rule Type you are using.