Discussions

 View Only
  • 1.  Help with formula URL (or rich text) button

    Posted 10-29-2020 14:04
    I'm trying to create a button that will put a record into edit mode without changing any fields, and then save the record immediately after. I need this to happen in order to allow a JavaScript function in a code page to be implemented on the form using the IOL technique. 

    The function itself does something to this effect:

    var string = Math.random().toString(36).substring(2, 15);
    $("#_fid_6").val(randomString);
    If I manually click the edit button on the record, the function is implemented and the results are saved when the record is saved manually, but I'd like that to happen with a single button click.

    Can anyone help? If anyone knows of a better way to accomplish this I'd be glad to hear it.


    ------------------------------
    A Brown
    ------------------------------


  • 2.  RE: Help with formula URL (or rich text) button

    Posted 10-29-2020 17:00
    I'm not familiar with any way a button could be coded to Edit and Save a record in the same click in the UI. I'm not terribly well-versed in JS, but it looks like you're trying to generate a unique code that includes a random value, is that accurate? If you share a bit of your use case for this, maybe we can find an alternative solution.

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



  • 3.  RE: Help with formula URL (or rich text) button

    Posted 10-29-2020 17:06
    Yes, I'm trying to generate a random string to be entered into field 6. The function is in a code page, call it script.js.
    On my form, I have a rich text field which contains: [iol] & "script.js" & [/iol].

    When I put a record in edit mode, field 6 displays the random string that was generated in the code, which works for now. But I'd prefer to have a button that will automatically put the record into edit mode so that the results of the script will be passed to the field, and then automatically save the record and go back to display mode. This can easily be done by manually editing and saving the record, but I'd prefer to do it in one button click.

    Thanks so much for your time.

    ------------------------------
    Ahuva Brown
    ------------------------------



  • 4.  RE: Help with formula URL (or rich text) button

    Posted 11-04-2020 09:52
    Check the app exchange for an app called Magic Buttons. There are examples of many different functions using buttons.

    One that may prove helpful to you includes opening the record in edit and here is the formula URL code:
    URLRoot() & "db/" & [_DBID_CLIENT] & "?a=API_EditRecord&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_28=Completed&_fid_153=Completed&_fid_143=100&rid=" & [Record ID#] & "&rdr=" &
    URLEncode(URLRoot() & "db/" & [_DBID_PROJECT_SNAPSHOTS] & "?a=API_AddRecord&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_6=" & [Project Name] & "&_fid_7=" & [Status] & "&_fid_8=" & [Priority] & "&_fid_9=" & [Est Start Date] & "&_fid_10=" & [Est End Date] & "&rdr=" &
    URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]))

    // Edit the record and change the status to Completed then redirect to
    // Adding a Project Snapshot record to the Project Snapshot table then redirect to
    // displaying the original record

    Here is the formula rich text code:
    "<a class='Vibrant Primary' style=\"width:310px; text-align: center;\" href='" & [_DBID_CLIENT] & "?a=API_EditRecord&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_28=Completed&_fid_153=Completed&_fid_143=100&rid=" & [Record ID#] & "&rdr=" &
    URLEncode(URLRoot() & "db/" & [_DBID_PROJECT_SNAPSHOTS] & "?a=API_AddRecord&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_6=" & [Project Name] & "&_fid_7=" & [Status] & "&_fid_8=" & [Priority] & "&_fid_9=" & [Est Start Date] & "&_fid_10=" & [Est End Date] & "&rdr=" &
    URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#])) & "'>20B. Edit record then add record then display record</a>"

    // Edit the record and change the status to Completed then redirect to
    // Adding a Project Snapshot record to the Project Snapshot table then redirect to
    // displaying the original record

    // This uses one of the following Quick Base classes to display the color of the button. These are provided by Quick Base and subject to change. Alternatively you can use css style buttons for any color. See other buttons below.
    // Red Button: class='Vibrant Danger'
    // Green Button: class='Vibrant Success'
    // Blue Button: class='Vibrant Primary'
    // White Button: class='Vibrant Snowy'

    ------------------------------
    Adam Keever
    ------------------------------