help needed with API_DoQuery and API_AddRecord

  • 1
  • 1
  • Question
  • Updated 3 years ago
  • Answered
I am very new to javascript and XML, so please help me in what i have to do. I have 3 tables, products, master tasks and tasks. I want t create a button on the products form which should select a set of tasks from the master table and add it to the tasks table along with the product table reference.
I want to add multiple fields per record. So i thought of using DoQuery to retrieve the records from the master table and use AddRecord to add them to the task table.
But the problem here is how do i start, where am i suppose to write the requests, how do i add multiple records?
Can someone give me a sample code of how XML and javascript are used to create an XML request?
Thanks in Advance.

Photo of Azh7

Azh7

  • 30 Points

Posted 7 years ago

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

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,204 Points 20k badge 2x thumb
See this blog post:

Pimp My QuickBase
http://quickbase.posterous.com/pimp-my-quickbase
Photo of Azh7

Azh7

  • 30 Points
The URL that i am using is giving me an error...Here the URL

javascript:$.getScript('https://www.quickbase.com/db/db?a=dbpage&pagename=retreive.js');void(0);
Photo of Azh7

Azh7

  • 30 Points
I got the URL working....
Photo of Azh7

Azh7

  • 30 Points
When i click on the button the records are not getting generated. PLease help...

Here is the URL that i am using :
"javascript:void($.getScript('https://www.quickbase.com/db/blahblah?a=dbpage&pagename=retreive.js'));"

And here is the code, i have modified the one you provided, though not much, here it goes :-
<script src="https://www.quickbase.com/js/QuickBaseClient.js&quot; type="text/javascript">
</script>

<script language="JavaScript" type="text/javascript">
var data1 = {PRid: PRid};

var url1 = "";
url1 += "https://www.quickbase.com/db/blahblah&quot;;
url1 += "?act=API_GenResultsTable";
url1 += "&query={'25'.CT.'106'}AND{'25'.CT.'107'}AND{'25'.CT.'108'}AND{'25'.CT.'109'}AND{'25'.CT.'110'}AND{'25'.CT.'111'}AND{'25'.CT.'112'}AND{'25'.CT.'113'}AND{'25'.CT.'114'}AND{'25'.CT.'115'}AND{'25'.CT.'116'}";
url1 += "&clist=8";
url1 += "&options=csv";


$.get(url1, function(template1){
  var csv2 = Mustache.render(template1, data1);
  var url2 = "";
  url2 += "https://www.quickbase.com/db/blahblah&quot;;
  url2 += "?act=API_ImportFromCSV";
  $.post(url2, {clist: "31", records_csv: csv2, skipfirst: "1"}, function(xml2){
    document.location.reload();
  });
});

</script>
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,204 Points 20k badge 2x thumb
kRid is a global variable within the host QuickBase page that identifies the [Record ID#] of the record being edited or viewed. Unless you created a JavaScript variable namned PRid it does not exist. Debug your code using console.log statements.
Photo of KenFirch

KenFirch

  • 10 Points
Wish I could post a Word doc here. Often newbies, or those who use only pure Quickbase, see posts on scripts, API's, etc, but don't know how to put all the pieces of the puzzle together to make it actually work. I put together detailed how-to instructions that assume someone knows nothing about scripts or API's, and show how to do it. I am by no means an expert, and It may not be as creative as Dan's suggestions, but it is profusely commented and has enough to get someone going. This little white box is not conducive for posting such material, so I'll hunt around for some public storage website to store it on, and hopefully provide a link later..... Ken.
Photo of Azh7

Azh7

  • 30 Points
Yes, that would help a lot.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,204 Points 20k badge 2x thumb
>This little white box is not conducive for posting such material, so I'll hunt around for some public storage website to store it on, and hopefully provide a link later..... Ken.

You could always place it in a QuickBase as a file attachment field.

HEY QUICKBASE:
In fact I would like to ask QuickBase to create a subdomain qbu.quickbase.com and grant access to some of the contributors here. I will volunteer to administer and curate it. It is becoming quite a pain to provide rich content, images, code fragments by linking to yet another external service.
Photo of Azh7

Azh7

  • 30 Points
Still no luck....  And i was again looking at the example you provided, the jobs,tasks and master tasks, and in master tasks the Related Job field has {{kRid}} , the field that i am referring to is blank, but it is linked to the job table.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,204 Points 20k badge 2x thumb
The kRid parameter is a QuickBase global variable that exists on view and edit record pages. My advice is to recreate my application by examining the source and after you understand how it works modify to fit your needs using console.log() statements.
Photo of Azh7

Azh7

  • 30 Points
It is giving an error on the URL formula that i am using, which is
"javascript:$.getScript('https://www.quickbase.com/db/blahblah?a=dbpage&pagename=AddTasks.js');void();&quot;

What might be the reason.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,204 Points 20k badge 2x thumb
We can't guess at what your are experiencing so you have to provide a description of the error or a screenshot. From what you are posting I don't think you are taking my advice on reconstructing my application by looking at the source and debugging your code changes with console.log(). What you need to do or learn is basic debugging skills. In a week, month or a year you will thank me for this blunt advice because it is the only way to learn how to write code (work from examples, make mistakes and debug etc).
Photo of KenFirch

KenFirch

  • 10 Points
Try:

"javascript:" &
"$.getScript('" & URLRoot() & "db/blahblah?act=dbpage&pagename=AddTasks.js');void(0);"
Photo of KenFirch

KenFirch

  • 10 Points
Photo of Azh7

Azh7

  • 30 Points
@Dandiebolt:- Thanks, i am working on it.
@6s524 :- I will try that.
Photo of Azh7

Azh7

  • 30 Points
Thanks a LOT Ken....This is really helpful.....
Photo of Jacob

Jacob

  • 0 Points
This is exactly what QB needed - a starting place for newbies to the API.  With all of QB's documentation, I'm surprised they don't provide this.  Thank you so much, this is great.
Photo of ECastellaw

ECastellaw

  • 20 Points
Ken - this is great!  I'm the person you described above: have created several applications (even go into formulas and exact forms), but have NO CLUE about APIs.  Thank you for taking the time to create such a detailed document!!!
Photo of Pierre_Christo

Pierre_Christo

  • 0 Points
Thanks Ken
I have been looking for this for months
Quickbase should include this information (or equivalent) in its own help database
Photo of KenFirch

KenFirch

  • 10 Points
FYI...Also put it here:

http://home.surewest.net/firch     

Dropbox seemed too invasive on my PC.
I'm also finishing up a new "API Workbench" tool.  It allows you to test all API's against any of your apps, all within the comfort of Excel.

Ken
Photo of ECastellaw

ECastellaw

  • 20 Points
Ken - I look forward to using the new workbench!  Please let me know if you need volunteers to conduct a UAT or QA test. My email address is liz.castellaw@orgwide.com.
Photo of Saketh Kumar

Saketh Kumar

  • 10 Points
Can you re-post the above link?
Photo of KenFirch

KenFirch

  • 10 Points
Here's some revised Google Drive links:

QB Scripting Doc:
https://drive.google.com/file/d/0B0msP83QbaCdQTNVVEJGMlMtRlk/edit?usp=sharing
My coding techniques have evolved, so it's not exactly how I would do it today.  But it still works, or will help get you started.

Excel Download Tool:
https://drive.google.com/file/d/0B0msP83QbaCdSW4wdFNJY3I1bDA/edit?usp=sharing

Excel API Tool:
https://drive.google.com/file/d/0B0msP83QbaCdby00OUVUU3J3aGs/edit?usp=sharing
Hi Ken,

I also want to access this dropbox link:

https://www.dropbox.com/s/vwhsxwuq1ebvdg3/QB%20Scripting.docx

But I am unable to access it, can you provide a new link of this document.

and  I have same question,

can you help me out ?

https://quickbase-community.intuit.com/questions/1382704-can-we-add-multiple-child-records-to-a-parent-record-at-the-click-of-a-single-button


Thanks,
Gaurav
Photo of KenFirch

KenFirch

  • 10 Points

This conversation is no longer open for comments or replies.