translate function to remove spaces for url - InfoPath Dev
in

InfoPath Dev

translate function to remove spaces for url

Last post 11-09-2012 12:16 PM by Ginger. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 06-13-2009 12:52 PM

    • j0nxy
    • Not Ranked
    • Joined on 02-05-2009
    • Posts 5

    translate function to remove spaces for url

    I'm trying to add a hyperlink in a form that references another form.  The form link is based off of the other form title in the document library.  Unfortunately the titles have spaces in them so I need to replace the spaces with a %20.  I've tried doing this: translate(title," ", "%20"), but it only seems to insert the % and not the rest of the characters.  Is there any way to replace one character with multiple character?  Is there a better way to create this link in the first place?

     

    Thanks!

  • 06-13-2009 02:57 PM In reply to

    Re: translate function to remove spaces for url

    Based it off the filename instead of form title.  There should be a specific URL for each that you can define easily.  Translation is one-for-one.

  • 06-13-2009 03:27 PM In reply to

    • j0nxy
    • Not Ranked
    • Joined on 02-05-2009
    • Posts 5

    Re: translate function to remove spaces for url

    Thanks for the response.  Maybe I'm missing something.  I'm getting the title by using a data connection to the document library and then filtering by the ID (the user submits this ID).  The only column I can retrieve that has the form name is Title.  I'm not able to get Name or the file name.

     

     

  • 06-13-2009 04:29 PM In reply to

    Re: translate function to remove spaces for url

    In SharePoint Designer, if you reference the library, you will see tons more metadata, such as Encoded Absolute URL (plus many others).  If you get the URL that way, you can add it to a field in your form by promoting that field, making it editable in SharePoint, and then using SPD to modify that column by adding the proper URL.

  • 06-14-2009 09:02 AM In reply to

    • j0nxy
    • Not Ranked
    • Joined on 02-05-2009
    • Posts 5

    Re: translate function to remove spaces for url

    Sorry I'm still not getting it.  The links to the forms will be dynamic (and the form name itself has the spaces).  How can I use your method to get the absolute url to the forms from within infopath?  Is this easier than inserting a %20 into the title?  I will have the ID of the form, but formserver.aspx does not take the ID as a paramater.

  • 06-14-2009 09:12 AM In reply to

    Re: translate function to remove spaces for url

    It's hard to answer without seeing the problem, because I never have this issue with dynamically referencing my forms due to spaces.  I'm always able to directly reference the Forms Services URL for my browser-enabled forms, which of course is much tougher than just reference the direct XML file for rich client use.  Maybe it's because I never allow spaces in my filenames?  Not sure, since I don't have any memory in my head of having the issue you're having.

    One way or another, there is a URL for your forms - rich client or browser-enabled.  SharePoint Designer is able to dynamically derive that for the current item (or whatever item you specify by ID).  Whatever this URL is - whether it has spaces or %20 - should work when clicked on from InfoPath or anywhere.

  • 09-12-2010 10:19 AM In reply to

    Re: translate function to remove spaces for url

    I have to report that I'm experiencing a similar issue with attempting to use the translate formula.  However, the URL that I'm attempting to create is not one that would exist in any meta data.

    My company is utilizing a form to submit transportation requests so that our transportation group knows when to take clients to appointments off-site.  Once submitting the form, a workflow is initiated to automatically place this request on a SharePoint calendar and an e-mail sent to the transportation group. 

    All fine up to this point.

    The transportation group then requested that we include driving directions in the e-mail so they know where they're going.  I figure, what better way to do that than simply include a link to driving directions within Bing Maps.  Here's the problem: e-mails generated by SharePoint workflows are in plain text format, so the instant that a URL includes a space, the hyperlink is interrupted and only includes the portion pre-space.  So, essentially, when lookup the "Address" field (field that contains the destination address for the transportation group) for the e-mail, it would interrupt the hyperlink.

    To remedy (so I thought) this problem, I created another field "AddressforURL" that would take the data put in the "Address" field and convert the spaces to %20.  The problem that I am encountering is the exact same as the one that started this thread: When the translation is complete, it only includes the %, and not the 20 (example: "123 Somplace Street" should translate to "123%20Somplace%20Street," but instead translates to "123%Someplace%Street").  No good.

    The formula that was used was: translate(Address, " ", "%20").  When that didn't work, I even went so far as to create another field URLSpace that had a default value of %20.  Then the formula was translate(Address, " ", URLSpace).  Same result.

    Any ideas at all?  This seems like a very, very strange problem.

  • 09-12-2010 10:35 AM In reply to

    Re: translate function to remove spaces for url

    I think I figured out a better solution to my problem: Insert the URL into a HTML hyperlink tag.  Then it doesn't matter if there are spaces or not.  Duh.  Sometimes the easiest solution just doesn't even occur to you.

  • 09-20-2010 02:00 AM In reply to

    Re: translate function to remove spaces for url

    warrtalon:

    It's hard to answer without seeing the problem, because I never have this issue with dynamically referencing my forms due to spaces.  I'm always able to directly reference the Forms Services URL for my browser-enabled forms, which of course is much tougher than just reference the direct XML file for rich client use.  Maybe it's because I never allow spaces in my filenames?  Not sure, since I don't have any memory in my head of having the issue you're having.

    One way or another, there is a URL for your forms - rich client or browser-enabled.  SharePoint Designer is able to dynamically derive that for the current item (or whatever item you specify by ID).  Whatever this URL is - whether it has spaces or %20 - should work when clicked on from InfoPath or anywhere.


    Thank you, this is good news for new visitors.
  • 03-09-2011 04:23 PM In reply to

    Re: translate function to remove spaces for url

     

    Hello Skippy, I have excatly the same problem. I use the Object Hyperlink and I want the user to put a link to a local file ex: file://c:\program files. After inserting the link I click on it and it work with %20 but when I reopen the form (in sharepoint) the %20 have disapear and are replace by ''space''. And with space it's did not work. I have test also the translate function but it was not working. Have you find a solution.
  • 03-14-2011 09:20 PM In reply to

    Re: translate function to remove spaces for url

    Hi fredruel,

    This is possible to accomplish with the xPath functions concat, substring-before, and substring-after. Say your filename is in @file. Then your rule (set on @file) is:

    If @file contains ' ' Then

    Set a field's value: @file = concat(substring-before(@file, ' '), '%20', substring-after(@file, ' '))


    The function only replaces of the first space in @file every time the rule is run but the rule will keep firing until all the spaces are replaced. The spaces should be replaced as soon as the value of the field changes.

    Hope this helps!

    Qwerty
  • 03-18-2011 05:15 PM In reply to

    Re: translate function to remove spaces for url

    Thank Qwerty it help a lot and it's work well. The first solution I found without code or calling any webservice.

  • 03-18-2011 05:27 PM In reply to

    Re: translate function to remove spaces for url

    Glad I could help. You can customize this idea to run codeless 'for' loops in IP. The idea just occurred to me a few days ago, so I'm glad it worked :)
  • 04-29-2011 06:40 AM In reply to

    Re: translate function to remove spaces for url

    Qwerty, this is sooooo very helpful. This solves an issue I've been struggling with for days. Many many thanks!
  • 10-16-2012 03:19 PM In reply to

    Re: translate function to remove spaces for url

    Is there any way you can use this when setting a fields value?

Page 1 of 2 (16 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.