Discussions

 View Only
Expand all | Collapse all

button to create a record that is not a child

  • 1.  button to create a record that is not a child

    Posted 04-11-2019 18:40
    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()


  • 2.  RE: button to create a record that is not a child

    Posted 04-11-2019 18:48
    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.


  • 3.  RE: button to create a record that is not a child

    Posted 04-11-2019 19:05
    Worked beautifully. Thank you!!!!!!!!!!!!!!!!


  • 4.  RE: button to create a record that is not a child

    Posted 04-11-2019 19:19
    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])


  • 5.  RE: button to create a record that is not a child

    Posted 04-11-2019 19:25
    Oh - never mind - I figured out what I was missing. Works now. Man, I feel so powerful! :)


  • 6.  RE: button to create a record that is not a child

    Posted 04-11-2019 19:27
    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



  • 7.  RE: button to create a record that is not a child

    Posted 04-12-2019 14:12
    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. :)


  • 8.  RE: button to create a record that is not a child

    Posted 04-12-2019 14:10
    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])



  • 9.  RE: button to create a record that is not a child

    Posted 04-12-2019 15:08
    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....


  • 10.  RE: button to create a record that is not a child

    Posted 04-12-2019 15:14
    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])
    )


  • 11.  RE: button to create a record that is not a child

    Posted 04-12-2019 16:53
    Thank you so much!
    Form rules won't work because these buttons will be pressed from a report rather than a form.


  • 12.  RE: button to create a record that is not a child

    Posted 04-12-2019 16:54
    Well that makes complete sense.