button to create a record that is not a child

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • Answered
I've got a parent table (Cases) with two different child tables (Activities and Tasks).

I figured out how to create a button in Tasks that creates a new Activity. (Go me!)

What I can't figure out is how to map fields (for example, to grab the parent Case from the Task and make it the parent Case on the Activity).

Here is the formula I have so far. I copied it from one of the automatic "Create Child" buttons that are created when you create the relationship, and then I changed the name of the table. I didn't know what else to change.

URLRoot() & "db/" & [_DBID_ACTIVITY_SUMMARY] & "?a=API_GenAddRecordForm&_fid_22=" & URLEncode ([Record ID#])& "&z=" & Rurl()
Photo of Sarah Clark

Sarah Clark

  • 602 Points 500 badge 2x thumb

Posted 3 months ago

  • 0
  • 1
Photo of QuickBasePros (Laura Thacker)

QuickBasePros (Laura Thacker), Champion

  • 5,568 Points 5k badge 2x thumb
Either:
(to create an Activity connecting it to the Case from a Task without connecting it to the Task)

URLRoot() & "db/" & [_DBID_ACTIVITY_SUMMARY] & "?a=API_GenAddRecordForm&_fid_xx=" & URLEncode ([Related Case])
& "&z=" & Rurl()

or 
(to create an Activity from a Task connecting it to both the Task and the Case)

URLRoot() & "db/" & [_DBID_ACTIVITY_SUMMARY] & "?a=API_GenAddRecordForm&_fid_xyz=" & URLEncode ([Record ID#])
& "&_fid_abc=" & URLEncode ([Related Case])
& "&z=" & Rurl()


xx and abc is going to be the [Related Case] (reference) field ID# in your Activities table (connecting it to Cases)

xyz is going to be the [Related Task] (reference) field ID # in your Activities table (connecting it to Tasks)

If, when the User saves the new Activity records, you want them to stay in the new Activity rather than go back to the Task they came from; then remove the & "&z=" & RURL() from your formula.
Photo of Sarah Clark

Sarah Clark

  • 602 Points 500 badge 2x thumb
Worked beautifully. Thank you!!!!!!!!!!!!!!!!
Photo of Sarah Clark

Sarah Clark

  • 602 Points 500 badge 2x thumb
Followup question: I also want the text in the field "Task" to become the text in the field "Subject" (fid 15) in the new Activity. I tried adding to the formula as follows, but I'm getting an error message. What did I do wrong?

URLRoot() & "db/" & [_DBID_ACTIVITY_SUMMARY] & "?a=API_GenAddRecordForm&_fid_20=" & URLEncode ([Related Case #])&_fid_15=" & URLEncode ([Task])
Photo of Sarah Clark

Sarah Clark

  • 602 Points 500 badge 2x thumb
Oh - never mind - I figured out what I was missing. Works now. Man, I feel so powerful! :)
Sarah,

A couple of resources to learn this syntax stuff are my app in the exchange called URL Formuals for Dummies and also Kirk Trachy's "Magic Buttons App".

Mark

Photo of Sarah Clark

Sarah Clark

  • 602 Points 500 badge 2x thumb
Got 'em both, and I'm sure they'll be immensely helpful. For now I need an answer soon, so it was easier to ask. :)
Photo of Sarah Clark

Sarah Clark

  • 602 Points 500 badge 2x thumb
Okay, here's a new challenge. :)

Now I want the button to "Mark Complete and Create Activity." Complete is a checkbox in the Tasks table, fid 9.

Here is where my formula stands now. What do I add to have it mark the task as complete?

URLRoot() & "db/" & [_DBID_ACTIVITY_SUMMARY] & "?a=API_GenAddRecordForm&_fid_20=" & URLEncode ([Related Case #])&"&_fid_15=" & URLEncode ([Task])

Photo of QuickBasePros (Laura Thacker)

QuickBasePros (Laura Thacker), Champion

  • 5,264 Points 5k badge 2x thumb
My question here is; can you leverage Form Rules to mark the Task as complete before creating the Activity; or is it only because you are creating the Activity that your Task is being marked as complete?

You can update the button you have built to edit the Task first, but just wanted to be sure you are needing this modification when another solution is not viable.

I'll post the API_EditRecord updated formula in a few minutes....
Photo of QuickBasePros (Laura Thacker)

QuickBasePros (Laura Thacker), Champion

  • 5,264 Points 5k badge 2x thumb
URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=xxxxxxxx&rid=" & [Record ID#]
& "&_fid_9=1"
& "&rdr=" & URLEncode(
URLRoot() & "db/" & [_DBID_ACTIVITY_SUMMARY] & "?a=API_GenAddRecordForm&_fid_20=" & URLEncode ([Related Case #])
& "&_fid_15=" & URLEncode ([Task])
)
Photo of Sarah Clark

Sarah Clark

  • 602 Points 500 badge 2x thumb
Thank you so much!
Form rules won't work because these buttons will be pressed from a report rather than a form.
Photo of QuickBasePros (Laura Thacker)

QuickBasePros (Laura Thacker), Champion

  • 5,264 Points 5k badge 2x thumb
Well that makes complete sense.