Discussions

Expand all | Collapse all

Is there a way to edit a record and add a record to another table with the same button?

  • 1.  Is there a way to edit a record and add a record to another table with the same button?

    Posted 07-16-2018 20:27
    Hello! I have currently have a button that adds a record to another table with a shared parent record. Is there a way I can have this button also edit the original child record? 

    to clarify, I am working with three tables, the parent table, and two children tables. I have a button to "convert" a record from one type of child record to the second, but I want to mark the original record with the date it was "converted"

    Here is what I have so far, it creates the new record, but does not edit the original.

    var text AddRecordOne =
    URLRoot() & "db/" & "dbidforchild2"
    & "?act=API_GenAddRecordForm&_fid_15=" & URLEncode ([Related Site])
    & "&_fid_12=" & URLEncode([Notes])
    & "&_fid_8=" & URLEncode([Forecast Complete])
    & "&apptoken=******************"; 

    var text EditTask=   //mark task as completed
    URLRoot() & "db/" & "dbidforchild1" 
    & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_8=" & URLEncode(Today())
    & "&apptoken=****************"; 


    var text DisplayRecord=

    URLRoot() & "db/" & Dbid() 
    & "?a=dr&rid=" & [Record ID#];

    $AddRecordOne &
    $EditTask


  • 2.  RE: Is there a way to edit a record and add a record to another table with the same button?

    Posted 07-16-2018 22:45
    This will work

    $EditTask
    & "rdr=" & urlencode($AddRecordOne)

    However, be aware that if the user clicks that button to Create the 2nd child record manually and they get stuck by lightning or lose the internet or just get distracted and they never actually save the 2nd child record, then the original child will be already flagged as converted, but in fact was not.

    I suggest a more foolproof method would be to make the 2nd child also be a child of the first child.  Then the 1st child can have a summary count field to know how many 2nd child children it has (it should be 1 if successfully converted).  So then the flag on the first child as to if it has been converted will be if the [# of 2nd children] >0.


  • 3.  RE: Is there a way to edit a record and add a record to another table with the same button?

    Posted 07-17-2018 14:04
    THANK YOU! This did it. I will look into your other way as well, but at least it's working for now!


  • 4.  RE: Is there a way to edit a record and add a record to another table with the same button?

    Posted 07-17-2018 09:15
    HI There,

    Thank to Mark, I got mine working...you are welcome to try it.

    var text URLONE = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&rid=" & [Record ID#] &
        "&apptoken=65zusbcixqngsbqnkhn39juqdk" &
        "&_fid_222=" & [Current Date and Time] ;
     

    var text URLTWO = URLRoot() & "db/" & Dbid() & "?act=API_AddRecord" &
        "&apptoken=65zusbcixqngsbqnkhn39juqdk" 
    & "&_fid_9=" & [Related Link Order]
    & "&_fid_8=" & [Why do you want to reschedule Forecast Date?]
    & "&_fid_28=" & [Related Link Build - Contractors]
    & "&_fid_6=" & [Proposed Reschedule Forecast Date]
    & "&_fid_53=" & [Which Link is scheduled?] &

        "&rdr=" &
     URLEncode(URLRoot() & "db/" & "bmjz2qva6" &
            "?a=q&qid=21" & 
            "&z=" & Rurl());


    $URLONE

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

    URLONE - updates existing record, and URLTWO creates new record and redirect to report.