``` --- id: exyg82texwv60f0ch7r1i7m title: |- sd...
# questions
g
Copy code
---
id: exyg82texwv60f0ch7r1i7m
title: |-
  sdgjsgd,,module.exports = {
    /**
     * Creates a note name with a year.month.name format.
     */
    OnWillCreate: {
      setNameModifier(props) {

        // placeholder name:
        let nameModifier = "John Doe";

        // Try to get the name first from selected Text, and secondly from the clipboard
        if (props.selectedText) {
          nameModifier = props.selectedText
        }
        else if (props.clipboard) {
          nameModifier = props.clipboard;
        }

        // Add a date component with year and month
        const curDate = new Date();
        const year = curDate.getFullYear();
        const month = curDate.getMonth() + 1; // getMonth is 0 indexed

        return {
          name: [year, month, nameModifier].join('.'),
          promptUserForModification: true
        };
      }
    },
    /**
     * Extracts the name component of the note title and capitlizes it
     */
    OnCreate: {
      setTitle(props) {
        const fName = props.currentNoteName;

        if (fName.includes(".") && fName.lastIndexOf(".") < fName.length) {
          const namepart = fName.substring(fName.lastIndexOf(".") + 1);
          const capitilized = namepart.split('-').map(element => element[0].toUpperCase() + element.substring(1));

          return capitilized.join(' ');
        }
        else {
          return fName;
        }
      }
    }
  }
desc: ''
updated: 1653210612441
created: 1653210612441
traitIds:
  - professional-connections
---