Using one button, edit record THEN perform copyMasterDetail

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

I currently have the following URL-Formula button:

var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=XXX&rid=" & [Record ID#] & "&_fid_478=" & Today(); "javascript:void(copyMasterDetailButtonHandler('&relfids=91&recurse=false&sourceRID=4226&destrid=" & [Record ID#] & "', 'XXX'))"

QuickBase accepts the code but when the button is clicked, it only performs the copyMasterDetail portion. I'd like it to edit one field first THEN perform the copy.

Any suggestions?

Thank you!
Photo of NP

NP

  • 10 Points

Posted 4 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
I checked with Charles at Trinity Software Integrated Solutions, who is one of my favorite "go to" resources for scripting and he is pretty sure that because one if the URLs is JavaScript, that this cannot be done in a usual QuickBase URL formula box.  I tried my usual techniques and it did not work for me.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
Actually, I just realized that there is a way to do this as the Copy Parent Child function is also an API.  I will post back once I test it.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
This worked. The help info on making that javascript into an API call is here http://www.quickbase.com/user-assistance/Default.html#apicalls.html

var text EditDateTime = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#]) & "&_fid_15=" & URLEncode(Now());

var text CopyParentChild = URLRoot() & "db/" & Dbid()
& "?a=API_CopyMasterDetail"
& "&copyFid=6"
& "&destrid=0"
& "&apptoken=mytoken"
& "&sourcerid=" & ToText([Record ID#]);

var text DisplayReportForRecordsCreatedToday =
URLRoot() & "db/" & Dbid() & "?a=q&qid=2";

$EditDateTime
& "&rdr=" & URLEncode($CopyParentChild)
& URLEncode("&rdr=" & URLEncode($DisplayReportForRecordsCreatedToday))



So, while this does not display the newly created record, it does go to a report that you specify, which can have the newly created record at the top, for example a report of records created today sorted at the top by date created.
Photo of NP

NP

  • 10 Points
Thanks for your help, Mark. The code actually doesn't work because, & "&copyFid=6", is not a text field in my situation.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
You will need to look at the API Guide help info and put in the correct reference numbers for you own situation.
Photo of NP

NP

  • 10 Points
Ok, thanks!
Photo of QuickBasePros_IDS

QuickBasePros_IDS, Champion

  • 4,208 Points 4k badge 2x thumb
I had a similar issue, but instead of copying the parent record; I wanted to copy the children of a "template" parent record for which I normally use a copyMasterDetailButtonHandler formula-URL. I was able to modify Mark Shniers' code to achieve the results I wanted.

Goal: Edit a date/time field in the parent record to the current date/time; Redirect and copy the Children and Recursive Children of a specific Record ID# and then redirect back to the Record I started at; refreshing the screen.

In the formula below the sourcerid is the "template" record I am copying the children from and the destrid is the Record ID I am on, because I'm attaching the children from a template to the record I'm already in (already exists).



var text EditDateTime= URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=xxxxxxxxxxxxx&rid=" & ToText([Record ID#]) & "&_fid_489=" & URLEncode(Now());



var text CopyParentChild= URLRoot() & "db/" & Dbid()

& "?a=API_CopyMasterDetail"

& "&relfids=xxx"

& "&destrid=" & ToText([Record ID#])

& "&apptoken=xxxxxxxxxxxxx"

& "&sourcerid=xxx";

var text DisplayLead = URLRoot() & "db/" & Dbid() & "?a=dr&apptoken=xxxxxxxxxxxxxx&rid=" & ToText([Record ID#]);




$EditDateTime


& "&rdr=" & URLEncode($CopyParentChild)

& URLEncode("&rdr=" & URLEncode($DisplayLead))



Thanks to Mark Shnier for getting me 99% of the way there.
Photo of NP

NP

  • 10 Points
Hi Mark! I actually never did get this to work for me until this morning haha. But I need help with one more thing. Before, the CopyMasterDetails button displayed a quickbase popup window that said something like "10 Records Were Created" . My newly revised button performs all the actions that I need BUT instead of displayed that popup window, it refreshes the screen. How do I get it to display that popup window instead? Thanks!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
To my knowledge there is not a way to make that pop up when you use the API.