Formula URL Button from CHILD table to Generate new child record of the same parent.

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

This shouldn't be so difficult to explain so here goes.....

I have a Parent Table with 2 child tables: 

ITEMS - Parent

CHILD - Current Inventory

CHILD - Inventory Inspections

I need to be on the current inventory table and create a button to complete an inventory inspection for the common parent. 

How can I do that?  I've searched all over and everything seems to be suggesting creating a relationship between the two children and I DO NOT want to do that.  My current inventory records will be purged nightly so the relationship has to be with the parent.  Any help is appreciated. 

Photo of Krissy

Krissy

  • 110 Points 100 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Blake Harrison - DataBlender

Blake Harrison - DataBlender, Champion

  • 100 Points 100 badge 2x thumb
The easiest way would be to copy the formula in the Add Inventory Inspections button from your Parent table, and paste it into a new Formula URL field on your Current Inventory table. Most likely, the code starts out looking something like this:

URLRoot() & "db/" & [_DBID_CHILD] & "?a=API_GenAddRecordForm&_fid_8=" & URLEncode ([Record ID#])& "&z=" & Rurl()

You'll want to modify the formula to use the Related Item field instead of the Record ID# field (in bold above) and you should be good to go.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,224 Points 20k badge 2x thumb
Use script with something like this (untested):

$.get(dbidParent, {
  act: "API_DoQuery",
  query: "{3.EX." + kRid + "}",
  clist: "3",
}).then(function(xml) {
  console.dirxml(xml);
  var ridParent = $("record_id_", xml).text();
  $.post(dbidChild, {
    act: "API_AddRecord",
    _fid_6: ridParent
  }).then(function(xml) {
    console.dirxml(xml);
    //do something like redirect
  });
});}
Photo of Krissy

Krissy

  • 110 Points 100 badge 2x thumb
Thank you!  That did the trick!
Photo of Krissy

Krissy

  • 110 Points 100 badge 2x thumb
This may be the better way to do it but it's also totally over my head!