Visual Builder

Get Involved. Join the Conversation.

Topic

    Stephen Bryant
    Is it possible to delete all records in a BO using a REST...Answered
    Topic posted July 13, 2019 by Stephen BryantBronze Trophy: 5,000+ Points, tagged Action Flows, Business Objects, REST, SaaS Integration 
    77 Views, 7 Comments
    Title:
    Is it possible to delete all records in a BO using a REST CALL?
    Summary:
    Similar to truncating a table in plsql
    Content:

    Hello,

    We have a requirement to truncate/delete all records in a Business Object and then re-poplulate with new records.

    Can we truncate (delete all records) a business object via one rest call?

    Thanks,

    Steve

    Version:
    19.1.3

    Best Comment

    Shay Shmeltzer

    Just noticed that you are invoking the delete in the wrong way.

    Should be something like:

    while (vo.hasNext()) {
    def r = vo.next();
      r.remove();
    };

    Comment

     

    • Shay Shmeltzer

      You can create a BO function that loops over the records and delete them. Right now there isn't a delete all operation.

      https://blogs.oracle.com/vbcs/service-methods-for-business-objects-in-visual-builder

      • Stephen Bryant

        Shay,

        I've created the delete all function with no parameters.  The function is based on the dummy object.

        I’m running it using a button tied to the event that calls the function  

         

        However, I continue to get an unsupported media type 415.  There is no body to pass.  Is that the issue or do I need to do something there.

        Here is my function:

        def vo = newView('glBalances')
        vo.executeQuery()
        while (vo.hasNext()) {
        def r = vo.next();
                vo.deleteRow(r);
        }
         
        Thanks,
        Steve
        • Shay Shmeltzer

          Did you pass in the needed content-type - application/vnd.oracle.adf.resourceitem+json

          https://docs.oracle.com/en/cloud/paas/app-builder-cloud/consume-rest/crud-tasks.html#GUID-E0BAE8DC-CA5A-46D3-90F4-EA79B816BAD0

           

          • Stephen Bryant

            Shay,

            Attached are screenshots of my set up and you will see I did pass the content type.

            Does my function look ok?  Do I need a for-loop?  

            Thanks,

            Steve

          • Stephen Bryant

            Shay,

            Here is my code again,

            def vo = newView('glBalances');
            vo.executeQuery();
             
            println("ran");
             
            while (vo.hasNext()) {
            def r = vo.next();
              vo.deleteRow(r);
              
            };
             
            right now, it is producing this error:
             
             
            JBO-25184: Exception in expression "dummyFundsCheck" object function deleteGlBalancesRecords() : groovy.lang.MissingMethodException : No signature of method: glBalances_1.deleteRow() is applicable for argument types: (oracle.jbo.server.ViewRowImpl) values: [<oracle.jbo.server.ViewRowImpl@3>]
             
             
            Thanks,
            Steve