Calculation in rules

Forums General discussion Calculation in rules

This topic contains 11 replies, has 4 voices, and was last updated by  Alexander Bautz 1 week ago.

  • Author
    Posts
  • #9814

    Gerard Graham
    Participant

    Hi there

    Is there a way of triggering a rule based on a calculation? For example if a the difference between two dates is greater than 30 days? I know this can be done in the Validation Settings for the list, but I’d like the message to appear when the end date changes rather than when the user attempts to save the record.

    Thanks

    Gerry

  • #9846

    Alexander Bautz
    Keymaster

    Currently you can do this calculation with [today] by comparing with [today]+30 (not currently documented), but not when comparing two date columns. I will however add this to the next release – BETA hopefully later tonight.

    Alexander

  • #9859

    Gerard Graham
    Participant

    Cheers

  • #22638

    Matthew Thompson
    Participant

    was this able to be added? if so what would the calc be?

  • #22642

    Alexander Bautz
    Keymaster

    Hi,
    You should be able to create a rule triggering on is greater than on lets say EndDate and select {StartDate}+30 in the This value field.

    Alexander

  • #25191

    Maciek Grischke
    Participant

    Thanks for this!

    I had to apply this rule in the holiday request form because people book holidays with wrong dates <facepalm>

    Everything needs to be idiot proof lol

  • #25200

    Maciek Grischke
    Participant

    Alexander, since sharepoint accepts dates in dd.MM.yyyy format (full stop) and we have users who use dots, the rule above doesn’t seem to be working in this case.

    Do I have to use JS replace() to each field or is there another way of doing this?

    My region is set to UK.

    Thanks.

  • #25213

    Alexander Bautz
    Keymaster

    I’m not sure I understand what you mean. What format is your SP site showing by default, and what is your users typing in?

    Does it show an error message in the field because of wrong format?

    Alexander

  • #25225

    Maciek Grischke
    Participant

    Alexander,

    Time in UK format is 06/05/2019 (with forward slash) and this is how it’s displayed in lists etc, however, users can enter this date as 06.05.2019 and SharePoint will accept it no problem. Unfortunately, when used with DFFS and the above snippet, there is no warning. The warning only works with 06/05/2019 date format.

    Hope this makes sense.

    Thanks.

  • #25234

    Alexander Bautz
    Keymaster

    I’m not sure how to fix this – the code looks at the default format for the input and can currently only calculate from this value. Maybe you can disable the input and force then to use the datepicker?

    Alexander

    • #25656

      Maciek Grischke
      Participant

      How can I disable the manual input and force users to only use a “date picker”?
      I’ve tried with “read-only” option, but it disables the field entirely. There’s no date picker button.

  • #25674

    Alexander Bautz
    Keymaster

    Hi,
    You must use Custom JS like this:

    jQuery("#dffs_YourDateColumn input").attr("disabled",true);

    Replace YourDateColumn with your field name.

    Alexander

You must be logged in to reply to this topic.