Visual Builder

Get Involved. Join the Conversation.

Topic

    Rajeev Singh
    ADP row count check
    Topic posted September 5, 2019 by Rajeev SinghRed Ribbon: 250+ Points 
    118 Views, 18 Comments
    Title:
    ADP row count check
    Summary:
    ADP row count check
    Content:

    Hi,

    I am calling a service and populating my ADP with response data using assign variable. How do i check if the ADP is empty or contains rows of data?

    Version:
    19.1.3

    Comment

     

    • Shay Shmeltzer

      In your action chain you'll have an assign variable action.

      Look at your browser's console to locate that action and it will show you the value in your ADP after the assignment - 

      https://blogs.oracle.com/vbcs/debugging-and-troubleshooting-visual-builder-logic

    • Rajeev Singh

      Hi Shay,

      Thanks for the response. But i want to check if my ADP has any row or not using if condition in the action chain. Based on that i want to show message on the UI.

    • Rajeev Singh

      Hi,

      I tried {{ $page.variables.MyADP.data[] > 0 }} in if condition . But Its returning false even though my ADP has 3 records .

    • Shay Shmeltzer

      Does it work if you add .length -  $page.variables.MyADP.data[].length > 0

      • Rajeev Singh

        No Shay :(

        • Shay Shmeltzer

          This works for me - [[ $flow.variables.FEmpADP.data.length > 0 ]]

          • Rajeev Singh

            Hi Shay,

            if i try[[ $flow.variables.MyADP.data.length > 0 ]] , if condition does not get evaluated at all. It's giving neither true nor false

            if i try {{ $page.variables.MyADP.data.length > 0 }}, condition always gets evaluated to true, even if ADP does not have any record.

            • Shay Shmeltzer

              If you use a notification action and output the value of $page.variables.MyADP.data.length in it - what value do you see it having when the ADP is empty?

              • Rajeev Singh

                Hi Shay,

                 It's working perfectly fine in notification as well as in if condition {{ $page.variables.MyADP.data.length > 0 }}. I do not know what mistake i was making earlier that if condition was not getting evaluated properly.

                Thank you so much for your replies.

                 

    • James Pitman

      Shay - does this technique still work after the latest VBCS upgrade?  It seems we get an error where the ADP Id Attribute is being evaluated before the length function occurs.  

      when we simply do a notification action for something like below

      $page.variables.txnRevOTTMainADP.data.length

      We get an error like this, where RevnId is the Id attribute.

      VB (ERROR), /vb/action/action]: Action fireNotification1_e468xzvh6 failed. TypeError: Cannot read property 'RevnId' of null
          at SinglePropertyIdAttributeHelper.getKey (dataProviderUtils.js:116)
          at dataProviderUtils.js:120
          at Array.map (<anonymous>)
          at SinglePropertyIdAttributeHelper.getKeys (dataProviderUtils.js:120)
          at Function.buildDeltaItemKeys (jsonDiffer.js:113)
          at jsonDiffer.js:56
          at Array.forEach (<anonymous>)
          at JsonDiffer.processDeltas (jsonDiffer.js:48)
          at ArrayDataProvider.get [as data] (arrayDataProvider.js:568)
          at eval (eval at createFromString (expression.js:78), <anonymous>:3:416)

       

    • James Pitman

      Hmm? It is broke across our entire app using.  I guess we have to create a SR.

       

      Version: 19.3.1.2
      Build Number: 4a46b296b98aaaa61a5b69c28599b4cd3f0936ad (2019-09-24 05:04:52)
      Runtime Version: 19.3.1.12
      JET runtime version: v7.1.0
      • Shay Shmeltzer

        Just to verify the steps you take are:

        1. Execute REST call

        2. Take the REST results and assign them to the data[] part of your ADP

        3. Reference your ADP.data.length

        Or are you doing another step somewhere?

        • Guy Lior

          This is not working for me also in version 19.3.1.2.

          Any solution ?

          • Shay Shmeltzer

            Since this seems to work for me and I can't reproduce the issue on my side, we'll need to get your reproducible test case to see what is wrong. Either attach it here or better even open a service request with Oracle Support and provide it there.

            • Guy Lior

              Ok, the issue is checking if ADP has data in bind-if component (not in action chain)

              • Shay Shmeltzer

                This works for me in 19.3.1:


                    <oj-bind-if test="[[ $variables.empADP.data.length ]]">
                      <oj-table scroll-policy="loadMoreOnScroll" id="oj-table--1782984506-1" data="[[ $variables.empADP ]]" columns='[{"headerText":"id","field":"id"},{"headerText":"name","field":"name"},{"headerText":"email","field":"email"},{"headerText":"salary","field":"salary"}]'></oj-table>
                    </oj-bind-if>