Zum Hauptinhalt gehen

Programatically set value for Date Range Picker and Item Picker

Kommentare

9 Kommentare

  • Nico Burgerhart

    Laurens van der Burgt What is your viewer application? VertiGIS Studio Web?

    Perhaps you could share you configuration of the Set Form Element Property activity?

    And the result of the inspection / screenshot of the form?

    I can remember to have seen the same.for a Date Picker.

    0
  • Laurens van der Burgt

    Hi Nico Burgerhart,

    Thanks four your follow up.

    I am indeed using using VSW (version 5.20).

    The Set Form Element Property activity is inside my subflow for the onload event of the Date Range Picker.

    Property Name: value
    Property Value:
    ={
    startDate: new Date(Date.now() - 1000*60*60*24*7),
    endDate: new Date()
    }

    As you can see in the screenshot, the value of the element has been updated however the UI still shows the initial view with no selection.

    0
  • Ken Lyon

    I tried this expression and it also did not work

    ={
      "refValueType": "daterange",
      "startDate": "2023-05-15T07:00:00.000Z",
      "endDate": "2023-05-18T07:00:00.000Z"
    }

    This might be a limitation of the form element, at least for now. The good news is that we're in the process of migrating all of the form elements to use Material UI components. The Date Range Picker will use the React Date Range Picker component. We will be sure to test this sort of functionality as part of that migration.

    1
  • Nico Burgerhart

    I created a request for Laurens' issue:
    #41404 Programatically set value for Date Range Picker and Item Picker

    0
  • Zack Robison

    One trick that I've been able to use, occasionally, is to run =$form.actor.refresh() in an Evaluate Expression activity.

    I haven't tried this with a Date Range Picker before, but I have used this method to get other form elements to re-render when I see the correct element properties logged in the dev console but not reflected in the UI.  I've been using this a lot lately to update forms in other workflows (like a second WF updating a form in a first WF).

    I have encountered a bug setting Item Picker values recently... or perhaps it was list boxes?  I'm not positive which element it was, but I am positive that I'm setting values in lots of Item Pickers in 5.31 so I'm curious what the behavior there is for you folks.  I'd note that you need to be careful about form element items: you might sometimes be tempted to recycle items in multiple elements but don't do that that's a trap.

    0
  • Nico Burgerhart

    Zack Robison Is this =$form.actor.refresh()  the exact expression or should I change actor to a reference to the form element?

    0
  • Nico Burgerhart

    Laurens van der Burgt I got it to work with Web 5.23 / Workflow 5.33.1 with your syntax of the Set Form Element Property activity and without the use of $form.actor.refresh().

    I cannot get it to work to set a date for a Date Picker.

    1
  • Zack Robison

    Sorry I missed you, yes that is the syntax; it refreshes the entire form.  It only fixes a few of my form issues though haha.

    0
  • William Walker

    Are there any updates on how to set a date range picker with a Set Form Element Property? I have no problems with a date picker. This is what I have tried, based on the output of the date range picker

    ={
    "type": "DateRangePicker",
    "validates": false,
    "value": {
    "startDate": $date2.local,
    "refValueType":"daterange",
    "endDate":$date3.local
    }
    }

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.