0

Create an appointment for next week

Hi All,

I have a button in a Dashboard to create an appointment and popup the new record. 
The new Appointment record has the date field set for Today as the default. It works fine.

I have tried to create 2 similar button formulas that will create the record with tomorrows date and one with next weeks date( today() +7) without success. 

I would appreciate some suggestions—thanks for looking!

 

Sam

11 replies

null
    • Rafael Sanchis
    • Rafael_Sanchis
    • 1 mth ago
    • Reported - view

    Hi Sam one question how you resolve the button to create a appointment.

    let term := text(appointment(datetime(Date, From), 'Time Internal'));
    do as server
        Appointment := term
    end
    

    I try this but don't work

      • Sam.1
      • 1 mth ago
      • Reported - view

       hi Rafael, thanks for looking! I tried with the time interval but I’ll try again. 

      I’ll post the answer if I get it sorted out.

      thanks

    • Fred
    • 1 mth ago
    • Reported - view

    This works for me:

    Appointment := appointment(datetime(Date + 7), 3600000 * 4)
    

    Appointment is my appointment field.

    appointment() is the command to set an appointment field.

    Date is a date field.

    3600000 is the number of milliseconds in an hour so I'm adding 4 hours to start time

    You can also do:

    Appointment := appointment(datetime(today() + 7), 3600000 * 4)
    
      • Rafael Sanchis
      • Rafael_Sanchis
      • 1 mth ago
      • Reported - view

       

      A little modify the field 'Time Hours' is a numeric field.

      Apparently works

      • Sam.1
      • 1 mth ago
      • Reported - view

       Sorry for the delayed response. Busy Day.

      Thank you for sharing. This looks useful!

      Please look at the file attached to the reply for Fred.

      • Sam.1
      • 1 mth ago
      • Reported - view

       Hi Fred, I apologize for the delay.

      Attached will be found a small sample database.

      You will see that the default method of making the appointment is with a plain Date field. I'm hoping to have the buttons create an appointment for tomorrow and one for next week. There is a formula within each button. On my end, they create an appointment for today only.

      thanks for looking!

    • Fred
    • 1 mth ago
    • Reported - view
     said:
    You will see that the default method of making the appointment is with a plain Date field. I'm hoping to have the buttons create an appointment for tomorrow and one for next week. There is a formula within each button. On my end, they create an appointment for today only.

     Take a look at the Ninox docs for appointment().

    So the format is:

    appointment(start, end) or appointment(start, duration)
    To convert 2 given time-related values to an appointment.

    So my reply shows an example of (start, duration).

    Your code is missing this format, and a couple of other typos. You wrote:

    let newRec := (create APPOINTMENTS);
    APPOINTMENTS.(Appointment := date(today()) + 1);
    openRecord(newRec)

    1) If you want to modify the Appointment field of the newly created record then you need to reference that variable in line 2.

    let newRec := (create APPOINTMENTS);
    newRec.(Appointment := date(today()) + 1);
    openRecord(newRec)

    2) Now you need to add the appointment() command to line 2 so you can add an appointment. We will follow the appointment(start, duration) format for the Create Tomorrow's Appointment button:

    let newRec := (create APPOINTMENTS);
    newRec.(Appointment := appointment(datetime(today() + 1), 3600000 * 4));
    openRecord(newRec)
    

    You can change the + 1 to +7 for the Next Week button.

      • Sam.1
      • 1 mth ago
      • Reported - view

       thank you for all the time spent! I could have named the fields better as code 1 needed a change from appointment--> 'Appointment Date'. Also, I can not see why the +1 needs to be +2. And the +7 needs to be +8 for the date to be moved forward 1 and 7 days respectively.

    • Fred
    • 1 mth ago
    • Reported - view
      • Sam.1
      • 1 mth ago
      • Reported - view

       I have checked to see if there are any triggers or formulas that would cause the difference.

      Nothing. I’m using the Mac app.

      The only thing I have set is the default for Today in the Appointment Date field.

      Used it on the server. Same thing, the formula needs to be +2 for the date to be tomorrow.

      let newRec := (create APPOINTMENTS);
      newRec.('Appointment Date' := date(today()) + 2);
      openRecord(newRec)

      I took out the date before today()---got it now.

      thanks

      • Sam.1
      • 1 mth ago
      • Reported - view

        got it! I had date(today()). Removed the date. 

      Thanks again!

Content aside

  • Status Answered
  • 1 mth agoLast active
  • 11Replies
  • 75Views
  • 3 Following