In a page I've added a script component that shows a page section if count of a view is equals to zero.
<script>
function customizeEdit() {
var sectionID = rbf_getSectionIdByTitle("SectionName");
var myOrg = rbv_api.getCount("1122233456");
rbf_showOrHideSection(sectionID , myOrg===0);
}
</script>
The script is not working and in the console I get the following error:
[ERROR] Page onload event handler ReferenceError: rbv_api is not defined
Please use below script
<script>
function my_callback(myOrg)
{
console.log(myOrg);
var sectionID = rbf_getSectionIdByTitle("SectionName");
rbf_showOrHideSection(sectionID, myOrg===0)
}
(function () {
rbf_getCount("6096",my_callback); // 6096 is view original id
})();
</script>
Thanks
Srinivas
You are using the server-side api for getCount. That won't work running client-side in the browser.
Replace it by the client-side one:
<script> function customizeEdit() { var sectionID = rbf_getSectionIdByTitle("SectionName"); var myOrg = rbf_getCount("1122233456"); rbf_showOrHideSection(sectionID , myOrg===0); } </script>
But maybe this one is more applicable to the use-case:
You are using the server-side api for getCount. That won't work running client-side in the browser.
Replace it by the client-side one:
<script> function customizeEdit() { var sectionID = rbf_getSectionIdByTitle("SectionName"); var myOrg = rbf_getCount("1122233456"); rbf_showOrHideSection(sectionID , myOrg===0); } </script>
[View:https://documentation.progress.com/output/rb/doc/index.html#page/rb%2Frbf-getcount().html%23:550:50]
[View:https://documentation.progress.com/output/rb/doc/index.html#page/rb%2Frbf-getcount2().html%23:550:50]
But maybe this one is more applicable to the use-case:
[View:https://documentation.progress.com/output/rb/doc/index.html#page/rb%2Frbf-getviewcount.html%23:550:50]
Please use below script
<script>
function my_callback(myOrg)
{
console.log(myOrg);
var sectionID = rbf_getSectionIdByTitle("SectionName");
rbf_showOrHideSection(sectionID, myOrg===0)
}
(function () {
rbf_getCount("6096",my_callback); // 6096 is view original id
})();
</script>
Thanks
Srinivas
That worked perfectly.
Thank you very much Srinivas.