Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RelativeDateItem - how to show/set value as 'N days ago' with offset 20

    Hi I have a RelativeDateItem.

    I can get the value with relativeDateItem.getRelativeDate().getValue() which says what option is selected. I.e Today/yesterda/Current day of last month/N days ago with offset etc.


    However, how can I set the value of the relativeDateItem such that it shows the specific drop down values like yesterday or N days ago with offset and not the actual date. Is there anything like relativeDateItem.setRelativeDate() etc?

    #2
    Yesterday can be set if you do setValue(RelativeDate.YESTERDAY.toString()). YESTERDAY is a built-in option that correlates to $yesterday. I haven't found a built-in option for N days ago, for instance, though it might be in there. I tried using TimeUnit but it didn't have an effect on the RelativeDateItem. It just set the field to Today's date and time.
    Last edited by bwilkins30; 23 Jan 2013, 14:31.

    Comment


      #3
      It's pretty simple once I figured it out.

      In the onChanged of your ChangedHandler, call

      Code:
      RelativeDate relDate = myItem.getRelativeDate()
      This will return you a built-in representation for the relative date. So by using the debugger, I was able to determine that N days ago with 20 as the setting returns:

      Code:
      -20d[-0D]
      so, all you have to do is call myItem.setValue("-20d[-0D]") and that will show N days ago with 20 as the value.

      Comment


        #4
        Originally posted by bwilkins30 View Post
        It's pretty simple once I figured it out.

        Code:
        -20d[-0D]
        so, all you have to do is call myItem.setValue("-20d[-0D]") and that will show N days ago with 20 as the value.
        Is this really supposed to work ? Atleast when running 4.0p nightly from a while back this just barfs out an exception if called on a RelativeDateItem. It seems to work on simple presets (such as $today, -1M, ...) but when the value is more complex (with [..] specifiers for example) it seems that it is not supported. We are struggling to get RelativeDateItem initialized to a quantity containing value with little luck.

        Comment


          #5
          We're not seeing an issue with any of our automated tests, so try posting a minimal, ready-to-run test case that reproduces a framework issue when you run it in the unmodified, stock SDK.

          Comment

          Working...
          X