Forum Discussion

EOMDevelepors's avatar
EOMDevelepors
Qrew Captain
5 years ago

Dynamic fid for javascript pages

I created a javascript page to add a note to a record. It works great and here is my code:

(function(){
  var dbid = "tableExample";
  var dbidTable = dbid;
  var apptoken = "tokenExample";
  $.ajaxSetup({data: {apptoken: apptoken}});
  var memo = prompt("Enter your note here:", "");
    if (memo== null || memo== "")  {
  alert("You did not enter a memo. Please try again");
  Return;
  }
  var promise = $.get(dbidTable, {
    act: "API_EditRecord",
    rid: QBU_rid,
  _fid_29: memo,
   }).then(function(xml) {
    console.dirxml(xml);
 $.get() & location.reload(true);
  });
})();

The question is that instead of creating a code page for each table that needs a memo field, I want a dynamic solution which will contain the fid in the button formula and pass it into the javascript page so I can use the same page for any given table.

I was assuming that the _fid_29 can be replaced with the var name of the fid which was passed in from the button formula. Is there anyone that knows how to get this to work?

Thanks
No RepliesBe the first to reply