Remove ' from document attribute
Remove ' from document attribute
I have a feature where users upload a document. If the document name includes an apostrophe ( ' ), such as "Jim's Statement.doc", it's a legit filename in most operating systems and it uploads fine. But trying to download it results in an error. I can't figure out how to use REPLACE_PATTERN for this since I must enclose the apostrophe within apostrophes, and this doesn't seem to fly. I am also not sure if this will work on a document attribute since the document is the whole blob and I'm not sure if the replace_pattern function would be addressing the filename or the data. Perhaps I need a Java script to catch it at file selection on the client. If so, I need someone to write that for me. $$
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
MySQL, AWS EC2, S3
PDFtk Toolkit
Re: Remove ' from document attribute
Try the following to remove the apostrophe:kklosson wrote:I have a feature where users upload a document. If the document name includes an apostrophe ( ' ), such as "Jim's Statement.doc", it's a legit filename in most operating systems and it uploads fine. But trying to download it results in an error. I can't figure out how to use REPLACE_PATTERN for this since I must enclose the apostrophe within apostrophes, and this doesn't seem to fly.
Code: Select all
REPLACE_PATTERN(BO.Attribute, '\x27', '')
Can't help you here. Try it and report back your results.kklosson wrote:I am also not sure if this will work on a document attribute since the document is the whole blob and I'm not sure if the replace_pattern function would be addressing the filename or the data. Perhaps I need a Java script to catch it at file selection on the client. If so, I need someone to write that for me. $$
Bob
Re: Remove ' from document attribute
REPLACE_PATTERN(FilledForm.Form, '\x27', ' ' )
This does not pass error checking when saving.
This does not pass error checking when saving.
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
MySQL, AWS EC2, S3
PDFtk Toolkit
Re: Remove ' from document attribute
Try using a SystemSettings attribute where you have the ' i.e you do REPLACE_PATTERN(FilledForm.Form, SystemSettings.CharApo, ' ' ). Written ad hoc so syntax may be wrong.kklosson wrote:I have a feature where users upload a document. If the document name includes an apostrophe ( ' ), such as "Jim's Statement.doc", it's a legit filename in most operating systems and it uploads fine. But trying to download it results in an error. I can't figure out how to use REPLACE_PATTERN for this since I must enclose the apostrophe within apostrophes, and this doesn't seem to fly. I am also not sure if this will work on a document attribute since the document is the whole blob and I'm not sure if the replace_pattern function would be addressing the filename or the data. Perhaps I need a Java script to catch it at file selection on the client. If so, I need someone to write that for me. $$
Henrik (V8 Developer Ed. - Windows)
Re: Remove ' from document attribute
I am able to solve my problem using the RENAME DOCUMENT action. However, there remains a need to search for an apostrophe in a text string and I cannot figure out how to do it.
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
MySQL, AWS EC2, S3
PDFtk Toolkit
-
- Posts: 2403
- Joined: Mon Jul 02, 2012 12:24 am
- Location: Ulaanbaatar, Mongolia
Re: Remove ' from document attribute
This works for me....
MyData.CleanString=REPLACE_PATTERN(MyData.ApostString,`'`,``)
MyData.CleanString=REPLACE_PATTERN(MyData.ApostString,`'`,``)
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Re: Remove ' from document attribute
In my original posting, I was just showing the format for the REPLACE_PATTERN function.
The complete action would be:
FilledForm.Form=REPLACE_PATTERN(FilledForm.Form, '\x27', '')
If that is what you did, what was the error you got? The above worked for me.
Mark's suggestion should also work.
The complete action would be:
FilledForm.Form=REPLACE_PATTERN(FilledForm.Form, '\x27', '')
If that is what you did, what was the error you got? The above worked for me.
Mark's suggestion should also work.
Bob
Re: Remove ' from document attribute
Okay and thanks all. I did not realize that ` (the backward thingie under the tilde) could be used in place of ' (apostrophe). I learned something useful!
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
MySQL, AWS EC2, S3
PDFtk Toolkit
Re: Remove ' from document attribute
I seem to still be struggling with this. I need to remove any apostrophe characters from file names added to a document attribute. FilledForm.Form represents a document attribute. Mr rule is:
FILE_NAME(FilledForm.Form)=REPLACE_PATTERN(FILE_NAME(FilledForm.Form),`'`,'')
This results in the attached validation error. has anyone roped this goat?
FILE_NAME(FilledForm.Form)=REPLACE_PATTERN(FILE_NAME(FilledForm.Form),`'`,'')
This results in the attached validation error. has anyone roped this goat?
- Attachments
-
- Validation Error.png (7.93 KiB) Viewed 6782 times
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
MySQL, AWS EC2, S3
PDFtk Toolkit
Re: Remove ' from document attribute
try using the CHR function,
or make a SystemSettings field with that character as the value
or make a SystemSettings field with that character as the value
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: Remove ' from document attribute
I ended up using the RENAME DOCUMENT action and that seems to work fine.
Thank you for responding.
Thank you for responding.
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
MySQL, AWS EC2, S3
PDFtk Toolkit
Re: Remove ' from document attribute
I reported a bug in the last few months, where the rename document was working, but it left the original file there. So if you rename the file A to file B, it was copying it instead of renaming it.
Can you check your physical directories and see if this is happening for you?
Can you check your physical directories and see if this is happening for you?
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: Remove ' from document attribute
Lol
Didn't realize this was a long thread. Didn't read the prev msgs.
I also reported that if the filename had a '#' In it, it would save file but you couldn't reopen it if it was a pdf.
This might be corrected in 8.5 later builds.
Didn't realize this was a long thread. Didn't read the prev msgs.
I also reported that if the filename had a '#' In it, it would save file but you couldn't reopen it if it was a pdf.
This might be corrected in 8.5 later builds.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: Remove ' from document attribute
Thanks. My assessment is that apostrophe and hash symbol will fail when downloading. I tried many other characters that all work. I am storing it in the database so I don't think the duplication issue is an issue. This update rule works:
IF FILE_NAME(FilledForm.Form) CONTAINS `'` OR
FILE_NAME(FilledForm.Form) CONTAINS `#` THEN
RENAME DOCUMENT FilledForm.Form TO REPLACE_PATTERN(FILE_NAME(FilledForm.Form),`'`,'') + '.pdf'
RENAME DOCUMENT FilledForm.Form TO REPLACE_PATTERN(FILE_NAME(FilledForm.Form),`#`,'') + '.pdf'
IF FILE_NAME(FilledForm.Form) CONTAINS `'` OR
FILE_NAME(FilledForm.Form) CONTAINS `#` THEN
RENAME DOCUMENT FilledForm.Form TO REPLACE_PATTERN(FILE_NAME(FilledForm.Form),`'`,'') + '.pdf'
RENAME DOCUMENT FilledForm.Form TO REPLACE_PATTERN(FILE_NAME(FilledForm.Form),`#`,'') + '.pdf'
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
MySQL, AWS EC2, S3
PDFtk Toolkit