Forum Discussion

DavidHoover's avatar
DavidHoover
Qrew Trainee
4 years ago
Solved

Native/Alternative Solution for JavaScript

In regard to the recent announcement about upcoming changes to JavaScript I have been looking into alternatives. I use JavaScript to solve 4 different problems where I couldn't find a solution elsewhere at the time. It's been several years since these were implemented but hopefully things have evolved or changed so that now I can replace them with something native, or with something that will be supported in the future.

To keep my first post on this as short as possible I'll just start with 1 of my uses.

The first JavaScript I implemented was put in place to remove carriage returns from a Notes field contained on our employee Timesheet entry form. The Timesheets are exported weekly and that export file is used to import to our accountants. If that file has a carriage return in the Notes field it would not import successfully into the accountants system. Before implementing the JavaScript for this our internal admin was manually scrubbing the Notes field before importing to the accountants system. I helped make that process a little easier with some tricks to remove them automatically in Excel but it was still extra steps that were not welcome.

So the final solution I came up with was to use JavaScript and regex to remove any carriage returns with the OnBlur event handler.

My JavaScript is within a Code Page but I use a Formula Rich Text to have it accessible on the Form

Here's the code in my "timesheets.js" Code Page I use for this (#_fid_8 is the Notes field on the form):

$('#_fid_8').blur(function(){$('#_fid_8').val($('#_fid_8').val().replace(/\n{1,}/gm,' '))});

 
And here's the Formula used in the Rich Text field placed on the Timesheet Form:

[script_page] & "timesheets.js" & [/script_page]


This field was identified as one that would no longer be supported when the upcoming changes are implemented. According to the posts it should still function but I won't be able to make any changes to the formula field, it will be locked down (though since the actual JavaScript is in a Code Page I assume I'd still be able to edit it if needed).

So I guess first I should ask if that is truly the case. Will the way I have implemented JavaScript for this issue be unsupported when the changes are put in place?

If so, can anyone think of an alternative? Is there is something native within Quickbase I am overlooking? Several years ago when I put this in place I couldn't find a formula to find/replace a carriage return (just text and/or numbers, etc) or any other native method, but I haven't delved too deeply into recent enhancements like Pipelines, or trying to solve this with Automations which also was enhanced or changed since I implemented this solution - but would either of those tools or anything new be a viable replacement somehow now?

 



------------------------------
David Hoover
------------------------------
  • The function SearchAndReplace is relatively new and may not have existed whern you needed the javascript.

    Try this
    SearchAndReplace([Notes],"\n"," ")

    That should replace the carriage return with a space character. 



    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------

2 Replies

  • The function SearchAndReplace is relatively new and may not have existed whern you needed the javascript.

    Try this
    SearchAndReplace([Notes],"\n"," ")

    That should replace the carriage return with a space character. 



    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • DavidHoover's avatar
      DavidHoover
      Qrew Trainee
      Thanks Mark!

      SearchAndReplace is indeed new since I put this JavaScript in place. I tried using it in a Formula-Text field and it wasn't working, but then I tried using a Formula-Rich Text field instead and that does work, which makes sense now that I think about it.

      Anyway, I think the Formula-Rich Text field is also relatively new so with both now it looks like I can get rid of this particular JavaScript. I still have a couple other (more DOM related needs) that I'll post separately. But this one was more of a priority so I'm very happy to find an alternative. You are the man! 


      ------------------------------
      David Hoover
      ------------------------------