Forum Discussion

ClaytonRountree's avatar
ClaytonRountree
Qrew Cadet
7 years ago

Populating a Lookup field with Formula URL button

Hi, I have 3 tables involved in this issue. Parent: Estimates, Child: Estimate Details, and a related Table "Teams". I have a button that creates several children records on Estimate Details. The button sits on Estimates. The children records have certain fields that I pre-populate (assign) values to in the button code, like adding a timestamp, and labeling the status as TBD. Teams is related to Estimate Details, each team can have many estimate details.

Previously, the button would also assign a team name, using the text of the team name. This was sent to a Multiple Choice Text Field. I've tried to update my DB structure, so that we host the list of Teams on its own table. Thus, I'd like to populate the children on Estimate Details with the corresponding team name from the Teams table.

Sample Code:

var text AddCEmailServices=

URLRoot() & "db/" & [_DBID_Estimate_Detail]

& "?act=API_AddRecord&_fid_41=" & URLEncode ([Record ID#])

& "&_fid_49=" & "Commercial - Email Services"

& "&_fid_40=" & "TBD"

& "&_fid_89=" &  Now()

& "&disprec=1";


and later: 

"javascript:" & 

"$.get('" & $AddCEmailServices & "').then(function(){" &

...

"});" &

"void(0);"

 

The bold italic line is what I'm hoping to change. The field that links from Teams table is fid_100 for [Related Team] (Record ID) and the proxy [Team Name] is the team name fid_101. I've tried replacing that line above with

 & "&_fid_100=" & URLEncode ("5")

 as well as:

 & "&_fid_101=" & "Commercial - Email Services"

 These have not worked. Please let me know if you have any suggestions. Thanks!

2 Replies

  • The code you posted here

    & "&_fid_100=" & URLEncode ("5")

    is the correct code if in fact the field for {Related Team] is fid 100.

    What I suggest to debug this is to reveal any error message like this

    var text AddCEmailServices=

    URLRoot() & "db/" & [_DBID_Estimate_Detail]

    & "?act=API_AddRecord&_fid_41=" & URLEncode ([Record ID#])

     & "&_fid_100=" & URLEncode ("5")

    & "&_fid_40=" & "TBD"

    & "&_fid_89=" &  Now()

    & "&disprec=1";


    $AddCEmailServicesURL



     and then comment out that javascript code.

    That will just run the URL formula and you will see if that errors out on something.

     When you do that javascript refresh, it hides any error message.
  • Thanks! That worked (in conjunction with turning off required status for fid 49, the old team field)