Generating key name based on value passed to function

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I have a function that takes a Quickbase recordID and fieldID and deletes any file associated with that field. First, the function:
function deleteFiles(recid,fldid) {

    var apptoken = "xxxxxxxxxxxxxxxxxxxxxxxxx";
    $.ajaxSetup({data: {apptoken: apptoken}});

    var dbid = "xxxxxxxxx";

    var promise = $.post(dbid, {
        act: "API_EditRecord",
        rid: recid,
        _fid_NN: "",
        delfile_fid_NN: "1"


where "NN" needs to equal the fieldID (fldid) being passed. I've tried concatenating the fldid onto those two key names but that didn't work. I've seen a lot of similar questions that suggest creating objects, etc., but those won't work in my situation, either. So the question is, how do I dynamically alter those key names so that QB is happy and the files get deleted? 


Photo of Tejaswini


  • 86 Points 75 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
Official Response
This may help:

You can pass the variable to the code page with something like this:

 href=\"javascript:window.location.href = '"&[Record ID#]&"'\"

Then in the code page you will need to translate that value with something similar to this:

 A.controller('main', ['$scope', function($scope) {        $scope.params = UrlParam();
        $scope.temp = {};

        $scope.parent = $scope.params.parent;

        $scope.qb = new QuickBaseClient();

Its not direct, but if you know your code and what you are trying to do that should help you pass the information needed.