Discussions

Expand all | Collapse all

Rich Text Field Showing Javascript Code

  • 1.  Rich Text Field Showing Javascript Code

    Posted 28 days ago
      |   view attached
    Hi everyone,

    I have a rich text field with a button that "completes" a task.  It shows up in multiple places (including my dashboard reports) so I used javascript to return it to the current page.  Below is the code I used.  The problem I have is that it is showing the javascript on the button (see screenshot).  Any ideas on how to hide that?

    //Button Functionality:
    //
    //Check the current Task Stage
    //
    //If not Complete display button as gray
    //Code should change the Task status to Complete

    var text CLASS = If([Status]="Complete","btn btn-primary btn -sm","btn btn-default btn -sm");
    var text FONTCOLOR = If([Status]="Complete", "#FFFFFF", "#A9A9A9");
    var text LABEL = "Complete";

    //Change the Task Status to Complete
    var text URLONE = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
    "&rid=" & [Record ID#] &
    "&apptoken=HIDDEN" &
    "&_fid_24=Complete" &
    "&_fid_36=Changed Status to Complete" &
    "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid="& [Record ID#]);

    //Create edit functionality
    var text URL = "href='" & $URLONE & "'";

    var text LINK = "<a class='" & $CLASS & "' style='color: " & $FONTCOLOR & "; text-decoration: none'" & $URL & ">" & $LABEL & "</a>";

    "javascript:" &
    "$.get('" &
    $LINK &
    "',function(){" &
    "location.reload(true);" &
    "});"
    & "void(0);"

    ------------------------------
    Ivan Weiss
    ------------------------------


  • 2.  RE: Rich Text Field Showing Javascript Code

    Posted 28 days ago
    Ivan,

    Give them an icon to look at 

    var text IMG  =     "<img src=https://images.quickbase.com/si/48/016-email_0.png>"

     "<a href=\"javascript:" & "$.get('" & $URL  & "', function(){" & "location.reload();" & "});" & "void(0);\">"& $IMG &"</a>"


    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 3.  RE: Rich Text Field Showing Javascript Code

    Posted 23 days ago
    Don, will that image show on the button?  The button is supposed to say "Complete" as it is to Complete a task....

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 4.  RE: Rich Text Field Showing Javascript Code

    Posted 23 days ago
    Ivan,

    You can substitute any image or text in that position of the href.    

    Technically you do not even have to change the name, you can still call it IMG but that is not good practice.   It is a declared variable of the type text.  

    Substitute

    var text Message= "Complete";

    and then stick $Message in the href.

    Since you are setting fields 24 and 36, you can add more logic to allow the User to only execute it once.
    If you add two more variables:

    var text TaskComplete = "Task is Complete";
    var text Executable =  "<a href=\"javascript:" & "$.get('" & $URL  & "', function(){" & "location.reload();" & "});" & "void(0);\">"& $IMG &"</a>";

    Your logic then becomes:

    If ( [FID24]<>"Complete", $Execute, $TaskComplete  )

    Substitute the real name of FID24 in the block.   If it has been marked then the Executable will not show and the User will see the message "Task is Complete" and not have a button to push.


    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 5.  RE: Rich Text Field Showing Javascript Code

    Posted 22 days ago
    Hi Ivan,

    Inserting Javscript into Quick Base formulas is an unsupported technique, and later this year we will begin blocking any new Javascript code from being added in this way. This is an important change to the platform as Quick Base was never designed for arbitrary code to be used in formulas, and it causes a lot of issues being able to support such apps and to pass them on to other admins in your company.

    We're looking into improving our formula language to allow for reloading the page, but in the meantime we recommend copying your formula for each report/dashboard it appears on.

    Thanks,
    Brian

    ------------------------------
    Brian Cafferelli
    Product Marketing Manager | Quick Base
    ------------------------------



  • 6.  RE: Rich Text Field Showing Javascript Code

    Posted 22 days ago
    Edited by Austin K 22 days ago
    Should this be considered the announcement for Quick Base not supporting any type of JavaScript in formulas then? What happens to old formulas that are there already that have the same functionality? When will we expect to see this go live? Will there be a point where you do this to current formulas as well which will break them or will that not happen?

    Maybe I missed a previous announcement but this is the very first time I am seeing this being said.


  • 7.  RE: Rich Text Field Showing Javascript Code

    Posted 22 days ago
    Hi Austin,

    While I didn't specifically intend to break news with my above post, yes this may be the first time this change has been mentioned on this forum.

    To clarify, inserting javascript code into formulas, branding, etc has never been supported but the change we're planning to make is to prevent javascript from being inserted in places where it was not already there, and to prevent changes to formulas that have previously had javascript added. javascript has always been intended to be used in code pages and that will continue.

    This change will not impact existing formulas that use javascript, in that they will be continue to work as-is after the change. We currently have no plans to stop supporting that. However, this seems like a good opportunity to remind folks that it is never a good idea to use javascript that way as those formulas could stop working at any time without warning. That continues to be the case, and those formulas will become more likely to break as we work to update the Quick Base UI over the next few years (for those who leverage DOM objects in their javascript-powered qb formulas).

    We'll have more details to share about these plans in the coming months.

    ------------------------------
    Brian Cafferelli
    Product Marketing Manager | Quick Base
    ------------------------------



  • 8.  RE: Rich Text Field Showing Javascript Code

    Posted 22 days ago
    Thanks for the information. We for the most part avoid any of the BOL or tricks like that for this reason. We do rather prolifically use a formula similar to the above one for reloading the page as that is not something Quick Base currently offers. I think if you added the ability to reload the page in a formula like you mentioned a few posts up that would be a huge help in transitioning away from using JavaScript.


  • 9.  RE: Rich Text Field Showing Javascript Code

    Posted 22 days ago
    Brian,

    I certainly understand your position on the javascript but I really really really really hope that Quick Base is not purely going to block functionality that is clearly necessary without providing a way to do it.  There are SOOOOO many people using that code block I am using for simple URL manipulation.  I use it on my dashboards to reload the page etc.

    I also am a bit concerned because I reached out to Quick Base support first for help on how to do this without Javascript and they said go to a partner.  That was it, and with COVID my company is not in a position to invest in outside resources at the moment.  And outside resources on community pointed me here.

    In this particular example, all I am trying to do is fetch the current URL I am on and use it as my redirect.  This is a button to "Complete a task".  I use it on a dashboard report (so people can hit complete from the dashboard home page) as well as on the report link to the tasks table on my projects forms.  Again so people can complete tasks without 5,000 clicks.

    Right now I have one field with this button (since it appears in multiple places) and I use the javascript to determine where i am so I can redirect back to it.  How would you suggest doing this without javascript?  I would gladly get rid of the javascript if you can point me in the right direction here?  But so far this is all the help I got.....

    Thanks!

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 10.  RE: Rich Text Field Showing Javascript Code

    Posted 22 days ago
    Hi Ivan,

    Since Javascript is a general-purpose programming language, we know that Quick Base will never be able to solve every single problem which can be solved with javascript. On the contrary, as a no-code platform we aim to enable non-coders to solve a huge variety of important business problems much more quickly than could be done by coding a solution from scratch using a programming language such as javascript.

    Speaking more specifically about your formula to reload the current page, we are considering a new feature which would allow that without the use of javascript. We're doing the same for a handful of other common problems which folks are solving by inserting javascipt into qb formulas today, and we expect to share more information on those features later this year.

    Now, putting the future of Quick Base aside for a minute, I understand the time savings you get by allowing someone to update a large number of records without their having to click back to the previous page for each record. Without using javascript in your formula, I think you've got a few options:

    1. Using grid edit instead would allow someone to update the status of one record as Completed, then quickly copy and paste to each other record they want to update.
    2. Or, if you wanted to go with the button you can redirect to a specific page. For example, if the button is on the List All report (QID=1), you would use this formula:
      URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid_6=Completed&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=q&qid=1")​

      For the formula above, if you have multiple pages where you want the button to appear, you can copy the field for each other page, like your dashboard, and each version of the formula would redirect to a different page. The setup for that is a little more complex but it provides the same streamlined workflow for your app's users.
      Then, if neither of those work well, that's when I would consider whether it's worth working with one of our partners to build a custom solution that may meet your needs better.



    ------------------------------
    Brian Cafferelli
    Product Marketing Manager | Quick Base
    ------------------------------



  • 11.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    Have the engineers at Quickbase ever seen major problems from JS in forms?  I'm concerned that QB is losing tons of functionality for mostly acedemic reasons, but I'm not a JS expert so I'm totally open to being educated.  Either way, I've worked for a few QSPs and as a QB admin at several companies and all use JS in forms (as well as iFrames, although rarely).  I'm sure you've heard this before, but its so useful to have this functionality.

    I am very strongly suggesting that you do not move forward with bocking JS in forms completely.  Please instead coud you consider blocking by default and let the administrator decide if they would like to enable JS.  Please take the same approach with iFrames.

    ------------------------------
    Jake R
    ------------------------------



  • 12.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    Hi Jake. I'll jump in here as the person driving our multi-year UI refresh journey. Our priority as a platform is time-to-value, not necessarily pixel perfect control.

    We have done significant research on this in the past 12 months. Many of our partners and customers have been involved in this. Arbitrary code in a place it wasn't intended in any software system is considered a security vulnerability. As a software platform that serves thousands of enterprise customers with rigorous security controls, security and supportability has to take precedence. In the case of Quick Base, the intended place for JavaScript code has always been code pages.

    Without getting too far into the weeds, there are numerous conflicts that arise with unsupported code on any page, since we cannot regression test for it. As we are significantly investing in our interface, this only increases the likelihood issues will appear which we have no way to support. Even if an administrator approves it, there is still a support and maintenance challenge and things can break without notice.

    Long term, we absolutely understand the value in extending the platform and have a detailed strategy in place to allow for further customization and power. That won't all be in the way of JavaScript though. Adding native capabilities, such as those to our formula engine, are going to reduce the need for the unsupported and supported code, getting you to the ideal experience faster.

    Finally, we have an extensibility strategy we are building towards which will allow safe and intended extension points. For example in our new dashboards, we are exploring allowing builders to insert a custom code page to be inserted and receive filter events so that a custom chart or report can feel native to the end user. And in our new forms, iFrames will absolutely be supported. We just need to carefully keep the plates spinning between short term, long term, usability, supportability and security.

    Hope this helps.


    ------------------------------
    Harrison Hersch
    Director of Product Operations
    ------------------------------



  • 13.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago

    Hi Harrison, 

    Yes, that's very helpful and detailed.  Really appreciate the response.

    To hear that iFrames will still be supported in the new form is a huge relief.  

    I've also heard that, for old fields with JS, you will still be able to keep your JS.  Is that true?  If yes, it sounds like eventually, those will not be supported either, but that would come later.  Is that accurate?

    Thanks!
    Jake



    ------------------------------
    Jake R
    ------------------------------



  • 14.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    We have a very intentional and thorough communication plan coming on this so stay tuned. But in short, we are not intentionally breaking anything existing. There has always been the risk of those things breaking (and they do regularly actually).

    ------------------------------
    Harrison Hersch
    Director of Product Operations
    ------------------------------



  • 15.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    Sorry this post took a direction I really did not intend!  However, let me provide my 2cents on all of this.  I joined quick base about 1 1/2 years ago representing a company sized of about 40 employees.  We dont have a development team....  I am the COO and computer savvy with an interest in programming but little formal training.....

    Quick base out of the box is fantastic but has limitations.  People are using javascript to solve problems.  I know that when clients use outside tools to solve problems in my industry it means I have some gaps.....  The answer should not be to eliminate that functionality without providing the resources to solve those problems.  I certainly hope that you are going to provide a way to solve for these challenges first.

    As to support.....  I had not honestly thought of such an elementary idea of just copying the button and creating multiple fields to use.  I know it sounds silly...  But I did reach out on community and this was the advice received.....  After reaching quick base support.

    I cannot tell you how many times I am told go to a partner which for a smaller business does not work.  I am already spending a lot of money on quick base, so the support needs to be thorough enough to provide solutions....

    As to my specific problem I will certainly go the multiple field route as it is simple enough to implement to fix my issue.....  But I really think you have a bigger issue here....  A casual mention in the community of preventing future javascript is not a very good communication plan....I apologize to call that out, but that is really not the right place for such an announcement.  

    I love quick base, since joining I am a huge fan....  But I think you have uncovered some issues here on a few fronts I really hope will be taken seriously....  Harrison or anyone if any need to discuss further offline feel free to reach out (iweiss@elitestudioe.com) but I do really hope this is going to be handled well as it is going to create a bit issue in a number of ways.  

    I understand, like everyone does, that javascript is not officially supported.....  But there is a reason it is there....  And more importantly best be really careful how this is all communicated and what options are going to be available in lieu of the most common javascript uses.

    For example, I have no idea how to even implement javscript in a code page for our use....  So maybe need some training on that too.

    ------------------------------
    Ivan Weiss
    ------------------------------



  • 16.  RE: Rich Text Field Showing Javascript Code

    Posted 20 days ago
    Hi Ivan,

    No worries at all and thank you for the great conversation! It's so important for us to have this open dialogue. I just wanted to respond once more to kind of wrap things up for now. While partners are an important part of our community, it should not be necessary to work with a partner to create common types of buttons in Quick Base. If it appears that way, there may either be a misunderstanding or we may want to evaluate that situation, to see how adding a new feature there might benefit all users. The more pieces of your app you build using native QB features rather than JS code you may not be very familiar with, puts more control in your hands to customize and extend your app. The idea of copying a formula field I shared above is just one example, and we we've observed many reaching for javascript quickly to accomplish something in Quick Base where there may be other options.

    We've shared some detail about why we're making the javascipt change later this year, as well as some info on how to address the workflow issue from the opening post without using javascript. So I would encourage folks interested to read this thread from the beginning, and to add your own thoughts.

    For more information about these javascript changes, keep an eye out for an official announcement post from us in the coming months. My apologies for the slightly premature announcement here, and anyone should feel free to email me at bcafferelli@quickbase.com if you'd like to follow up offline.

    ------------------------------
    Brian Cafferelli
    Product Marketing Manager | Quick Base
    ------------------------------



  • 17.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    I'm fairly sure this is mostly from a security standpoint. I assume there is some certification or whatever that in order to obtain it for the platform they need to lock it down tighter. I'd be curious to find out the exact reason as well but this is what I have always thought.

    The one thing I dislike about this whole "go to a partner" thing is that Quick Base is supposed to be the low code/no code platform that is simple to use and build. It is obviously not very simple if I am having to go to an expert to get something done that was previously easy for me to do.


  • 18.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    As a current Partner and former member of the Support/Care team at Quick Base, I believe the intent of suggesting you reach out to a partner for an update to / alternative for your current JavaScript is that the Care team does not support JS at any level - only native Quick Base functionality. From a customer's perspective, it's never a great experience when your vendor tells you they can't assist you and you need to reach out to a paid service, unfortunately this is one of those instances. JS can be used to do so many varied things that the level of expertise needed to fully support JavaScript is much higher than your typical product support agent might have - no matter the vendor.

    ------------------------------
    Blake Harrison
    bharrison@datablender.io
    DataBlender - Quick Base Solution Provider
    Atlanta GA
    404.800.1702 / http://datablender.io/
    ------------------------------



  • 19.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    That may be the intent and that may work for the average customer that is not using JavaScript currently. However in this case what it looks like is happening is they are taking customers who are currently successfully using JavaScript in one way or another and removing that ability and telling them to go pay someone to do it for them in a different way. It seems silly to just force people to either contact a partner for something so small or for the user to move everything to a code page and still accomplish the same thing they already were.

    As long as they replace the basic functionality in formulas that most users even use JavaScript for then it shouldn't be a huge issue. Giving people lots of notice and Quick Base updating their formula functions first would give people the opportunity to decide how they will update their apps and how they will start working with the new formula functions. Let users start using the new formula pieces instead of the JS before they prevent it from being used, basically.

    I know they have not given a timeline or road map yet but I hope that is the direction that they go with it. Either way they can never really prevent JS from being used in an app, they will just make it more difficult to do lol.


  • 20.  RE: Rich Text Field Showing Javascript Code

    Posted 21 days ago
    I couldn't agree more

    ------------------------------
    Jake R
    ------------------------------