Calendar appointment autofill (help with formula)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Emmker
    Member
    • Nov 2023
    • 64

    Calendar appointment autofill (help with formula)

    In the attached picture, I need to click on the lane of John MD after "test3" appointment, and on the modal that opens, I need to have "start time" prefilled with the last appointment's end time.
    I know that I need to define $lastAppointmentEndTime, that is closer to the "clicked time", on the timeline. and have it pre-fill the end time on the modal. But I don't how to define the "clicked time" to make the calculations.

    Is it even possible?
    Attached Files
  • Emmker
    Member
    • Nov 2023
    • 64

    #2
    I found a way.
    • I created a varchar field called 'test' just to momentarily hold the value of the start time that automatically takes from the clicking point.
    • Then I find the nearest event end time with record/findOne
    • Then I find the end Time of the event with the id that I found, with record\attribute
    • I give that value to the dateStart of the newly created event when saved.




    // variables
    $dateStart = dateStart;
    $NearestEndTimeEventId = record\findOne('Entity','dateEnd', 'desc', 'dateEnd<=', $dateStart);
    $NearestEndTime = record\attribute('Entity', $NearestEndTimeEventId, 'dateEnd');​


    ifThen(
    entity\isNew(),
    dateStart = $NearestEndTime)

    Comment

    Working...