Forum Discussion
- ChuckGrigsbyQrew Cadetfirst 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!- ChuckGrigsbyQrew Cadetalso in place of the //Do something,
you could put alert("New record added") which would show a dialog box if you still wanted the user to know it went through.
- QuickBaseCoachDQrew CaptainSania,
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.- ArchiveUserQrew CaptainI want to click on a button, that will create a record and save it with some pre populated fields. Basically, I don't want user to edit the add form but just save it with the information that is pre populated
- QuickBaseCoachDQrew Captainso this can be done natively.
When the user clicks the button do you just want to show a quiet pop up saying like "Record Added", or do you want top refresh the record the user is on to perhaps show that a child record was added.
- QuickBaseCoachDQrew CaptainThis 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.