Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Date playback

Hi,

I just want to check if there is a better way of getting what i want from the system.

Basically i have implemented a script for customers to call in, pass some security checks using account number and DOB which are verified with a DB Get. Once passed they can activate their next order and the information is written back to the DB for upload into CRM.

the next phase was for the CRM to populate the DB i read from with the customers delivery date. So far i have tested 2 methods of doing this;

  1. Store the delivery date as 3 x integer values for day, month, year. Then use the credit card expiration generator type for the prompt out to a delivery date prompt (in GB language)
  2. Store the delivery date in full as a string (("MM/DD/YYYY") im not usre what would happen in UK format). Use a set step to copy the delivery date string to a delivery date Date vairable. Then use the standard Date generator type to play the date, skipping the year

Like i say, both work but im not sure which is best. One other thing i would like to add for the benefit of our elderly customers is to play the delivery date and then the number of calendar days that the given date is away from now. Would that effect the best method? any ideas how i would calculate just the days between D[now] and D[%deliverydate%]?

Best wishes

Jon

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Date playback

If both options work, then either is a good solution.  I have not tested either method though, so I'm relying on your word that they work.  The great thing about scripting/programming, is there is no one right way of solving a problem.  If there was, then there would be a UCCX book telling you exactly how you should be doing this.  I say, as long as you are not causing errors or making it harder on the caller, do whatever you want on the backend.

As for your number of days problem, either solution will net you what you want, though you may have more or less steps invovled in each approach.

Here's a small example on how you would get the integer for the number of days between your stored date and today:

Using three integer values and assuming they are held in month, day and year as ints:

/* We subtract one from the month value, because months are based on a zero-indexed array of months */

/* We subtract 1900 from the year, because the input is the number of years since 1900 */

Do { delivery_date.setMonth(month - 1); delivery_date.setDate(day); delivery_date.setYear(year - 1900); }

/* 86400000 is the number of milliseconds in a day.  We are simplifying the long value to focus on days only */

Set days_until_delivery_date = delivery_date.getTime() / 86400000 - today.getTime() / 86400000

Play Prompt (--Triggering Contact--, P[delivery_date_is] + N[days_until_delivery_date] + P[days_away])

Using a string value and assuming it is held in month_day_year in the following format "mm/dd/yyyy":

Set delivery_date = new Date(month_day_year)

/* 86400000 is the number of milliseconds in a day.  We are simplifying the long value to focus on days only */

Set days_until_delivery_date = delivery_date.getTime() / 86400000 - today.getTime() / 86400000

Play Prompt (--Triggering Contact--, P[delivery_date_is] + N[days_until_delivery_date] + P[days_away])

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
Green

Date playback

Jon,

Have you used the Expression Editor to call Java functions? How are your Java skills? You can easily do it with the substring() function. Let's see

if variable String ddmmyyyy = 12091950

    String mmSddSyyyy = ddmmyyyy.substring(2, 4) + "/" + ddmmyyyy.substring(0, 2) + "/" + ddmmyyyy.substring(4, 8);

and variable String mmSddSyyyy = 09/12/1950

Regards,

Geoff

12 REPLIES

Re: Date playback

If both options work, then either is a good solution.  I have not tested either method though, so I'm relying on your word that they work.  The great thing about scripting/programming, is there is no one right way of solving a problem.  If there was, then there would be a UCCX book telling you exactly how you should be doing this.  I say, as long as you are not causing errors or making it harder on the caller, do whatever you want on the backend.

As for your number of days problem, either solution will net you what you want, though you may have more or less steps invovled in each approach.

Here's a small example on how you would get the integer for the number of days between your stored date and today:

Using three integer values and assuming they are held in month, day and year as ints:

/* We subtract one from the month value, because months are based on a zero-indexed array of months */

/* We subtract 1900 from the year, because the input is the number of years since 1900 */

Do { delivery_date.setMonth(month - 1); delivery_date.setDate(day); delivery_date.setYear(year - 1900); }

/* 86400000 is the number of milliseconds in a day.  We are simplifying the long value to focus on days only */

Set days_until_delivery_date = delivery_date.getTime() / 86400000 - today.getTime() / 86400000

Play Prompt (--Triggering Contact--, P[delivery_date_is] + N[days_until_delivery_date] + P[days_away])

Using a string value and assuming it is held in month_day_year in the following format "mm/dd/yyyy":

Set delivery_date = new Date(month_day_year)

/* 86400000 is the number of milliseconds in a day.  We are simplifying the long value to focus on days only */

Set days_until_delivery_date = delivery_date.getTime() / 86400000 - today.getTime() / 86400000

Play Prompt (--Triggering Contact--, P[delivery_date_is] + N[days_until_delivery_date] + P[days_away])

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Date playback

Thanks Anthony.

Ive started a fresh to keep it simple and used the wording for your variables instead. Unfortunatly i can get neither to work.

I tried the first method;

created Int variables for setMonth, setDate and setYear. I manually punched in a date in the future into these.

created String (tried Date too) variable for delivery_date

added a Do step with the expression "{ delivery_date.setMonth(month - 1); delivery_date.setDate(day); delivery_date.setYear(year - 1900); }" (no " of course)

Then i get invalid identifier month line1 col 24

Then i tried the seccond method;

set the delivery_date string to be "08/28/2012".

added a Set step with the expression "delivery_date.getTime() / 86400000 - today.getTime() / 86400000"

I get undefined method: getTime for class java.lang.String (line1:col1)

Sorry if ive missed something stupid here, java is not my strong point. I would attach the script but it doesnt really contain anything other than the variables. Im running UCCX premium 8.5.

Thanks again.

/Jon

Date playback

Two things:

1. It sounds like you do not have a variable named month.  Please screenshot your variable pane and submit.

2. It sounds like either one or both of your variables: delivery_date or today are of type String.  Again, a screenshot of your variables would help.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Re: Date playback

i already amended the setMonth to just Month, now i get a simmilar message to the other method " undefined method: SetMonth for class: java.lang.string

Date playback

gbljoba wrote:

i already amended the setMonth to just Month, now i get a simmilar message to the other method " undefined method: SetMonth for class: java.lang.string

Good, you figured out the name issue.  Now, you are trying to use a Date method on a String object.

What you need to do is, change your Type for delivery_date to Date.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Date playback

Ah nuts ive come across another problem. Currently our callers enter in their DOB in DDMMYY where it is checked in a DB in format DDMMYY i.e no /. If they dont match they are told to enter it again at the moment. I didnt have an aweful lot of time to get the script the way i wanted it initially. Now I want to playback the entered DOB confirmation as a date instead for confirmation instead of a prompt to just enter it again.

so the problem i have is that the DOB is like 19042012 and i need it to be in 04/19/2012 so the set step can set a valid date variable so it can be played back as "the 19th of April 2012".

/Jon

Green

Date playback

Use your Expression Editor to manipulate the string and insert the slashes so "19042012" becomes "04/19/2012". There are simple Java utility functions that can help.

Regards,

Geoff

New Member

Re: Date playback

Hi Geoff,

Yes that's what I'm trying to do I just don't know how to split up the number, rearrange it and add the slashes. I can only do this with separate variables

/jon

Sent from Cisco Technical Support iPad App

Green

Date playback

Jon,

Have you used the Expression Editor to call Java functions? How are your Java skills? You can easily do it with the substring() function. Let's see

if variable String ddmmyyyy = 12091950

    String mmSddSyyyy = ddmmyyyy.substring(2, 4) + "/" + ddmmyyyy.substring(0, 2) + "/" + ddmmyyyy.substring(4, 8);

and variable String mmSddSyyyy = 09/12/1950

Regards,

Geoff

New Member

Re: Date playback

thanks Geoff,

My java skills are none existent. It's probably something I should try to get into as my scripts are relatively feature rich and could probably be made more efficient.

I will give that a bash in the morn

Cheers

Jon

P.s any recommendations on reading up on the basics of java ?

Sent from Cisco Technical Support iPad App

New Member

Re: Date playback

Many thanks to Anthony and Geoff for the help. In the end i left out the days until delivery and just concentrated on the date playbacks.

In the interests of sharing i have attached a script that i have been using to test out various methods of turning collected digits and DB get strings into dates and account numbers for voice prompts. Hope it eventually helps someone out.

Have a good weekend all.

/Jon

Date playback

Sweet! Thanks for sharing the results.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
454
Views
0
Helpful
12
Replies
CreatePlease to create content