ScoobyDoo works when applied to a simple table, but does not work when used with a different table?

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

Here is the code:

http://pastie.org/10720906

Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
I fixed a missing variable... here is the new pastie.  http://pastie.org/10720925
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
What is strange is that it works fine against table A.  The IOL is very simple.  

[iol] &  "z_startEventAfterAdd.js" & [/iol]

it is the same for both forms and when the form loads on table B.  I do get the first alert of "Loading startEventAfterAdd", but I do not get any of the subsequent alerts like:
               alert("qbu_EventId (" + qbu_EventId + ")");
which is right after the debugger, and the alert for the undefined qbu_EventId.

After I click the save button, there are none of the alerts that I expect, or that I get when working with table A.

Any thoughts or ideas are greatly appreciated as I am totally stuck right now.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
There is no variable debugger defined in your code so the JavaScript throws an error and stops running at that point.

UPDATE: If you are trying to use the console command debugger it will set a breakpoint and stop executing JavaScript at that point and no further statements will execute until you jump over the breakpoint.
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
I have been using debugger to stop processing and allow me to step through the code?  However, I removed the line but same behavior.  Any other thoughts?  Again... I have defined this same script with another table and the behavior is as expected... but when I try to use it against the current table it gives no response... just saves the record but the script does not run.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
Try console.log before and after this statement:

        var qbu_EventId = this.contentWindow.kRid;

If that statement fails use the ob32 version to get the rid value:

        var rid = ob32decode(url.match(/r=([abcdefghijkmnpqrstuvwxyz23456789]+)/)[1]);

 Do you see the same behavior in all brosers?
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
like this?
                 console.log;
                 var qbu_EventId = this.contentWindow.kRid;
                 console.log;
  and yes, I am getting consistent behavior in MS explorer, firefox, and chrome.
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
no change with thei above.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
console.log ("here")
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
Dan, Are you available for private consultation?  May I email you personally?
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
Dinner is almost ready so I need to leave for a bit... Dean
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
ok... added the following
                 console.log("console log 1")
                 var qbu_EventId = this.contentWindow.kRid;
                 console.log("console log 2")
 
What should I see?
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
ok... so in the console i see messages.  How do I get them in here?  I did a print screen, and saved to a file... but do not see how to attach to here?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
you have to answer instead of comment or amend your original question
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
log output attached.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
Those are all warning messages your IE browser is tossing out complaining about QuickBase's page. I don't see the output of your console.log() commands - perhaps it has scrolled off the screen.
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
When I run this against table B, I don't get the output.  It isn't making it inside the .on("load", function()  code.  when I run against table A, I do get the console.log messages, and I get the alerts, and it branches to the called functions properly.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
I don't know Table A from Table B. You have to include the [-] field in any form where you want to call a user defined page module.js. So you have one form for Table A and you have placed [-] on this form and the code you supplied runs. That is all the technique does short of what you put in your code. If you want to do something  such as create child records knowing the {Record ID#] of the newly created parent you just make an AJAX call to API_ImportFromCSV or API_AddRecord and add your child records and with the [Record ID#] value to set the [Related Parent] in the child. You only have to gain control of the page with module.js once.
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
when you say [-] does that mean the formula text field with the [iol]... [/iol] in it?  If so... I have that in the form for table A that works, and I have it for the form for table B that is not working.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
yes [-] is the typical field label for the image onload field. So far all you work has been dealing with one table, one form and one IOL field. I don't see any reference to a second table. If you want to customize the behavior of a second form for a second table you have to independably create an IOL field in that second table and insert it into the second form as well as supply a second user defined page such as moduleTable2.js
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
yes... i have done that.  if I didn't then I wouldnt be getting the first alert indicating that the script was loading when the form loads.  The problem is that it stops after the first alert.  It does not continue and I do not get any messages from the onLoad section.  I talk about it working for table A so you understand that the script does work.
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
and ... the save does not seem to trigger the iol script.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
Where is the startEventAfterAdd () function defined? I think you can narrow down the problem with appropriate console commands if you change one thing at a time from a known good state.
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
ok... I see that for the form that works on table A, the url is this:
https://fixandpaint.quickbase.com/db/bkk8m27xh?a=nwr
and on the form for table B that does not work, the url is
https://fixandpaint.quickbase.com/db/bkejte6r4?a=API_GenAddRecordForm&_fid_9=134&_fid_17=&_fid_53=2831&z=xz3

And ... I see from your code, the if test is on nwr.  Could this be the problem?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,024 Points 20k badge 2x thumb
That is the problem. You need to decode that second page using code from the generic template:

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=293
Photo of Dean

Dean

  • 708 Points 500 badge 2x thumb
I changed the code for the button that I am using to call the page to use nwr instead of the api_genAddRecordForm and now the code is firing... but I am not seeing the  this.contentWindow.kRid.  I used debugger and went looking for the field but it is not there.  Thoughts?  BTW... thanks for the help.