Forum Discussion
- MCFNeilQrew CaptainYes, that is a situation where you need to account for that when you are writing the script, and more importantly the placement of the field that causes the execution of the code.
- SaudaFurkhanaQrew Cadet
- SaudaFurkhanaQrew CadetSo, how should this be rectified? I just need the output highlighted in blue in each row (screenshot attached above)
- SaudaFurkhanaQrew CadetHi Gaurav! the exampleurl in Dan's Pasties app does have the image onload field on the table home page and it seems to be working fine! so there definitely is a way to eliminate the redundant/incorrect data, and I think probably the piece of code that is joining all the record ids in the query needs to be fixed somehow so that it queries one record at a time rather than joining all of them with a "OR".
- _anomDiebolt_Qrew Elite>Using image onload field in a report leads to the repeated execution of the javascript and thereby leads to incorrect output
The formula for the image onload field is specifically designed to prevent multiple loads of the script file by testing the existence of the global QBU variable. This feature has always been included in the image onload field definition so I suspect you have implemented the IOL incorrectly. To debug post your formula and the shortest code the produces the same behavior. - SaudaFurkhanaQrew CadetHi Dan! Thank you for the response. Here are the details.
1) My App variables and Formula Field in parent table:
a) iol => <img qbu='module' src='/i/clear2x2.gif' onload="javascript:if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=
b) /iol => &rand='+new Date().getTime())};">
c) Childs2:
[iol] & "module.js" & [/iol]
&
"<div class=QBU_Childs data-rid=" & & "></div>"
2) HTML source of the tag that is getting rendered in the parent report
<tr>
<td class='FirstColumn'><img qbu='module' src='/i/clear2x2.gif' onload="javascript:if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=module.js&rand='+new Date().getTime())};"><div class=QBU_Childs data-rid=444></div></td>
<td align=right class='NoWrap'>444</td>
</tr>
<tr>
<td class='FirstColumn'><img qbu='module' src='/i/clear2x2.gif' onload="javascript:if(typeof QBU=='undefined'){QBU={};$.getScript(gReqAppDBID+'?a=dbpage&pagename=module.js&rand='+new Date().getTime())};"><div class=QBU_Childs data-rid=445></div></td>
<td align=right class='NoWrap'>445</td>
</tr>
3) Data in my parent/child tables:
Parent Record #444 has 3 children - child1 value: ghi, child2 value: def, child3 value: abc)
Parent Record #445 has 3 children - child1 value: 123, child2 value: 456, child3 value: 789)
Expected data output is to have parent record and reports in the parent table to display:
444 - ghi, def, abc
445 - 123, 456, 789
4) module.js is same as in https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=464&_ga=2.235786049.17404487.... Here are the details of the code changes that I tried:
a) I changed dbid, dbidParents,dbidChilds, apptoken, relatedParentFid, relatedParentLabel, clist
- clist is fetching two fields: 1) child unique record id # and 2) data-value that I want to concatenate and display in parent table
b) I modified the following two lines in js file. Please see the screenshot for the output related to Code2 and Code3
>> Code1: as it is in Pasties example
var markup = Mustache.render(template, item);
$("div." + qbuClass + "[data-rid=" + rid + "]").html(markup);
Output: no result within in the parent record and parent table report
>> Code2: using console.log, I saw that rid contained the child record value that I need to display in parent record
var markup = Mustache.render(template, {comment: rid});
$("div." + qbuClass).html(markup);
Output:
- always lists the last child value in the individual parent record
- parent table report has the last value in the loop for both the records (I think this is because I eliminated unique identifier for the div?)
>> Code3: I changed .html to .append in code2
var markup = Mustache.render(template, {comment: rid});
$("div." + qbuClass).append(markup);
Output:
- lists the concatenated child values within an individual record
- but I think due to .append(), all the records in the report have the concatenated list of child values for "all" records (I think this is because I eliminated unique identifier for the div?)
5) Dan, should we change something in this function as well?
function ridsToQuery(rids, fid) {
fid = fid || "3";
return "{" + fid + ".EX." + rids.join("}OR{" + fid + ".EX.") + "}";
} - SaudaFurkhanaQrew CadetHi Dan! Is the above information sufficient for you to debug the code?
- SaudaFurkhanaQrew CadetHi Dan,
So, I was able to resolve the issue. The report and the individual records in the parent table display the concatenated text correctly.
I have few other issues/questions though:
1) On saving the report, instead of the concatenated text, the report displays the formula code. How can we get the report to save the "concatenated text"?
2) The iol code does not execute when dynamic filters are applied to the report.
Any guidance/input is highly appreciated! Awaiting your response.
Thanks,
Sauda - _anomDiebolt_Qrew Elite>Awaiting your response.
What a great pun - sir you are a master punmaster. I created a new demo using the new Async / Await feature in JavaScript that concatenates child cast members into the parent movie records.
Movies and Actors
https://haversineconsulting.quickbase.com/db/bm3wfa894?a=td
I will probably create a top level post of this under another title. See here:
Where Can I See More Async / Await?
https://community.quickbase.com/quickbase/topics/where-can-i-see-more-async-await - SaudaFurkhanaQrew CadetHi Dan,
Thank you for the direction.
1) I looked at the example and it seems that the await/async technique resolve the issues I mentioned.
- I looked at the new code and could not evaluate the piece of code that would query for the specific parent record or set of records in a report? (I was trying to locate something on the lines of ridstoquery() in the original code.)
- I tried to adapt the code and using the word "await" before Promise.resolve does not execute the JS code. Are there any prerequisites (browser related maybe?) to be able to use "await"? (I'm using Google Chrome)
2) I added a new Actor (to the Movie record Dr.No) in your example database and the concatenated text did not get updated.
- Did I add the Actor record incorrectly?
3) Would it be possible for you to add the brief comments to the different portions of the Pasties code to explain action/input/result for that specific section?
Thanks,
Sauda