Set Date Picker with correct format

Home Forums Autocomplete Set Date Picker with correct format

Tagged: 

Viewing 1 reply thread
  • Author
    Posts
    • #23075
      Shane Miller
      Participant

        Hello Alexander,
        I am using Autocomplete to set a date picker field of a related list item. the format after setting the field comes out as YYYY-MM-DD 0. Any help you could provide on how to format this would be very helpful. Below is the Autocomplete from the custom JS tab. Thank you very much for your help.

        spjs.ac.textField({
        “applyTo”: “exerciseName”,
        “helpText”: “Copy and Paste Exercise name here…”,
        “loadText”: “”,
        “listGuid”: “{5069237B-77D7-4E64-9120-DCE5AF2125DC}”,
        “listBaseUrl”: “/sites/XT”,
        “showField”: “Generated_x0020_Exercise_x0020_I”,
        “searchFields”: [],
        “filterCAML”: “<Where><Geq><FieldRef Name=’Exercise_x0020_Start_x0020_Date’/><Value Type=’DateTime’ IncludeTimeValue=’FALSE’><Today /></Value></Geq></Where>”,
        “useREST”: false,
        “preloadData”:false,
        “filterREST”: “”,
        “optionDetailFields”: [],
        “optionDetailPrefix”: [],
        “enforceUniqueValues”: true,
        “rowLimit”: 15,
        “listOptionsOnFocus”: false,
        “minLengthBeforeSearch”: 3,
        “reValidateOnLoad”: false,
        “allowAddNew”: false,
        “isLookupInSelf”: false,
        “addNewAdditionalFields”: [],
        “multiselect”: false,
        “multiselectSeparator”: “; “,
        “orderBy”: [],
        “clearSetFieldsOnInvalidSelection”: false,
        “setFields”: [
        {
        “fromFIN”:[“Exercise_x0020_Start_x0020_Date”],
        “joinBy”:””,
        “toFIN”:”currentStart”,
        “parseFunction”:””,
        “skipIfEmpty”:false
        },
        {
        “fromFIN”:[“Exercise_x0020_End_x0020_Date”],
        “joinBy”:””,
        “toFIN”:”currentEnd”,
        “parseFunction”:””,
        “skipIfEmpty”:false
        }
        ],
        “debug”: false
        });

      • #23083
        Alexander Bautz
        Keymaster

          Hi,
          You must use the parseFunction like this:

          	...
          	...
          	"setFields":[
                  {
                   "fromFIN":["Exercise_x0020_End_x0020_Date"],
                   "joinBy":"",
                   "toFIN":"currentEnd",
                   "parseFunction":"fixDateValue",
                   "skipIfEmpty":false
                  }
              ]					
          });
          
          function fixDateValue(s){
              var date = new Date(s[0]);
              // Fix the returned format to match your current date format
              return  (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear();
          }

          Alexander

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.