select child form based on field value?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
I'm trying to select a child form base on the value of a field called "form #" on the parent record. Not only does this code not work (I swear it used to) but it also kills the lookup fields I'm trying to carry down to the child table!. Here's a sample of the "Add List Items" button:

URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])&

Case([Form #],
"1",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=10",
"2",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=11",
"3",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=12",
"&z=" & Rurl())

Anyone have a clue?
David
Photo of David

David

  • 80 Points 75 badge 2x thumb

Posted 3 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
Try this.  You do not need that first part of your current formula.

Case([Form #],
"1",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=10",
"2",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=11",
"3",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=12",
"&z=" & Rurl())
Photo of David

David

  • 80 Points 75 badge 2x thumb
Thanks Mark! That was it. Did something change? I swear it used to work for me.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
I can't imagine how it could have worked before.
Photo of David

David

  • 80 Points 75 badge 2x thumb
You're probably right. I may have remarked out that first line at some point to make it work. Here's a related question about the behavior of the record after save. When I use "save and add another" everything is fine. It keeps the same form (dfid #) for the next record and same fields showing. But, if I hit save it puts me back on the same record in view mode with all the fields I'm trying to hide showing. In other words it's not using the same dfid # in view mode. Apparently it's using the default form. Is there a way to modify this to make it use the dfid # for viewing?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
try this

var text URLONE =
Case([Form #],
"1",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=10",
"2",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=11",
"3",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=12")

var text URLTWO =
Case([Form #],
"1",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=dr&rid=" & totext([Record ID#])& "&dfid=10",
"2",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=dr&rid=" & totext([Record ID#])& "&dfid=11",
"3",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a="?a=dr&rid=" & totext([Record ID#])& "&dfid=12")

$URLONE
& "&nexturl=" & URLEncode(URLTWO);



... so basically, you do your edit and then it redirects to display the record by specifying the "nexturl"
Photo of David

David

  • 80 Points 75 badge 2x thumb
Thanks I'll give this a try later and let you know what happens!
Photo of David

David

  • 80 Points 75 badge 2x thumb
I'm getting a "variable declaration must end with a semi-colon" error. Everything including var text URLTWO= is underlined in the error
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
right, we need to end each var with a semi colon.

var text URLONE =
Case([Form #],
"1",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=10",
"2",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=11",
"3",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=API_GenAddRecordForm&_fid_59=" & URLEncode ([Record ID#])& "&dfid=12");

var text URLTWO =
Case([Form #],
"1",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=dr&rid=" & totext([Record ID#])& "&dfid=10",
"2",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a=dr&rid=" & totext([Record ID#])& "&dfid=11",
"3",URLRoot() & "db/" & [_DBID_LIST_ITEMS] & "?a="?a=dr&rid=" & totext([Record ID#])& "&dfid=12");

$URLONE
& "&nexturl=" & URLEncode(URLTWO);
Photo of David

David

  • 80 Points 75 badge 2x thumb
Thanks Mark. I'm just getting back to this from last week so I'm sorry about the delay in response. I had to adjust your formula at the end to & "&nexturl=" & URLEncode($URLTWO) but works fine now. Thank you for your help!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,422 Points 50k badge 2x thumb
Thx for letting me know!