Date format for OOTB lookup associated field

Home Forums vLooup for SharePoint Date format for OOTB lookup associated field

Viewing 2 reply threads
  • Author
    Posts
    • #33939
      MikeS
      Participant

        Alexander,

        I am unable to eliminate the time stamp (00:00:00) on an OOTB associated field that is two removed from the Parent list. The vLookup to the Child pulls in a Child record that has an associated date field from a Child lookup to a third list (via OOTB SharePoint lookup). It is this date field that will not format properly in the parent (i.e., date only) with {dateFormat”:MM/dd/yyyy”} in the vLookup ViewFields Special Configuration entry.

        Thanks for your help,
        MikeS

        • This topic was modified 3 years, 5 months ago by MikeS.
      • #33948
        Alexander Bautz
        Keymaster

          The dateFormat function only works for date columns and not for lookup columns (this is what the additional lookup columns are identified as). You can fix it using a custom js function like this:

          function formatLookupDateCol(a){
              var r = a;
              if(a !== ""){
                  try{
                      var d = new Date(a.split(" ").join("T"));
                      r = d.toLocaleDateString(_spPageContextInfo.currentUICultureName);
                  }catch(ignore){
                      // Nothing
                  }
              }
              return r;
          }

          And this in the Special configuration in your vLookup field:

          {"function": "formatLookupDateCol"}

          Alexander

        • #33950
          MikeS
          Participant

            This works great in the forms. Thanks.
            However, the List view still shows the time stamp (00:00:00).

            MikeS

            • #33954
              Alexander Bautz
              Keymaster

                To use this in a list view you must add the custom function to a script editor web part in the view.

                Alexander

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