Discussions

Expand all | Collapse all

Combine API Edit button and API Add New Record Button into one button

  • 1.  Combine API Edit button and API Add New Record Button into one button

    Posted 02-06-2018 20:10
    I have two seperate buttons that each work just fine on their own. The first one edits the current record.  And the second one adds a new child record in a related table.  I would like to combine these two buttons into one button.  Any ideas?

    Button 1:

    var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_485=" & URLEncode(User()) & "&_fid_486=" & URLEncode(Now()) & "&_fid_57=" & URLEncode("Left Daycare") & If([Change Roster Date?]="yes", "&_fid_203=" & URLEncode(Today()) & "&_fid_134=" & URLEncode("Yes"), null);


    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);"



    Button 2:

    var text AddRecord =
    URLRoot() & "db/" & [_DBID_ACTIVITIES] 
    & "?act=API_AddRecord&_fid_173=" & URLEncode ([Record ID#]) & "&_fid_181=" & URLEncode([Related Center]) & "&_fid_7=" & URLEncode("Roster Update") & "&_fid_10=" & URLEncode("left daycare  " & [Name of Center]) & "&_fid_189=" & URLEncode("Removal Note");


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


    $AddRecord 
    & "&rdr=" & URLEncode($DisplayRecord)





    Any help is greatly appreciated!  Thanks!



  • 2.  RE: Combine API Edit button and API Add New Record Button into one button

    Posted 02-16-2018 21:03

    $URLONE

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

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

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


    You will need to remove the 'void.reload' portion from your first button if you are going to utilize the 'display record' variable to show a specific record.

    The edit & add variables can be in any order as long as they don't affect eachother.

    Cheers,


  • 3.  RE: Combine API Edit button and API Add New Record Button into one button

    Posted 03-20-2018 17:36
    Here is a example of a rich text formula button that will edit, add then return to where you used the button. The fid's and fields are not yours just an example If you need to go to another place changes will need to be made.


    // Begin button style

    var text bgcolor = "#099F28";

    var text txtcolor = "white";

    var text style = "style=\"text-decoration: none; box-shadow: 3px 3px 1px #888888; background:" & $bgcolor & "; border-radius: 3px; padding: 5px 8px; color: " & $txtcolor & "; display: inline-block;  font-weight: normal;font: 700 24px/1 \"Calibri\", sans-serif; text-align: center; text-shadow:none;";

    // End button style

     

    var text URL = URLRoot() & "db/"& Dbid() & "?a=API_EditRecord&rid="& [Record ID#]

    & "&_fid_869=1"

    & "&rdr="

    & URLEncode(URLEncode( URLRoot() & "db/"& [_DBID_ACTIVITIES]  & "?a=API_AddRecord"

    & "&_fid_6=" & [Location ID]

    & "&_fid_10=" & URLEncode([Task Number])

    & "&_fid_14=" & URLEncode("Service Fees")

    & "&_fid_15=" & [Install Date]

    & "&_fid_35=" & URLEncode([Related Project])

    & "&_fid_42=1"));

     

    "<a " & $style & " href=\"javascript:" & "$.get('" & $URL & "', function(){" & "location.reload();" &

     "});" & "void(0);\"> MY BUTTON NAME </a>"