Creating a button that creates and populates a new record without opening the record

  • 1
  • 1
  • Question
  • Updated 1 year ago
  • Answered
Here is the code - with the help of Matthew Neil! However, the date is not populating into the record, and I would also like it to pull the name of the person identified in the parent record.


var text URL= URLRoot() & "db/" & [_DBID_CHILD_TABLE_ID] & "?a=API_AddRecord&_fid_yy="&URLEncode ([Record ID#])&"&apptoken=zzzzzzzzzzzz&_fid_xx="&URLEncode(Today());

"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"
Photo of Kelly

Kelly

  • 1,762 Points 1k badge 2x thumb

Posted 1 year ago

  • 1
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
Can you post "your" formula?  You can change the app token to zzzzzz, but please leave the rest of it as is.  Then I should be able to spot the error.
Photo of Kelly

Kelly

  • 1,762 Points 1k badge 2x thumb
Here you go... Also started a new thread.

var text URL= URLRoot() & "db/" & [_DBID_TIME_CLOCK] & "?a=API_AddRecord&_fid_6="&URLEncode ([Record ID#])&"&apptoken=d58b2yeetqfh3d7snhfjdjf7sv2&_fid_xx="&URLEncode(Today());

"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
Ok, Don't feel bad, but....
in the portion of the formula after the app token where we are putting the "Today" function.

&apptoken=d58b2yeetqfh3d7snhfjdjf7sv2&_fid_xx="&URLEncode(Today());

You need to change the "xx" to be the field ID of your date field on the child table.  So if the date field is field id 12 your formula would look like:

&_fid_12="&URLEncode(Today());
(Edited)
Photo of Kelly

Kelly

  • 1,762 Points 1k badge 2x thumb
Lol... I put that in the first ID field, which now explains why it wasn't going into the correct record. Thank you!
Photo of Kelly

Kelly

  • 1,762 Points 1k badge 2x thumb
Oh, I should add... It works beautifully!