Forum Discussion

LijaHarris's avatar
LijaHarris
Qrew Cadet
3 years ago

Add Field to end of customRedirectURL Code Page

I was wondering if it was possible in the customRedirectURL to add a different field (and it's value) at the end of the URL.  For example, in my code below, the record ID is what is populated at the end of the URL: (xxxxxxxxx is just a placeholder)

console.log(req1);
//******ADD YOUR DBID
$.ajax({url: "xxxxxxxxx?act=API_AddRecord",
type: 'POST',
data: req1,
contentType: "text/xml",
dataType: "xml",
processData: false,
success: function(data, status, xhr) {

var _rid = $(data).find('rid');
var rid = _rid[0].innerHTML;
var customRedirectURL = "https://xxxxxxx-xxxxxxx.quickbase.com/db/xxxxxxxxx?a=dbpage&pageID=2" + "&rid=" + rid;
console.log(customRedirectURL);
window.location.href = customRedirectURL;
}
});
}

instead of +rid can i use another field from the table there (field that is set by a variable)?  This does have to be in a code page and not in a URL formula field or form button, etc.  Thanks so much!

------------------------------
Lija Harris
------------------------------
  • You can do something like this which is a slimmed-down version of your code

    var customRedirectURL = "https://xxxxxxx-xxxxxxx.quickbase.com/db/xxxxxxxxx?a=dbpage&pageID=2" + "&rid=" + $(data).find('rid').text() + "&AnotherVariable=" + $(data).find('XPathToXmlNode').text();

    console.log(customRedirectURL);
    window.location.href = customRedirectURL;

    With JQuery, you can text from XML, for a given node, XML node using the this method:

    $(data).find('[XPath]').text()

    Where $(data) is the API response XML



    ------------------------------
    CDM Automation
    ------------------------------
    • LijaHarris's avatar
      LijaHarris
      Qrew Cadet
      Thank you so much for your reply!!! So, let's say I want to make _fid_23 that variable, or maybe im mis-speaking.  Ideally in a perfect world, I want a field's value at the end of the customRedirectURL.  So currently the above gives me a final redirect url of (The "X" are placeholders): https://XXXXXXXXXXXXXX.quickbase.com/db/XXXXXXXXX?a=dbpage&pageID=2&rid=72

      Instead of rid = 72 which is giving back the record id that was created by the user, I would like record 72's field's value for field 23.  So lets say field 23 is a text-formla field that is ="C-"&[Record ID#].  I would like https://XXXXXXXXXXXXXX.quickbase.com/db/XXXXXXXXX?a=dbpage&pageID=2&rid=C-72 instead.


      ------------------------------
      Lija Harris
      ------------------------------
      • SimonH's avatar
        SimonH
        Qrew Cadet
        API_AddRecord does not return other fields so you won't be able to use another field unless you make a separate request to get that records details using the newly generated rid

        ------------------------------
        Simon H
        ------------------------------