Extracting year from date field for use in Title

Forums Classic DFFS Extracting year from date field for use in Title

Viewing 4 reply threads
  • Author
    Posts
    • #6764
      Jeff Law
      Participant

      Hi,
      Just wondering about the best approach for this. I want to take the year from the start date of an event and put it into a separate field, and then use that as part of the new Title for the item.

      I want to use Year in a separate field so that I can do grouping on the items, and it is incorporated into the Title to help uniquely identify an entry.

      Im guessing that I will need to build a small function and add this somewhere, probably in the Custom JS in the Misc tab, and call this somehow when saving the item. Or is there an easier way with some “in-built” functions directly.

      There seems to be so many different ways of doing things, its hard to know how to start!

      Regards
      Jeff

    • #6765
      Jeff Law
      Participant

      Hi,
      Well there might be other ways, but I have got this working using the Custom JS section, and referring to the function in the rules.

      In Custom JS:

      
      
      function calcTournamentYear() {
      	var startDate = getFieldValue("EventDate");
      	var newStr = startDate.substring((startDate.lastIndexOf('/')) + 1);
      	setFieldValue("TournamentYear", newStr, false);
      }

      I have a rule to trigger if the field “Start Time” is changed and I have specified calcTournamentYear in the Run these functions field.

      Regards
      Jeff

    • #6766
      Alexander Bautz
      Keymaster

      Hi,
      You might be better off using a calculated column like this:

      =YEAR([Start Time])&""

      Set the output to “single line of text” and please note the &”” at the end – this is to force the output as text and not a number.

      Alexander

    • #6767
      Jeff Law
      Participant

      Hi,
      That’s what I have used, but as calculated columns are not appearing in the list of fields for me to display when laying out fields on the Tab page, I started looking for another way of doing this.

      Should calculated fields be recognised in the list of available fields in DFFS?

      While on this subject I also notice that the additional fields that have been selected in defining lookups are also not available for displaying. eg if I have a list of Venues that also have an address and a phone number, and I have defined these to also be returned when I do a lookup on the Venue Name, these extra two fields are not available in the list of fields in DFFS.

      Regards
      Jeff

    • #15211
      Gianni Zanetti
      Participant

      Hi, I have the same issue with some calculated fields that would be useful for the user if he sees them while editing other fields. Any chance to have an option to display calculated fields, (I would have no concern if they would not be updated on the fly when editing is done)

Viewing 4 reply threads
  • You must be logged in to reply to this topic.