Blogs
Our community blogs
-
- 17
entries - 9
comments - 4157
views
Recent Entries
Latest Entry
#3: Be more flexible on dates!
VBScript → Lua
Please note: there is also a version for Lua based Call Routing available: #17: Be more flexible on dates! (Part 2 - Lua)
Within the GSE of you have a Time block which can be used to check (beside others) for time spans:
You might noticed already that in here it is not possible to take the dates (or times) from within variables. So only hard coded time spans can be checked with this block.
In case you need it more flexible and use variables this block can't be used. But the GSE wouldn't be the GSE if there wouldn't be another easy solution for this problem.
We just have to do the comparison by ourselves with a little bit of VBScript. Within VBScript there is a DateDiff function available, which returns the difference of two dates in any needed unit, like days, weeks, months, years.
Dim nDifference nDifference = DateDiff( "d", CDate("01.09.2019"), CDate("30.09.2019") )
This example calculates the difference between the 01.09.2019 and 30.09.2019 in days and stores it into a variable.
If the second date is larger/later than the first date, the result is a positive number. If the second date is smaller/earlier than the first date, the result is a negative number. The function CDate converts a given date into a VBScript "date" data type.
So to check if the current date is within a given time span, we need to call DateDiff two times. The first time to check if the current date is larger/later than the start date. The second time to check if the current date is smaller/earlier than the end date.
To do this, we simply use two Evaluate blocks in a row. To check if the current date is within a given time span, where the start date and end date is given in variables, we can simply use two such blocks:
with
and
and
Please note: in this example the start and end date are included in the time span. If you want them to be excluded from the time span just check for "> 0" instead of ">= 0".
The current date is taken from the GSE build in function CurDate(). It would also be possible to use the VBSript function Now. The difference between both functions is, that CurDate() returns the date according the configured location time zone of the script user, while Now simply returns the date of the server machine.
To put everything together into a handy little script I have configured the two variables for start and end date as parameters of the GSE script, so they can be easily set from the call routing manager. If I am on vacation my voicemail will be started, otherwise I want my regular call routing to be executed.
Rule properties:
And this is how it looks in the call routing manager:
So with a little bit of VBscript and two Evaluate blocks we are able to check for time spans ourselves and don't need the static/hard coded Time block.
You can download this tiny script from here:
Enjoy!
PS: don't miss to take a look into the ECR Useful Link Collection
- 17
-
This post sums this great article series up. Mirjam spent quite some time to identify all those tips and to publish them here on Swyx Forum.
As the article series dates some years back there had been a couple of articles I have not re-posted again, simply because they were not valid with a current SwyxWare version anymore.
But the vast majority of the tips is still valid with current SwyxWare versions and that's why I decided to re-post them to make them available again after the old Swyx Forum went offline.
Thank you very much Mirjam for all your efforts!
- Read more...
-
- 0 comments
-
- 6
entries - 42
comments - 2302
views
Recent Entries
Latest Entry
Call Parking / Open Hold
A common feature request I have had over the years is a Call Park feature, and the usual stock reply to Can Swyx Do..... is NO! but...... of course this is software and anything is possible. I have seen a number of ways of implementing a call park feature some really clever ones that use the conference bridge facility in Swyx to some not so clever ones using analog adaptors to have live logged on extensions which are used to pick up from... sudu call park.
Before I saw the conference room version written by Tom I had a go myself and came up with this solution a couple of years ago and put it online. Recently a couple of requests came in for the source code so I thought I would upload it here.
This is another illustration of how different solutions to problems can be developed with Swyx, there is no right or wrong way, they either work or don't.So next time someone asks if "Swyx can do ......... ?", reply "No it can't, but you can" 🙂
- 6
-
- 9
entries - 0
comments - 2169
views
Recent Entries
- 9