After creating a record with Scooby do technique want to edit the new created record with API_EditRecord.

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

After creating a record with Scooby Doo technique want to edit the new created record with API_EditRecord.

 

I’m using:

 

if (/nwr/i.test(querystring)) {

 

    $("<iframe>", {id: "QBU_editform", name: "QBU_editform"})

      .css({display: "none"})

      .appendTo("body")

      .on("load", function() {

        QBbusyHide();

        var rid = this.contentWindow.kRid;

        alert(rid);

 

        $.post(dbidTable, {

          act: "API_EditRecord",

          rid: rid,

          _fid_129: "test"

 

        }).then(function(xml) {

            console.dirxml(xml);

 

[Log] #document

<qdbapi>​

<action>​API_EditRecord​</action>​

<errcode>​30​</errcode>​

<errtext>​No such record​</errtext>​

<errdetail>​

"Sorry, there is no record in this application table with the record identifier (rid)  of "102"."

</errdetail>​

</qdbapi>​

 

The record Id of the new record is 102.

 

Tested a couple of combinations in the spell check of the rid:

 

Do I have to use key instead of rid it is a spelling problem?

 

Photo of eduardo

eduardo

  • 40 Points

Posted 3 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,004 Points 20k badge 2x thumb
You have to use straightforward debugging techniques rather than post a question when you encounter a small problem. 

What does the alert(rid) in your code report?

This error message looks wonky with the double quote inside the pair of double quotes:

"Sorry, there is no record in this application table with the record identifier (rid)  of "102"."
Photo of eduardo

eduardo

  • 40 Points
alert rid reports 102, which is the newly created record Id.

I can use this rid to add a new record and relate the new record with record id 102.
Does not have 102"  

Don't know why I cannot edit using rid

3 years ago there was a similar question

https://quickbase-community.intuit.com/questions/168810-api_editrecord-missing-rid-error


"Instead of using $.post, I tried $.ajax and explicitly set the contentType and dataType to 'text/xml' and 'xml' respectively... suddenly, it works."

Very sorry dan this simple things must be a pain in the ass to you and you are really so collaborative.

I  really I tried for a day and couldn't solve it. Tried again just a few minutes
I use sublime text, but my debugging technique is cut and paste see if it works and read the  console.dirxml(xml);

By the way the Scooby do can be used also in an edit form?
Do I have to  change the

if (/nwr/i.test(querystring)) {

and follow the steps?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,004 Points 20k badge 2x thumb
I don't think you posted your complete code. I don't see this essential statement:

   $("form[name=editform]").prop({target: "QBU_editform"});

Without this statement the whole scheme will not work but you do appear to be alerting the new [record ID#]. But I can only debug seeing the complete code. Run your code through jsbeautifier with two spaces and post to a public pastie.
Photo of eduardo

eduardo

  • 40 Points
I have it dan it is working with add record, it is working with query etc.
Don't now why with edit, gonna try changing $.post, to  $.when(promise)


(function(){
  var dbidTable= "bkhdj8qxa";
  var apptoken = "cv62p3b9a6kgmbpiw5smd24qvpr";

  var XMLFlatToObj = function(xml, type) {
  var data = [];
  var record = {};
  $("record", xml).each(function() {
    record = {};
    $(this).children().each(function () {
      record[$(this).prop("tagName")] = $(this).text();
    });
    data.push(record);
  });
  return {records: data};
};


  $.ajaxSetup({data: {apptoken: apptoken}});
  var querystring=document.location.search;

  if (/nwr/i.test(querystring)) {

    $("<iframe>", {id: "QBU_editform", name: "QBU_editform"})
      .css({display: "none"})
      .appendTo("body")
      .on("load", function() {
        QBbusyHide();
        var rid = this.contentWindow.kRid;
        alert(rid);

        $.post(dbidTable, {
          act: "API_EditRecord",
          rid: rid,
          _fid_129: "casagrande"

        }).then(function(xml) {
            console.dirxml(xml);
          

           //document.location.href = gReqDBID + "?a=er&rid=" + rid;

          

        });

        

        

      });
    $("form[name=editform]").prop({target: "QBU_editform"});
  }

})();