Redirect after creating multiple child records

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a timecard app that allows the user to select multiple projects for a given week.The user can submit up to 10 project submissions with one parent record. This is done by a single URL (Submit All) button which triggers 10 other URL buttons to create each child. 

My issue is when the user fills out less than 10 records on the parent form, the 'Submit All' URL button doesn't redirect properly and I get an error after the button is clicked. All child records are created properly, but I think my IF statements are causing it to crash. I don't want to create child records if no time is entered for them. Any help would be greatly appreciated. Thank you.

Thanks to Mark Shnier for getting me this far via another thread found here:

https://quickbase-community.intuit.com/questions/1445339-one-button-to-create-multiple-child-records...


Here is my code:

var text URLONE = If([Total 1]>0,[Submit 1]);



var text URLTWO =  If([Total 2]>0,[Submit 2]);



var text URLTHREE =  If([Total 3]>0,[Submit 3]);



var text URLFOUR =  If([Total 4]>0,[Submit 4]);



var text URLFIVE =  If([Total 5]>0,[Submit 5]);



var text URLSIX =  If([Total 6]>0,[Submit 6]);



var text URLSEVEN =  If([Total 7]>0,[Submit 7]);



var text URLEIGHT =  If([Total 8]>0,[Submit 8]);



var text URLNINE = If([Total 9]>0,[Submit 9]);



var text URLTEN =  If([Total 10]>0,[Submit 10]);



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



// that last string will redisplay the record you are sitting on.



$URLONE 

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

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

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

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

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

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

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

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

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

& URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLELEVEN))))))))))
Photo of Christopher

Christopher

  • 2 Points

Posted 3 years ago

  • 0
  • 1
I'm sure that smarter people than me will frown on this solution but it will work and I really don't care about wasting a couple micro seconds of QuickBase's processing time.



Make a new formula URL called [Submit none].  Have it just do something trivial like update a dummy checkbox to true.  That way it will not be null.



var text URLONE = If([Total 1]>0,[Submit 1], [Submit null]);

var text URLTWO =  If([Total 2]>0,[Submit 2], [ Submit null]);


etc

var text URLTEN =  If([Total 10]>0,[Submit 10], [Submit null]);


Photo of Christopher

Christopher

  • 2 Points
I like your rebel attitude:)! Thanks, Mark but I failed to mention that both the parent and child records will all be saved/created at the same time. any other trivial actions I can create to make this work?
Photo of Christopher

Christopher

  • 2 Points
Belay my last... I just created another table "trivial actions' and put the trivial checkbox there. Works like a charm. Thanks so much Mark!