Another jQuery help request...back to basics..

  • 1
  • 1
  • Question
  • Updated 2 months ago
  • In Progress
I could use some help with a simple looping script I have been attempting to put together for the last two weeks with no success.  The purpose of the script is to easily add a range (large range) of phone numbers to our quickbase database without the need of csv importing or repeatedly using "Copy+Paste Special" in data entry mode.  I have been learning Javascript as I go, depending on the project I am assigned/asked to do.

Originally I had a JS function in the IOL file that I was attempting to call from a Formula URL button, but with no luck. It went something like this :

[code]
function addTNRange(start,end,prod,loc){
 // Error checking here
// for loop to add a record for every TN in the given range
alert("Range added.")
};
[/code]

I have tried both the basic IOL method and getScript.  Is this the right approach? Is there a better method for what I'm attempting to do?
Photo of Doug Hines

Doug Hines

  • 142 Points 100 badge 2x thumb
  • frustrated

Posted 2 months ago

  • 1
  • 1
Where is the actual data coming from? Is it from another Quick Base table, an external source?

For clarity - you description has an odd statement about trying to call IOL from a formula-url. IOL is used when you need to run a script without user intervention. The idea being that when an image loads on the page - your browser does something with that, like run a script. So perhaps I'm misunderstanding - but those two normally aren't combined and that you have to click a formula-url.

If you're clicking a button - getScript is one option - another is to actually just use a Quick Base code page.

getScript is a jQuery function - in this case, that would call out and load your JS file, and you could have a button on a Quick Base run your function with your getScript

A Quick Base code page is similar, in that you could set up a simple HTML page, and write you own Javascript into it. The advantage being there that you're not bound by Quick Base formula syntax and it makes it 100x easier to debug on the fly. 

In that case - all you do is make a formula-url that directs you to the code page like: 

https://yourrealm.quickbase.com/db/appDBID?a=dbpage&pageid=2

Where page ID 2 is your code page that contains HTML and JS. What I do a lot in this is just to put a really simple spinner as the HTML body so you know the page is doing something, and then all of you JS just runs. Once its done - you kick a re-direct back where ever you want.

Chayce Duncan | Technical Lead
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
If you're still looking to actually script it - I would still recommend going with a code page. You'll have more ability to actually have a UI - and have an interface for error checking or reviewing what gets done in your script for the end user to see. Using getScript in a formula will have a lot less opportunity to be able to do that.

Chayce Duncan | Technical Lead
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
Photo of Doug Hines

Doug Hines

  • 142 Points 100 badge 2x thumb
I've moved to the code page route.
I have a html file that I can successfully call from a formula URL on one of my tables.  I am now running into a road block of being able to pass/store field values so I can use them in the code page.

I'm currently attempting to use a sessionStore, but I think the conversion into quickbase scripting is throwing me for a loop.  Is sessionStoring of parameters a smart way to pass this data?
So to be honest I'm not really that well versed in using sessionStoring, but when I code dbpages such as this - I employ URL Parameters - and you can do window.location.search to work with your params

So for example you would have for a dbpage link such as: 

https://yourrealm.quickbase.com/db/maindbid?a=dbpage&pageid=208&rid=12345&param2=123&param3=456

Then a window.location.search.split("&") will get you an array of everything after the ? - and you can toss as many params into your URL as you'd like. You can index them how you want in order to use them in your code.

Chayce Duncan | Technical Lead
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
Photo of AustinK

AustinK

  • 1,084 Points 1k badge 2x thumb
I am currently researching a similar thing and I think this could be of help to you Doug. The first and third reply should have something to at least get you going.

https://community.quickbase.com/quickbase/topics/access-record-data-from-an-html-page-via-api-call
Photo of Doug Hines

Doug Hines

  • 142 Points 100 badge 2x thumb
Yes, the &praram method looks familiar.. I like familiar.  I'll mess around with this weekend and see if I can't make some headway.

Thank you.
Doug, if you wanted to work with me one on one to be able to enter a sequential range Start and end, we could get that working with natively (no code, just URL formula buttons) in about an hour on a GTM session.

QuickBaseCoach.com