Forum Discussion

KR2012's avatar
KR2012
New Contributor
13 hours ago

today's date to be populated as the default value


Hello, I am using a textbox to input a date, and its action property is linked to a parameter with the type set to "Input Type." When running the dashboard, the user wants today's date to be populated as the default value instead of manually entering a date. Has anyone tried using the Date function with the input parameter type for this purpose? thank you!

 



  • manthangandhi's avatar
    manthangandhi
    New Contributor III

    Hi,

    In the input parameter default value you can write a XFBR String function to call Dashboard XFBR rule and within that rule you can write a function to return the current date using VB.Net or C# functions.

    This can solve the issue.

    Thanks,

    Manthan

  • BenEppel's avatar
    BenEppel
    New Contributor II

    Hello,

    If you want to default the parameter to today's date, and also be able to manually change the parameter, you'll want to use a dashboard extender rule. This rule allows you to set parameters on dashboard load.

    Create a new Dashboard Extender rule and find where it says Case Is = DashboardExtenderFunctionType.LoadDashboard. Below that replace "TestFunction" with your function name, change this loadDashboardTaskResult.ChangeCustomSubstVarsInDashboard to True, and add in the logic you would like to get today's date like below. YourParamName also needs to be replaced with the name of your dashboard parameter.

    		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardExtenderArgs) As Object
    			Try
    				Select Case args.FunctionType
    					
    					Case Is = DashboardExtenderFunctionType.LoadDashboard
    						If args.FunctionName.XFEqualsIgnoreCase("YourFunctionName") Then 'Replace Name
    							
    							'Implement Load Dashboard logic here.
    							
    							If args.LoadDashboardTaskInfo.Reason = LoadDashboardReasonType.Initialize And args.LoadDashboardTaskInfo.Action =  LoadDashboardActionType.BeforeFirstGetParameters Then
    
    								Dim loadDashboardTaskResult As New XFLoadDashboardTaskResult()
    								loadDashboardTaskResult.ChangeCustomSubstVarsInDashboard = True 'Make sure it is set to True
    								loadDashboardTaskResult.ModifiedCustomSubstVars = Nothing
    								
    								Dim TodaysDate As String = System.DateTime.Now.ToString 'Example logic, might need some formatting changes
    								
    								loadDashboardTaskResult.ModifiedCustomSubstVars.Add("YourParamName", TodaysDate) 'Update with your parameter
    
    								
    								Return loadDashboardTaskResult
    								End If
    						End If

    Place your business rule in the highlighted area below

    Place the rule on the main dashboard pane that is being ran.

    Thanks,

    Ben