Discussions

 View Only
Expand all | Collapse all

Formula Button to Save a Record, Generate Record ID & redirect to a different page

  • 1.  Formula Button to Save a Record, Generate Record ID & redirect to a different page

    Posted 01-12-2020 11:48
    I have a table to track work orders.  Each work order has a [Related Contract].  The work order # is generated by​ taking the max # of work orders associated with a contract & increasing it by one.

    Fields & Formulas

    Max Work Orders (per Related Contract) - Summary field from Work Orders to the Contracts table, then a lookup field on the work order table.
    Next Work Order#​ - Formula Numeric Field - [Max Work Orders]+1
    ***Dynamic form rule***
    When Next Work Order# <>"" and Work Order#="", Change Work Order# to the value in the field Next Work Order#

    Problem or Issue
    If two users create a work order at the same time, duplicate [Work Order#] being created.

    Work Order # Date Created Record Owner
    68 12/23/2019 9:04 User # 1
    68 12/23/2019 9:03 User # 2

    Solution but need help
    I have created a workflow that will allow my user to create a new work order and only enter the [Related Contract].  This would allow the dynamic form rule to create the [Next Work Order #].  HOWEVER...  I can't find a formula for a button that will do the following.
    1. Save the record
    2. Generate a Record ID
    3. Open the same record in a different form
    The formula that I used to save the record is below, but this doesn't redirect to the same record using dfid 21.  Dfid 21 is the form that will require my user to enter the next information in the workflow. 
    "javascript:DoSaveAdd()" & "&rdr=" &
    URLEncode(URLRoot() & "db/" & Dbid() & "?a=er&rid=" & [Record ID#] & "&dfid=21" & "&z=" & Rurl())

    ​​​Can someone please help me find a solution to this problem so I can stop creating duplicate Work Order # & confusing my entire team.

    ------------------------------
    Amber Polston
    ------------------------------


  • 2.  RE: Formula Button to Save a Record, Generate Record ID & redirect to a different page

    Posted 01-12-2020 13:26
    I don't have an answer for your exact question, but I do have a suggestion to try.  You can create a new field called [Duplicate Work Order# - Please save again to get next WO#].

    The formula will be the List("-", ToText([Related Contract],  [Work Order#]), and set the field to be Unique.​

    The effect should be that the user will attempt to save and the save will fail (thus meeting your first goal of preventing duplicate Work Orders for the same contract.  Then due to the descriptive field name, the error message the user upon the failed save will get will be instructional - ie "just try saving again".

    I have not fully tested this with creating child record, but I'm pretty sure that after you get the error message the form will refresh and display.  I believe that the refreshed display will be very fresh and hence will include a valid Next Work Order which is non duplicate.

    Note that the user will just use the regular save button.

    However, I do not know how to control the display to a different form.  I personally try to avoid duplicate forms like the plague,  (in favor of using Form Rules), unless perhaps a Role is always locked into a Form, because its hard to control which form gets used when.

    Let me know if that works to prevent dup Work Order #'s ​

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