AddRecord adding wrong data

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
Im trying to create a button that adds a line to an inventory table if an item is unable to be returned. My code is adding a line to the inventory table but not the correct information. It needs to copy the line item information.
Here is the info it is supposed to be copying:
ProductCode = 20
Product - Supplier = Interceramic

But it is inserting:
ProductCode = 1
   (It is inserting the 20th item in the Products List)

Here is my code:
var text URL = URLRoot() & "db/" & [_DBID_SHOWROOM_INVENTORY_LEVEL] & "?a=API_AddRecord"
& "&_fid_7=2"
& "&_fid_6=Unrecoverable"
& "&_fid_12=" & URLEncode([ProductCode]);

"javascript:" &
"$.get('" & 
$url & 
"',function(){" &
"location.reload();"&
"});" &
"void(0);"
Photo of Apryl Stoldt

Apryl Stoldt

  • 132 Points 100 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,478 Points 20k badge 2x thumb
A few ways to troubleshoot include using the AddGenRecordFrom without the refresh, and have it auto populate the information you want. 
If that is working well, then you can switch it back to the AddRecord call with the refresh.

Another bug checker is to "copy the link address" by right clicking on the link/button.  
Then paste the code so you can look at it all formatted for the URL and see if there are some syntax errors.
Photo of Apryl Stoldt

Apryl Stoldt

  • 132 Points 100 badge 2x thumb
I figured it out, where _fid_12="&URLEncode([ProductCode]), i changed it to [Related Product].