cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Apostrophes in returned data

1379
Views
0
Helpful
0
Comments
This document was generated from CDN thread

Created by: David Wall on 23-04-2013 03:11:26 PM
Hello. I have a VXML application that returns several values to ICM via the FromExtVXML0 variable in a Subdialog_Return element. The values are packed into that variable as name=value pairs, as in A=ValueA,B=ValueB etc.

Most of the time it works fine, but when one of the values contains an apostrophe ('), it breaks the ICM script. The Run External Script node in ICM fails, even though no errors are shown in the VXML application activity log.
No other "special" characters seem to cause problems.
What can I do to escape returned strings to prevent this problem? It would be hard to modify the values themselves (e.g., turn "Tom's Diner" into "Tom\'s Diner" because of the way our database is, and because CallStudio doesn't support regex replacement.
Thanks in advance for any advice.

Subject: RE: Apostrophes in returned data
Replied by: Jameson Gagnepain on 23-04-2013 03:37:37 PM
David,
There is no built-in string modification or regex replacement in standard Call Studio elements, correct. The best solution may be to build a custom java element to do the "string cleanup". I'm not sure if you'll be able to pass non-escaped apostrophes into the settings of an element, so you may be stuck with making a custom Database element instead, which could escape the apostrophes before writing to its own element data.

Subject: RE: New Message from David Wall in Customer Voice Portal (CVP) - CVP - All
Replied by: Hemal Mehta on 23-04-2013 03:45:07 PM
There are so many ways to do this in java.  Just replace the apostrophe in incoming string with space.  Call a custom java action class.  You can achieve this with just couple of lines code in java.
Hemal

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Tuesday, April 23, 2013 3:12 PM
To: cdicuser@developer.cisco.com
Subject: New Message from David Wall in Customer Voice Portal (CVP) - CVP - All Versions: Apostrophes in returned data

David Wall has created a new message in the forum "CVP - All Versions": -------------------------------------------------------------- Hello. I have a VXML application that returns several values to ICM via the FromExtVXML0 variable in a Subdialog_Return element. The values are packed into that variable as name=value pairs, as in A=ValueA,B=ValueB etc.

Most of the time it works fine, but when one of the values contains an apostrophe ('), it breaks the ICM script. The Run External Script node in ICM fails, even though no errors are shown in the VXML application activity log.
No other "special" characters seem to cause problems.
What can I do to escape returned strings to prevent this problem? It would be hard to modify the values themselves (e.g., turn "Tom's Diner" into "Tom\'s Diner" because of the way our database is, and because CallStudio doesn't support regex replacement.
Thanks in advance for any advice.
--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/14582816 or simply reply to this email.

Subject: RE: Apostrophes in returned data
Replied by: David Wall on 23-04-2013 03:55:08 PM
I know that Java can do string substitutions, but "Toms Diner" and "Tom s Diner" are not the same as "Tom's Diner".
 
Interestingly, if I hard-code "Tom\'s Diner" into the value for the FromExtVXML0 variable, it won't validate. I would have expected the escape character to be recognized.

Subject: RE: New Message from David Wall in Customer Voice Portal (CVP) - CVP - All
Replied by: Hemal Mehta on 23-04-2013 04:04:06 PM
Yes, that is correct.  I will check in my system and confirm.

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Tuesday, April 23, 2013 3:55 PM
To: cdicuser@developer.cisco.com
Subject: New Message from David Wall in Customer Voice Portal (CVP) - CVP - All Versions: RE: Apostrophes in returned data

David Wall has created a new message in the forum "CVP - All Versions": -------------------------------------------------------------- I know that Java can do string substitutions, but "Toms Diner" and "Tom s Diner" are not the same as "Tom's Diner".

Interestingly, if I hard-code "Tom\'s Diner" into the value for the FromExtVXML0 variable, it won't validate. I would have expected the escape character to be recognized.
--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/14583603 or simply reply to this email.

Subject: RE: Apostrophes in returned data
Replied by: Janine Graves on 23-04-2013 04:04:28 PM
David - look at the following on the forum website, no telling what this will look like in an email.
The vxml gateway throws error.semantic because there are 5 reserved XML/VXML characters (single and double quote, less than, greater than, and ampersand) that must be escaped. If you don't want to write java, you can modify your database query in Studio so the database does the replacing of the single-quote with something else (like a dash).
Note that I'm using MySql and it also doesn't like the single quote (apostraphe) when I try to insert Joe's Grocery into a varchar field. To insert it as a value into the db, I have to use an escape code of \'
The following worked for me: select replace('\', '-', storeName) from stores where id=12345;
The table contains Joe's Grocery but above returned Joe-s Grocery
select replace('\'', '-', columname) from tablename where columnname=columnvalue
Inside the brackets I have:
single-quote
back-slash single-quote  (this is the escape code for the apostraphe)

single-quote
comma
single-quote
dash  (this is to replace the ' with a dash -)

single-quote
comma
columname
 

Subject: RE: Apostrophes in returned data
Replied by: Ryan Hilfers on 23-04-2013 04:06:22 PM
David Wall:
I know that Java can do string substitutions, but "Toms Diner" and "Tom s Diner" are not the same as "Tom's Diner".   Interestingly, if I hard-code "Tom\'s Diner" into the value for the FromExtVXML0 variable, it won't validate. I would have expected the escape character to be recognized.
  David, Only compilers will recognize escape sequences. When passing data through the ExtVXML arrays its simply being added as a string to the submit tag in the VXML coming from VXML Server. The gateway isn't a fan of this and throws an error.  There aren't any elegant ways of getting the apostrophe into ICM from an External Script that i know of...    you would have to get creative. I've been here and in my case, we simply removed them and ended up with with  "Toms Diner."      

Subject: RE: New Message from Ryan Hilfers in Customer Voice Portal (CVP) - CVP - Al
Replied by: Hemal Mehta on 23-04-2013 04:10:06 PM
I checked, we did the same.

From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]
Sent: Tuesday, April 23, 2013 4:06 PM
To: cdicuser@developer.cisco.com
Subject: New Message from Ryan Hilfers in Customer Voice Portal (CVP) - CVP - All Versions: RE: Apostrophes in returned data

Ryan Hilfers has created a new message in the forum "CVP - All Versions": --------------------------------------------------------------
David Wall:
I know that Java can do string substitutions, but "Toms Diner" and "Tom s Diner" are not the same as "Tom's Diner".

Interestingly, if I hard-code "Tom\'s Diner" into the value for the FromExtVXML0 variable, it won't validate. I would have expected the escape character to be recognized.


David,
Only compilers will recognize escape sequences. When passing data through the ExtVXML arrays its simply being added as a string to the submit tag in the VXML coming from VXML Server. The gateway isn't a fan of this and throws an error.
There aren't any elegant ways of getting the apostrophe into ICM from an External Script that i know of...    you would have to get creative. I've been here and in my case, we simply removed them and ended up with with  "Dans Diner."



--
To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/14583826 or simply reply to this email.

Subject: RE: Apostrophes in returned data
Replied by: Ryan Hilfers on 23-04-2013 04:14:02 PM
I guess I haven't tried XML escapes..  but i'm fairly certain you'd still have to parse that correctly on the ICM side..  which could be doable..     David,  you could try  "Tom's Diner"  and then in ICM conver it with a custom function...    concatenate(before("'",var),"'",after("'",var))   maybe??

Subject: RE: Apostrophes in returned data
Replied by: Janine Graves on 23-04-2013 04:15:46 PM
Oops - I shouldn't tested this further. Here's what you need if you want the Sql to do the replacement for you:

select replace('\'', '-', columname) as aliasName from tablename where columnname=columnvalue


example, select replace('\'','-',storeName) as storeName from stores where id=12345
Then you'll get back element data named 'storeName' with the apostrophe replaced with a dash (or any character you like).


Subject: RE: Apostrophes in returned data
Replied by: David Wall on 23-04-2013 04:22:19 PM
Thanks, everyone. I might try XML escapes (Janine, our values come from a custom Java element).

If anyone's writing down feature requests...this is a real limitation of CVP.

Subject: Re: New Message from David Wall in Customer Voice Portal (CVP) - CVP - All
Replied by: Janine Graves on 23-04-2013 04:26:06 PM
The xml escape works to get your info back to ICM. But then you'll have to use the suggestion of replacing the ''' with a single-quote in ICM script. On 4/23/2013 5:22 PM, Cisco Developer Community Forums wrote: David Wall has created a new message in the forum "CVP - All Versions": -------------------------------------------------------------- Thanks, everyone. I might try XML escapes (Janine, our values come from a custom Java element). If anyone's writing down feature requests...this is a real limitation of CVP. -- To respond to this post, please click the following link: http://developer.cisco.com/web/cvp/forums/-/message_boards/view_message/14583974 or simply reply to this email. -- Janine Graves
Create
Recognize Your Peers
Content for Community-Ad