Use javascript "replace" function in dynamic pdf created with Livecycle designer

cindyp9252819

07-07-2015

Hi -

I have created a multi-field pdf form that includes a button that generates an email.  The email body contains content of specified fields.  All this is working fine.  The issue is that in one of the fields, a network path is entered.  When the email is generated that information is included in the body of the email and often the resulting link is broken, because the path often contains spaces in the path name.  It seems that i can fix this issue if the empty spaces in the path are replaced by %, for example, prior to having users generate the email.

How do I create a javascript event that looks at the raw value of the field where the network path is stored and replace any blank spaces with a % sign?

Thank you so much in advance for your help!!!!

Answers (5)

Answers (5)

cindyp9252819

08-07-2015

Thank you!!! Your help with the replace option worked perfectly!!!  I was able to replace the spaces with %20 using your code above...at that point I still had an issue because the resulting NETWORK link (vs. hyperlink) was no longer being recognized when it was copied into my auto-generated email (it didn't understand %20)...but I solved that too by adding the'File://' + to the tfFieldWithSpaces exit event:

tfFieldWithNoSpaces.rawValue = 'File://' + this.rawvalue.replace (/ /g, '%20');

And now my auto-generated email contains a link to the network path as needed!

YAY!!!

jasotastic81

07-07-2015

Like I said earlier, a space in a URL or equivalent file path is usually changed to %20 instead of a space. Have you tried using that in the replace function?

cindyp9252819

07-07-2015

Thanks so much!!! That seems to work!!!  - at least to replace the characters as requested...now the link is not being understood - so that's the next hurdle - but I appreciate your scripting help!!!!  Any advice on the link appreciated -

cindyp9252819

07-07-2015

THank so much for the quick reply!

I tried your suggestion but I'm not getting the expected result.  Just to confirm - you say "built-in javascript replace function should work" - but where do I reference that or build it in (sorry )?  I had been trying to run the script on an exit (or change) event of the FieldWithSpaces.  But I am admittedly not experienced in any of this and apparently am still missing something.  Could you more specifically tell me where/how to enter this code?

I'm not seeing any data at all populating in my FieldWithoutSpaces - do I need to set that field a certain way?  And yes, thank you, I do want a space, so I guess I do want '%20'

jasotastic81

07-07-2015

The built-in javascript replace function should work just fine.


tfFieldWithoutSpaces.rawValue = tfFieldWithSpaces.rawValue.replace(/ /g,'%');



But if this is part of a link, do you want %20 instead? That's the URL equivalent of a space.


tfFieldWithoutSpaces.rawValue = tfFieldWithSpaces.rawValue.replace(/ /g,'%20');