Forum Discussion

MichaelGraham2's avatar
MichaelGraham2
Qrew Assistant Captain
9 years ago

Copy Master Detail records and then go to a PAGE and not to record?

I have a button which creates tasks but when clicked I don't want it to go to the related project (which is standard) but instead to redirect to a Home Page.

Currently the button is thus:

"javascript:void(copyMasterDetailButtonHandler('&relfids=510&recurse=false&sourceRID=463&destrid=" & [Record ID#] & "', 'bjtdaeume'))"


How can I get it to redirect to MYPAGE

??
  • Mick,

    There is help in the API guide but basically you need to convert this to an a formula URL using an the CopyMasterDetail API, and then you can do successive actions.  ie do the copy and then redirect to show the dashboard.

    So it would be like 

    var text URLONE = urlroot() & "db/" & [_DBID_of the Parent table] & "?act=API_CopyMasterDetail&recurse=false&sourceRID=463&relfids=510";

    var text URLTwo = and here you need to hard code the main URL of the app.

    var text URLTWO = "https://mycompany.quickbase.com/db/abcdefg;

    $URLONE

    & "&rdr=" & URLEncode($URLTWO)
  • MichaelGraham2's avatar
    MichaelGraham2
    Qrew Assistant Captain
    Im getting the following when trying to save the formula url field?

    The argument list of the function rdr must begin with a left parenthesis.

    var text URLONE = urlroot() & "db/" & [_DBID_PROPERTIES] & "?act=API_CopyMasterDetail&recurse=false&sourceRID=463&relfids=510";

    var text URLTWO = "https://xxxxx.quickbase.com/db/xxxxxxxxx?a=showpage&pageid=30;

    $URLONE

    & "&rdr=" & URLEncode($URLTWO)
  • MichaelGraham2's avatar
    MichaelGraham2
    Qrew Assistant Captain
    ah, it needed a " after the 30

    But now its asking for apptoken.  Ive created one but I dont think I have it in the right place...

    var text URLONE = URLRoot() & "db/" & [_DBID_PROPERTIES] & "?act=API_CopyMasterDetail&recurse=false&sourceRID=463&relfids=510"&apptoken=apptoken;
  • var text URLONE = URLRoot() & "db/" & [_DBID_PROPERTIES] & "?act=API_CopyMasterDetail&recurse=false&sourceRID=463&relfids=510&apptoken=apptoken";
  • MichaelGraham2's avatar
    MichaelGraham2
    Qrew Assistant Captain
    I had tried that as well but get this:

    <qdbapi>
    <action>API_CopyMasterDetail</action>
    <errcode>2</errcode>
    <errtext>Invalid input</errtext>
    <errdetail>CopyFID required</errdetail>
    </qdbapi
  • try this change

    var text URLONE = URLRoot() & "db/" & [_DBID_PROPERTIES] & "?act=API_CopyMasterDetail&recurse=false&sourceRID=463&destrid=" & [Record ID#] & "&relfids=510&apptoken=apptoken";
  • MichaelGraham2's avatar
    MichaelGraham2
    Qrew Assistant Captain
    Sorry Mark, I have been away...  just tested that and it works a real treat...  THANKS!
  • Hi Mark,

    While creating child records, I also want to set some defaults value with this API call. I tried but could not succeed.

    Here is my formula:

    URLRoot() & "db/" & Dbid() & "?a=API_CopyMasterDetail&sourceRID=1&destrid=" & [Record ID#] & "&relfids=684"
    & "&_fid_76=" & "Not Required" 
    & "&_fid_77=" & "Not Required" 
    & "&_fid_78=" & "Not Required" 
    & "&_fid_79=" & "Not Required" 
    & "&_fid_80=" & "Not Required" 
    & "&_fid_81=" & "Not Required" 
    & "&_fid_82=" & "Not Required" 

    & "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#])

    Thanks,
    Gaurav Sharma
  • You cannot change field values with the CopyMasterDetail  API.    Its also not obvious to get at the rid for the newly created record. 

    What I do is to land the user on a report of recently created Parent records by the current user.  ie the records you just created.  I do that with an rdr after the copymasterdetail.

    I then detect that the name field for the record now begins with "copy of", and show a button and a big red message asking the user to put the button.  The button then makes any field changes required.
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      MS> You cannot  ...

      Here is my advice: If you have an rdr parameter in your formula URL you should be using script instead for the entire feature.
    • GauravSharma3's avatar
      GauravSharma3
      Qrew Commander
      or can we use API_Editrecord with the CopyMasterDetail  API?