Pricing Blog

How to use Custom Actions increasing working days button.

  • uunicode-1263603856642936924

    unicodes

    1 year ago

    I have created a custom action for increasing now() with a specific number of working days. I called it on "click" but how to asign it to a variable? In function I can not find my "AddWorkingDays".
    1263603858115133542-Screenshot_2024-07-19_at_00.08.15.png
    1263603857305505802-Screenshot_2024-07-19_at_00.05.12.png
    1263603857745903729-Screenshot_2024-07-19_at_00.08.29.png
  • andreasmoller-1263604709336551457

    Andreas Møller

    1 year ago

    You cant return from a custom action. You have to trigger and event.
  • This is also not something you need an action for. Formulas are intended for pure computations like this.
  • You can also do this in toddles formula editor without using custom js
  • uunicode-1263605211528691742

    unicodes

    1 year ago

    I haven't understand already the toddles formula editor. Tried to transform it from custom actions but it stops and returns empty
  • uunicode-1263605995603759166

    unicodes

    1 year ago

    Let me try again making it in formulas.
  • andreasmoller-1263606191578419311

    Andreas Møller

    1 year ago

    I am off to bed. Good luck, If you have more questions ill get back to you tomorrow.
  • uunicode-1263606456909824121

    unicodes

    1 year ago

    thank you Andreas! Good night.
  • uunicode-1263825584283324536

    unicodes

    1 year ago

    Do you know how to add getDay() (from Javascript) in toddle functions?
  • lucasg-1263949236706345031

    Lucas G

    1 year ago

    toddle doesn't have a getDay node but you can format dates to return days of week
  • uunicode-1263950379981475974

    unicodes

    1 year ago

    Lucas, is there a guide how to use Custom Actions?
  • lucasg-1263950694948409478

    Lucas G

    1 year ago

    The docs are the only source I know
  • For a custom action, if you want to return something, you need to use ctx.triggerActionEvent('eventName', eventData)
  • Where eventName is the name of your event (created on the left panel there under arguments)
  • And eventData is the data that event should return
  • So quickly looking at the bottom of your code there, it would be ctx.triggerActionEvent('currentDate', currentDate) assuming you name your event 'currentDate`
  • Instead of return currentDate'
  • lucasg-1263951866547535964

    Lucas G

    1 year ago

    This might actually work better as a custom formula, in which case you wouldn't need the ctx.triggerActionEvent
  • uunicode-1263954591087722606

    unicodes

    1 year ago

    I tried in custom formula, but I can not find the logic. I was stuck at getDay() 🙂
  • lucasg-1263955234678640671

    Lucas G

    1 year ago

    Not a toddle formula, a custom one
  • It also uses JS
  • You can create one from the left panel, under where you create custom actions
  • max.kayr-1264092669617901609

    Max

    1 year ago

    Hi! I'm not sure if you managed to get it working already. Here is how you can do it with a custom formula and with a Toddle visual formula 🙂
    1264092668829372496-image.png
    1264092669437808710-image.png
    🤗1
  • uunicode-1264198293626552330

    unicodes

    1 year ago

    Let me try it! Thank you Max