How to load custom modules or code pages

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
  • (Edited)
I am trying to step up my coding knowledge and experience within Quick Base. I know there are ways to create code pages and pull in custom scripts. My struggle is basically this, I am not a code writer. I have implemented a couple of items but want to take it to the next level. I understand the code pages, but am not quote sure how to make the call to the module and what fields (text formula fields) to add to the form to make that call.

Some detail would be greatly appreciated....once someone shows me how to turn on the light switch I will get it!
Photo of Joey Zint

Joey Zint

  • 1,508 Points 1k badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
i think you can use the famous IOL Technique

Just create  a formula text field and make  the "Allow html tags" as checked

Paste the below code on the formula 
"<img qbu=\"module\" src=\"/i/clear2x2.gif\" " &
"onload=\"javascript:if(typeof QBU=='undefined'){QBU={};$.getScript('" &
URLRoot() &"db/" &Dbid() &"?a=dbpage&pagename=module.js&rand='+Math.random())}\">"

Create a page in Home-Settings-Pages-New Page and have the below code 

$(document).ready(function(){
alert("Page is Loaded !!")
})

Save the page as module.js

Write whatever code you wish to have in the module.js. 

You can rename the page , but the same page name should be called on the formula too.

I hope this will solve your issue!!
Photo of Michael Barrow

Michael Barrow

  • 2,206 Points 2k badge 2x thumb
Is this custom code limited to being used only on a form where that formula text field is loaded? What if I wanted to use some additional, external functions in formula field formulas? Is this possible? How does the IOL technique with the formula text field work for that situation?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,262 Points 20k badge 2x thumb
There is no mechanism for JavaScript to exchange values with the formula language. However, you can use JavaScript to place content in the same position a field would occupy giving the appearance that a server side formula calculate the value. Does that answer you question?
Photo of Michael Barrow

Michael Barrow

  • 2,206 Points 2k badge 2x thumb
So is this IOL mechanism limited to fields displayed on forms, or can I include it in a formula field or have it work for me in a grid edit situation?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,262 Points 20k badge 2x thumb
IOL will work on {new, edit, view, report and grid edit} pages. Basically it works on any page where you can place a raw field - you can't use IOL on chart pages because you can't put a raw field on those types of pages.

If you need script injected on other pages you can use BOL (Branding OnLoad) or SW (Service Workers).
(Edited)
Photo of Michael Barrow

Michael Barrow

  • 2,206 Points 2k badge 2x thumb
Thanks for the clarification!