How do I copy a master detail record and then edit a specific field in the new record using just one button?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered

After the new record is created, i want to edit the fid=48 to show today's date.

Here is the formula i am using now:

URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx&_fid_282=Original Contract - Contract ID "& [Record ID#] & "&_FID_291=" & Today() &"&_fid_294="&1& "&rdr=" &


URLEncode(URLRoot() & "db/"& Dbid() & "?a=API_CopyMasterDetail&copyfid=282&destrid=0&sourcerid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx" & "&rdr=" &


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


Photo of NP

NP

  • 10 Points

Posted 5 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
I don't think that's going to be possible.  I think that the best you can hope is to have a red message come up when landing the user on the newly created record to "click here to update with today's date".
Photo of NP

NP

  • 10 Points
How do i create that message?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
On your original formula I'm pretty sure that your last redirect is not doing anything and in any event, once you use the copy master detail you would want to land the users on those newly created record.  They get that opportunity after the copy is done.

If you have date field that you want to set.

You would have a button to set it like it like
var text SetDateToToday =
URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx&
& "&_FID_291=" & totext(Today());

var text display = urlroot() & "db/" dbid() & "?a=dr&rid=" & totext(record id#]);

if(isnull([my date field],
$SetDateToToday & "&rdr=" & URLENCODE($display)


You can also make an "<a href .. link with text, but that tales more work.
Photo of NP

NP

  • 10 Points
How do I edit my formula so that the user lands on the newly created record?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
Can you post your formula :).  Tough to see it from here.
Photo of NP

NP

  • 10 Points
Sure =)

 URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx&_fid_282=Original Contract - Contract ID "& [Record ID#] & "&_FID_291=" & Today() &"&_fid_294="&1& "&rdr=" &

           URLEncode(URLRoot() & "db/"& Dbid() & "?a=API_CopyMasterDetail&copyfid=282&destrid=0&sourcerid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx" &  "&rdr=" &

           URLEncode(URLRoot() & "db/"& Dbid() & "?a=dr&rid=" & [Record ID#]))
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
Does that formula pass the syntax error checker?  I would be very surprised if it did.  Is that where we need to start?
Photo of NP

NP

  • 10 Points
Haha, it actually does.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
try this

var text URLONE =
URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx&_fid_282=urlencode("Original Contract - Contract ID ") & totext([Record ID#])
& "&_fid_291=" & totext(Today())
& "&_fid_294=1";

var text URLTWO = URLRoot() & "db/"& Dbid() & "?a=API_CopyMasterDetail&copyfid=282&destrid=0&sourcerid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx";

$URLONE & "&rdr=" & Urlencode($URLTWO)
Photo of NP

NP

  • 10 Points
I get this error message:

A variable declaration must end with a semi-colon.


var text URLONE = URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx&_fid_282=urlencode("  Original Contract - Contract ID ") & totext([Record ID#]) & "&_fid_291=" & totext(Today()) & "&_fid_294=1";

var text URLTWO = URLRoot() & "db/"& Dbid() & "?a=API_CopyMasterDetail&copyfid=282&destrid=0&sourcerid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx";

$URLONE & "&rdr=" & Urlencode($URLTWO)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
OK try this

var text URLONE = URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx&_fid_282=" & urlencode("Original Contract - Contract ID ") & totext([Record ID#])
& "&_fid_291=" & totext(Today())
& "&_fid_294=1";

var text URLTWO = URLRoot() & "db/"& Dbid() & "?a=API_CopyMasterDetail&copyfid=282&destrid=0&sourcerid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx";

$URLONE & "&rdr=" & Urlencode($URLTWO)
Photo of NP

NP

  • 10 Points
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<qdbapi>
<action>API_CopyMasterDetail</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<parentrid>656</parentrid>
<numCreated>8</numCreated>
</qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
what happens if you just change the last line to $URLTWO

ie


// $URLONE & "&rdr=" & Urlencode($URLTWO)

$URLTWO

I know that it won't do the edit of the initial record, but does it properly do the copy parent child?
Photo of NP

NP

  • 10 Points
No, it does not properly copy the parent child.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 66,328 Points 50k badge 2x thumb
OK, so lets just start over.

I suggest that you make a new copy parent child button so we know that it will work.

Test the button to make sure it works.  the correct behavior will be that it comes up with a very friendly completion box and ask if you want to stay on the current record or go to the new record.

Then do this

var text URLONE = URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cdzbyfrb899v6559qzpdpjj2vx&_fid_282=" & urlencode("Original Contract - Contract ID ") & totext([Record ID#])
& "&_fid_291=" & totext(Today())
& "&_fid_294=1";

$URLONE & "&rdr=" & URLEncode([my copy parent button url field])
Photo of Juan

Juan

  • 20 Points
I have the same issue.  After using this approach to import (copy) records, users are not redirected to view the record just edited.  Instead, they go to this screen:

<qdbapi>
<action>API_CopyMasterDetail</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<parentrid>903</parentrid>
<numCreated>13</numCreated>
</qdbapi>

How can I redirect users back to the record they just edited, in view mode?

Thanks.