Discussions

Expand all | Collapse all

Is there a way to add a record (using a formula button in a report) without being redirected to that record?

  • 1.  Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 18:53
    I would like to create child "IRR" records from a report of parent "ticker" records by just clicking a button. I currently have the "Add IRR" button 
    URLRoot() & "db/" & [_DBID_IRR] & "?a=API_GenAddRecordForm&_fid_10=" & URLEncode ([Record ID#])& "&z=" & Rurl()
    but I want it to stay on the report view and just create the record in the background

    I know I can do a workaround by using an action triggered by a checkbox, but I don't want to have to edit the parent record

    Is there a way I can adjust the existing button code?

    Thanks


  • 2.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 19:21
    Do you want to refresh the report / record you are on or just have a quiet fade away pop up saying that the record has been added?


  • 3.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 19:23
    no need to refresh, I'd rather not have to wait that extra second between clicks


  • 4.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 19:28
    Here is an example.  You will need to disable the need for app tokens or else add a line to the code like

    & "&apptoken=xxxxxxxxxx"

    var datetime SnoozeUntil = ToTimestamp(Today() + Days(1), ToTimeOfDay("0:00"));


    var text URL = URLRoot() & "db/" & [_DBID_DEALLOCATION_CANDIDATES] & "?act=API_EditRecord"
     & "&rid=" & [Record ID#]
     & "&apptoken=xxxxxxxxxx"
     & "&_fid_415=" & ToText($SnoozeUntil)
     & "&_fid_416=" & ToText(Now()); // set the date/time so we know if the line existed when snoozed


     
    "javascript:" &
    "$.get('" & 
    $url & 
    "',function(){" &
    "$.jGrowl('put your pop up words here', {life: 5000, theme: 'jGrowl-green'});" &
    "});" &
    "void(0);


  • 5.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 19:35
    I get an error for [_DBID_DEALLOCATION_CANDIDATES]  what is that supposed to refer to?


  • 6.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 19:40
    Also, the popup is not necessary


  • 7.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 19:46
    You will want to let the user know that clicking the button "worked' or else they will just keep on clicking it and lot of child records will be created.  In any event, the pop up does not slow down the process.   The 5000 means 5 seconds before the pop up fades away on its own.  You can adjust that as you like.


  • 8.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 20:18
    I see what you are saying, thanks. Now the popup is working and it creates the record in IRR but the record is not connected to the ticker (parent record)
    This is what I have:

    var datetime SnoozeUntil = ToTimestamp(Today() + Days(1), ToTimeOfDay("0:00"));


    var text URL = URLRoot() & "db/" & [_DBID_IRR] & "?act=API_AddRecord"
     & "&rid=" & [Record ID#]
     & "&apptoken=qqj2k7wz..."
     & "&_fid_415=" & ToText($SnoozeUntil)
     & "&_fid_416=" & ToText(Now()); // set the date/time so we know if the line existed when snoozed


     
    "javascript:" &
    "$.get('" & 
    $url & 
    "',function(){" &
    "$.jGrowl('Record Added', {life: 5000, theme: 'jGrowl-green'});" &
    "});" &
    "void(0);


  • 9.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 20:23
    I got It! 
    var text URL = URLRoot() & "db/" & [_DBID_IRR] & "?act=API_AddRecord"
     & "&_fid_10=" & URLEncode([Record ID#])

    Thanks for your help!


  • 10.  RE: Is there a way to add a record (using a formula button in a report) without being redirected to that record?

    Posted 07-10-2018 20:24
    OK, so you are not understanding my example,

    a line like this 

    & "&_fid_416=" & ToText(Now())

    means to populate fid 416 with a value.

    so similar to your original formula
     you need to put in a line like 

    &_fid_10=" & URLEncode ([Record ID#])


    to connect the child to the Parent because your field 10 is the field for [Related Parent]