Dismiss Notice
We would like to remind you that we’re updating our login process for all 3CX forums whereby you will be able to login with the same credentials you use for the Partner or Customer Portal. Click here to read more.

Day of Week

Discussion in 'Call Flow Designer' started by Eric Osborn, Jun 13, 2017.

Thread Status:
Not open for further replies.
  1. Eric Osborn

    Joined:
    Mar 24, 2017
    Messages:
    27
    Likes Received:
    0
    Does someone know how to route based on day of week?

    I'm looking to do the following---

    Monday through Thursday from 9am to 5pm route to location A
    Friday 9am to 8pm route to location B
    Saturday and Sunday from 12pm to 8pm route to location C

    Thank you!

    Eric
     
  2. DL_

    DL_

    Joined:
    Mar 31, 2015
    Messages:
    55
    Likes Received:
    8
  3. Eric Osborn

    Joined:
    Mar 24, 2017
    Messages:
    27
    Likes Received:
    0
    Hey thank you for those.... From what I understand in other post he is using new Date().getDay() == 0 which should be for Sunday?

    When I compile, I get the namespace "Date" could not be found. Tried couple other ways using Microsoft article but not getting it. Time of day I think I'm good with.

    Eric
     
  4. DL_

    DL_

    Joined:
    Mar 31, 2015
    Messages:
    55
    Likes Received:
    8
    Wrong language. You need to use C# in the CFD.

    You can use an integer compare (i.e. 0 = Sunday) but you should also be able to use the constants as below to make it more readable.
    DateTime.Now.DayOfWeek == DayOfWeek.Sunday

    You can also use other operators such as
    DateTime.Now.DayOfWeek >= DayOfWeek.Monday && DateTime.Now.DayOfWeek <= DayOfWeek.Friday
    Just remember that Sunday is the lowest day and Saturday is the highest

    Test it (and other C# code) here: https://dotnetfiddle.net/7ghv7A
     
    #4 DL_, Jun 14, 2017
    Last edited: Jun 14, 2017
  5. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,609
    Likes Received:
    126
    Hi Eric,

    The articles that mention this:
    Are referring to the old VAD for v14, which uses Javascript. In the CFD for v15 you can't use Javascript, and that's why you're getting that error. You need to use C# instead, as very well explained by @DL_.

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Eric Osborn

    Joined:
    Mar 24, 2017
    Messages:
    27
    Likes Received:
    0
    Thank you and DL thank for that outline! I will try this out today.
     
  7. Eric Osborn

    Joined:
    Mar 24, 2017
    Messages:
    27
    Likes Received:
    0
    @dl @edossantos , Hey,

    Could you tell me if I wrote this right? I'm not getting it to work correctly. We open at 11am daily, close at midnight Sunday through Thursday and 2am on Friday and Saturday nights.

    ((DateTime.Now.Hour >= 9 && DateTime.Now.Hour <= 24) || (DateTime.Now.DayOfWeek == DayOfWeek.Saturday && DateTime.Now.Hour <2) || (DateTime.Now.DayOfWeek == DayOfWeek.Sunday && DateTime.Now.Hour <2))

    Thanks for your help!
     
  8. edossantos

    edossantos Support Team
    Staff Member 3CX Support

    Joined:
    Jun 27, 2007
    Messages:
    1,609
    Likes Received:
    126
    Hi @Eric Osborn,

    The expression looks good to me. I would just change:
    DateTime.Now.Hour <= 24

    to:
    DateTime.Now.Hour < 24

    Because the hour will never be 24. But anyway that will not cause a bug...

    So this is not working for you? What problem are you experiencing?

    Kind regards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Thread Status:
Not open for further replies.