api Addrecord not adding when related field number

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

This code works, but I need to send over the related fields (in bold) as well, and then it doesn't work.

If([Added NRO]=false,
"<a id='CreateSiteButton'class='Vibrant Success'  href=" & URLRoot() & "db/" & [_DBID_NEW_SITES_] & "?act=API_AddRecord&_fid_35=" & URLEncode([Project Name])
&"&_fid_7=" & URLEncode([Country])
&"&_fid_9=" & URLEncode([RD])
&"&_fid_10=" & URLEncode([DoD])
&"&_fid_11=" & URLEncode([D&C])
&"&_fid_131=" & URLEncode([Region])
// &"&_fid_188=" & URLEncode([Record ID#])
// &"&_fid_105=" & URLEncode([Related Franchisee])
// &"&_fid_106=" & URLEncode([Franchisee - Franchise Name])
// &"&_fid_172=" & URLEncode([Franchisee - Customer Number])
&
 "&rdr=" &
URLEncode(URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_786=true"
& "&rdr=" &
URLEncode(URLRoot() & "db/" & Dbid() & "?a=er&rid="& [Record ID#]))
& ">Create New Site</a>",

"<b>Site has been added to the New Sites table.</b>"
)

Photo of bonnie

bonnie

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Are you trying to update lookup fields? You may not update a lookup field (or a formula field).  You can only update the [Related Parent] field and then the lookup fields will come down on their own.  That may be breaking the update from happening as it would be erroring on that problem.
Photo of bonnie

bonnie

  • 0 Points
FID 188 is the Related Checklist field linking the 2 - which is why I am trying to send the Record ID# of the Checklist table - but it doesn't work.  This is how I am trying to get the lookup fields to retrieve the information.
Is field ID 105 an editable field in manual data entry?  Or is it a lookup field?
Photo of Scott

Scott

  • 334 Points 250 badge 2x thumb
Hi Bonnie,
Is [Franchisee - Franchise Name] the proxy field for [Related Franchisee]?  When you try to copy the proxy field along with the actual Related Reference field, quickbase goofs and copies nothing.  If [Franchisee - Franchise Name] is the proxy field, exclude it from the transfer, as it will fill in when [Related Franchisee] is transferred over.  You will not need to transfer over Franchise Name or Customer Number as they look like they are lookup fields and [Related Franchisee] will bring them over.  

As for [Record ID#], this could be because you are including the proxy field (Perhaps [Project Name]?) over as well.  Could be the same issue as [Related Franchisee].  Try removing the proxy fields.

However if they aren't related, then I don't know off the top of my head!  Could you provide a little more details on your table structure and perhaps a brief summary of how each field is set up?

Another side note, you'll have to make sure all of your _fid_###'s are manual entry fields.  You cannot force data into a lookup field.
Photo of bonnie

bonnie

  • 0 Points
FID 105 is not editable it is a reference field to a franchisee master table - Related Fanchisee

So I changed the code to look like this - most everything commented out - it didn't work.  Decided I would just pass the Related Checklist (Record ID#) reference to the New Sites - so the lookup fields could be used.  No good.

If([Added NRO]=false,
"<a id='CreateSiteButton'class='Vibrant Success'  href=" & URLRoot() & "db/" & [_DBID_NEW_SITES_]
& "?act=API_AddRecord&_fid_188=" & URLEncode([Record ID#])
// &"&_fid_7=" & URLEncode([Country])
//&"&_fid_9=" & URLEncode([RD])
//&"&_fid_10=" & URLEncode([DoD])
// &"&_fid_11=" & URLEncode([D&C])
// &"&_fid_105=" & URLEncode([Related Franchisee])
// &"&_fid_106=" & URLEncode([Franchisee - Franchise Name])
// &"&_fid_172=" & URLEncode([Franchisee - Customer Number])
&
 "&rdr=" &
URLEncode(URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_786=true"
& "&rdr=" &
URLEncode(URLRoot() & "db/" & Dbid() & "?a=er&rid="& [Record ID#]))
& ">Create New Site</a>",

"<b>Site has been added to the New Sites table.</b>"
)
1. so when you say "no good" - what are the symptoms - the record gets added but the field is not populated?
Also, I suggest getting the basic URL formula working before wrapping it in that hyperlink - I have found that hyperlinks with redirects don't work (I seem to recall that when I last tested, so let's eliminate that as a possible cause by just getting the basic URL and redirect working.
Photo of bonnie

bonnie

  • 0 Points
doesn't add the record.
OK, so what if you just do the URL without the hyperlink parts

does this part work?

URLRoot() & "db/" & [_DBID_NEW_SITES_]
& "?act=API_AddRecord&_fid_188=" & URLEncode([Record ID#])

I mean it just HAS to work.  I think that we are barking up the wrong tree on that fid 188.
also the URL encoding is incorrect and will not work

The format is this

$URLONE
& "&rdr=" & URLEncode($URLTWO)
& URLEncode("&rdr=" & URLEncode($URLTHREE))

I suggest that you make your three URLs into formula variables and write it that way as you need to double encode that last redirect.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,224 Points 20k badge 2x thumb
My eyes are bleeding after looking at that formula. Just use script and the problem will be so much easier.