Discussions

Expand all | Collapse all

Is it possible to have a copy parent record button also make changes to some fields?

  • 1.  Is it possible to have a copy parent record button also make changes to some fields?

    Posted 17 days ago
    I have a Tenants table that is the parent of a Leases table. I used the wizard in app management to create a Copy Lease button (which I renamed "Assign Lease"). However, what I want is when the Assign Lease button is clicked, for it to automatically check a checkbox field called "Lease Assigned" in the original Lease record and permit the user to choose a different existing parent record for the newly created/copied Lease record.

    So for example, a user might be in a Tenant record for Tenant A, clicks the Assign Lease button and then the record for Tenant A is saved with the Lease Assigned field checked, and the user then selects Tenant Q as the parent for the newly created/copied Lease record and saves. 

    I've seen some examples of formula url buttons that change data in fields but I don't kn ow how to combine that with the copy record button created by the wizard. Any guidance would be greatly appreciated!

    AJ

    ------------------------------
    Albert Campani
    ------------------------------


  • 2.  RE: Is it possible to have a copy parent record button also make changes to some fields?

    Posted 17 days ago

    The wizard uses an API which will copy all fields. there are no parameters to change that  


    So Plsn B is to have a button for the user to push when the record identifier field begins with the word Copy of to clear out the field and say leave the user in edit mode 

    You could use a form rule to hide sections of the form when the name begins with Copy Of  

    post back if you need help with the button formula  


     




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



  • 3.  RE: Is it possible to have a copy parent record button also make changes to some fields?

    Posted 17 days ago
    Yes please I would appreciate help with it.

    ------------------------------
    Albert Campani
    ------------------------------



  • 4.  RE: Is it possible to have a copy parent record button also make changes to some fields?

    Posted 17 days ago
    OK here goes,

    We need to make a URL formula field to edit the record and land the user in edit mode on the record.

    When using API's which update records, we either need to have what is called an application token.
    You may or may not want to keep the need for those enabled those enabled. many of my clients choose to disable the need for them.  That is a setting on Application Properties for the App settings.

    Here is the code for a button. Post back with your code and any error messages as I'm free form typing this without the benefit of he formula syntax editor!

    You can get the field ID# by right clicking a field name on the form or looking at the field properties under Usage or in the URL. 


    // this is a comment
    //this is a formula variable below

    var text ClearFields = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&apptoken=cxcxcxcxcxcxccxcxcxxcxc" // insert your app token here is you have them enabled
    & "&_fid_90="  // clear field ID 90 change the 90 to the field ID# of your own fields. 
    & "&_fid_91="  // clear field ID 91
    & "&_fid_92="  // clear field ID 92
    & "&_fid_93=";  // clear field ID 93  and end the formula variable with a semi colon

    // new formula variable to display the record in edit mode.
    var text DisplayInEditMode = URLRoot() & "db/" & dbid() & "?a=er&rid=" & [Record ID#];

    $ClearFields
    & "&rdr=" & URLEncode($DisplayInEditMode)

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



  • 5.  RE: Is it possible to have a copy parent record button also make changes to some fields?

    Posted 16 days ago
    Edited by Albert Campani 16 days ago
    Thanks for the formula Mark! I just tried it but I'm getting an error regarding the app token. I have them enabled and I tried using a new one I created as well as one already in use (for syncing an outlook account to the same app).

    Here's my modified formula:

    var text ClearFields = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&apptoken=xxxxxxxxxxxxxxxxxxxxxxxxx"
    & "&_fid_297=" // related tenant
    & "&_fid_304="; // assign lease

    var text DisplayInEditMode = URLRoot() & "db/" & Dbid() & "?a=er&rid=" & [Record ID#]; // new formula variable to display the record in edit mode.

    $ClearFields
    & "&rdr=" & URLEncode($DisplayInEditMode)

    and this is the error code I get:

    This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <qdbapi>
    <action>API_EditRecord</action>
    <errcode>24</errcode>
    <errtext>Invalid Application Token</errtext>
    <errdetail>The Application Token xxxxxxxxxxxxxxxxxxxxxx has not been assigned to this Application. To read about assigning an Application Token to your application go to https://help.quickbase.com/user-assistance/app_tokens.html</errdetail>
    </qdbapi>

    The older token was last used this morning so I think its working properly. Any ideas?



    ------------------------------
    Albert Campani
    ------------------------------



  • 6.  RE: Is it possible to have a copy parent record button also make changes to some fields?

    Posted 16 days ago
    Ok, we will sort this out here or if necessary I can jump on a quick zoom call..

    Is the app then correct?  Is there a leading space perhaps in front of the app token.
      Is it definitely an apptoken and not confused with a usertoken?


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



  • 7.  RE: Is it possible to have a copy parent record button also make changes to some fields?

    Posted 16 days ago
    You called it - I was plugging in a user token rather than an app token. Just fixed it and it works perfectly. Many thanks, I appreciate your time and your expertise. 

    Have a great weekend!

    AJ

    ------------------------------
    Albert Campani
    ------------------------------