Error in script - Forum - Rollbase - Progress Community

Error in script

 Forum

Error in script

This question is answered

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

Verified Answer
  • 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

All Replies
  • 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:

  • 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.