Discussions

 View Only
Expand all | Collapse all

Creating two records at once with reference fields NOT being populated

  • 1.  Creating two records at once with reference fields NOT being populated

    Posted 12 days ago

    Hi there. 

    I am trying to use formula URLs to create a button that can make two child orders based on the parent order (where the button would be pushed) using API_AddRecord.

    The child orders are supposed to duplicate some information from the parent order. The problem here is that reference fields are not being duplicated (unless you use the API_GenAddRecordForm which doesn't allow for creating multiple records
    simultaneously).

    Here's the code I've been using:

    var text addOrderNumber = Left([Order #],".") & "." & ToText([Number of Change Orders] + 1) & ".ADD";
    var text returnOrderNumber = Left([Order #],".") & "." & ToText([Number of Change Orders] + 1) & ".RETURN";
    var text parentOrderNumber = Left([Order #],".");
    
    
    //The URL to create a copy of the order. By default this is of type return order
    var text CreateAddRecord =URLRoot() & "db/" & Dbid() & "?a=API_AddRecord"&"&apptoken=XXXX"
    & "&_fid_6=" & URLEncode($addOrderNumber)
    & "&_fid_59=" & URLEncode([Customer Number#])
    & "&_fid_36=" & URLEncode([Partner Name]) // reference field
    & "&_fid_35=" & URLEncode([Related Partner]) // reference field
    & "&_fid_177=" & URLEncode([Partner Name]) // text field copying value of reference field
    
    
    var text CreateReturnRecord = URLRoot() & "db/" & Dbid() & "?a=API_AddRecord"&"&apptoken=XXX"
    & "&_fid_6=" & URLEncode($returnOrderNumber)
    & "&_fid_59=" & URLEncode([Customer Number#])
    & "&_fid_36=" & URLEncode([Partner Name]) // reference field
    & "&_fid_35=" & URLEncode([Related Partner]) // reference field
    & "&_fid_177=" & URLEncode([Partner Name]) // text field copying value of reference field
    
    var text ROOTURL = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];
    
    
    $updateNumberofChangeOrder
    & "&rdr=" & URLEncode($CreateAddRecord)
    & URLEncode("&rdr=" & URLEncode($CreateReturnRecord))
    & URLEncode(URLEncode("&rdr=" & URLEncode($ROOTURL)));

    When we hard code one of the reference fields (& "&_fid_35=5" ) it still doesn't populate the field in the child order.

    Please advise how I dynamically create two records with reference fields populated.



    ------------------------------
    Joshua Rosenthal
    ------------------------------


  • 2.  RE: Creating two records at once with reference fields NOT being populated

    Posted 12 days ago

    What is the Key field of the Parent Table?  Is it [Record ID#]

    Which part of the code is populating the related parent field?



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------