Edit Record and then go to add new record Page

  • 0
  • 2
  • Question
  • Updated 2 years ago
  • Answered
I need to create a button that will edit the current record and then redirect me to the "add new record" form for that table.  Ideally I would like this new record to pull over certain fields from the first record.  The syntax is right and separatly each URL works fine but when combined I get a document tree error.  Here is my formula - URL.  Thanks!

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&rid=" & [Record ID#] &
    "&apptoken=xxxxxxx" &
    "&_fid_11=Inactive" &
    "&rdr=" &


URLRoot() & "db/" & [_DBID_PROVIDER_ASSIGNMENTS] 
   & "?a=API_GenAddRecordForm\n\n&_fid_12=" 
   &[Related Vehicle]
   & "&apptoken=xxxxxxx" &
 URLEncode(URLRoot() & "db/" & Dbid() &
        "?a=dr&rid=" & [Record ID#])
Photo of Jacob

Jacob

  • 738 Points 500 badge 2x thumb
  • Unsure

Posted 2 years ago

  • 0
  • 2
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
Here is an example of an Edit of a project task, then a rdr to add a project note.
URLRoot() & "db/" & [_DBID_PROJECT_TASKS] & "?a=API_EditRecord&rid="&[Record ID#]&"&apptoken=xxxxxxxxxxxxxxxxxx&_fid_9="&URLEncode(Today())&"&_fid_25="&URLEncode(User())&"&_fid_27="&URLEncode(Now())&"&rdr="&
URLEncode(URLRoot() & "db/" & [_DBID_NOTES] & "?a=API_GenAddRecordForm&_fid_13=" & URLEncode ([Record ID#])& "&_fid_8=" & URLEncode ([Project - Related Client])& "&_fid_15=" & URLEncode ([Related Project])& "&z=" & Rurl())
A few syntax errors I see in yours:
  • You have an extra quote after your app tokens
  • You need an URLEncode after the rdr to encode the second part.
  • If you use the API_GenAddRecordForm you do not need an app token, as this will take you to the form with any information you bring through.
  • If you want to just create the record without confirmation use API_AddRecord.
How do you plan to use the second part?  Do you want to go to the form to complete other information, or do you just want to create a new record?

You can read more about the API HERE
Photo of Jacob

Jacob

  • 738 Points 500 badge 2x thumb
Basically I am tracking history of changes. The first part will make the current record inactive and then I will add a new record. That new record will need other information completed before saving. I got the URL formula to change the status and go to new record page but I can't pull over any information.
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
You'll need code in the URL which data to pass to which field.  
From the example above:
URLEncode(URLRoot() & "db/" & [_DBID_NOTES] & "?a=API_GenAddRecordForm&_fid_13=" & URLEncode ([Record ID#])& "&_fid_8=" & URLEncode ([Project - Related Client])& "&_fid_15=" & URLEncode ([Related Project])& "&z=" & Rurl())
after the GenAddRecordForm we have a '&_fid_13="  this is saying that in the new form find field id 13 and write this value to it. "&URLEncode([Record ID#])&"

So take that field id (13), which is the relationship field of the note to the job, and rights the record ID of the job, thus automatically creating the relationship.

You can do this same thing for any of the fields on the new table.
You will need to know your target field ID, _fid_13=, and the data from the parent you want to write, [Record Id#], [Project Status], etc.

Does that help?
Photo of Jacob

Jacob

  • 738 Points 500 badge 2x thumb
Great!  Thanks.  Works great now!  The record is edited and data is added to it and then it redirects the user to the add form page pulling in the related field creating the relationship.