Skip to main content
Question

How do I genaddrecord and save it without any redirect on a click? I want this to happen in the back end.

  • August 4, 2017
  • 0 replies
  • 54 views

How do I genaddrecord and save it without any redirect on a click? I want this to happen in the back end.
This topic has been closed for replies.

  • Registered
  • August 4, 2017
first you'll need the image onload technique so you can load javascript pages on your forms/reports. After that's installed open up the page, add this code to edit or add views wherever you want it to run.

Then create a formula text button that you'll use to trigger it
Name the id of the button qbu_something instead of qbu_yourCustomBtn

dbidVariable should be the table ID like this
var dbidTableName = "aj867234jaf";

The example below create a record and assigns the related record value to the parent record id (kRid) you can type that in your console while on a record page and it will tell you the record id.
_fid_1 is your field ID that you're updated so in my case the related record field in the child table is _fid_10 and 9 is a text field and I enter purchase approved. 

then place this code after you've updated the values in that javascript page you made under the proper view (add/edit/report)

$('#qbu_yourCustomBtn').on('click',
            function() {
                $.post(dbidVariable, {
                    act: "API_AddRecord",
                    _fid_10: kRid,
                    _fid_9: "Purchase Approved"
                }, function(resp) {
                    console.dirxml(resp)
                   //Do something with the response.
                })
            });

Let me know if this makes sense or if you need direct help setting this up.
chuck@chuck.support
Good luck!

Sania,

Can you describe what you want to happen when the user clicks.  I'm 99% sure that this can be done natively without resorting to the image onload technique.

This is an example:

var text URL= URLRoot() & "db/" & [_DBID_TABLE_1] & "?act=API_AddRecord"
& "&_fid_6=" & URLEncode ([Record ID#])
& "&_fid_7=" & URLEncode ([Status])
& "&_fid_10=" & URLEncode ([Name])

& "&apptoken=" & "XXXX";


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

Get the API Add Record working first.  Then add in the javascript refresh part.  The reason is that you need to see if there are any error messages and that refresh will hide the success or failure message.