Skip to Content
Author's profile photo Fred K

How Queries and DefaultSets work on OWL

Hi,

     May be this is already well-known by everyone (if so, sorry about that) but this doc is just about my experience to queries and defaultsets.

     If there is any mistake, please correct me. If there is some frustration , my bad.

     It is necessary , IMO, to know how actually queries and defaultsets work on OWL to be able to do more things with OWLs.

This is Custom BO definition that is used in the doc.

businessobject SalesOrder {

      element SalesOrderID:LANGUAGEINDEPENDENT_MEDIUM_Text;

   node Item[1,n]{

  element ItemID:LANGUAGEINDEPENDENT_MEDIUM_Text;

  element ItemName:LANGUAGEINDEPENDENT_MEDIUM_Text;

   }

}

       When we open this OWL, all Sales Orders are shown in the table. Because “All SalesOrdres” is selected in Show.

          SalesOrder1.png

             That is automatically configured by the studio as default after we have created an OWL. Let’s see how it does.

             In the “Default DefaultSet” property of AdvancedListPane:ObjectWorkList, you will see DefaultSet.

              SalesOrdre2.png

                 In the controller tap, you can see that default set under Query with the title All SalesOrders. We can edit the title.

                 There OnSelect event, EventHandler is selected. That event handler executes the query.( we don’t need to care about this

                 because this handler is automatically created when we create a defalut set.)

             SalesOrder3.png

              Here, we can restrict that DefaultSet. Let’s say, we only want to see the record of SalesOrderID “SO1”.

              We can create a parameter for that. First, we need to add SalesOrderID from QueryByElements to Selected Query Parameters

              by clicking the down arrow. Add a new field to Root/SearchParameters. Bind SalesOrderID with that new field.

               SalesOrder4.png

              Now we can do some restriction to our OWL with SalesOrderID. There will be SalesOrderID in Query Parameters of DefaultSet.

              We can add a new operation and create conditions here. In this case, I selected operation to “equals” and set Low Value to “SO1”.

          SalesOrder5.png

              I changed the title to “SO1 only”.Activate the OWL and let’s see the result:

              SalesOrder6.png

             *We can create more default sets under that Query and create more restriction.

              I created a new DefaultSet under Query namely “AllSalesOrder” and I changed the title to “All Sales Orders”.

              The event handler “EventHandler1” is automatically created. I did not create any restriction because I want to

              all sales orders this time.

              SalesOrder7.png

           

               That will do nothing to the OWL. We need to add it to DefaultSet mapping.

               SalesOrder8.png

      

              SalesOrder9.png

               Now our OWL will have two selections in Show.

               But the Default DefaultSet is DefalutSet of “SO1” . The “SO1 only” will be selected in Show.

               I am going to change that because I want to show all sales orders as default. That’s easy. Just change Default DefaultSet to new default set “AllSalesOrder” that we created a bit earlier.

              SalesOrder10.png

               Result :

               SalesOrder11.png

           

Thanks for reading.

Fred.

Updated : Related Document

How custom queries work on OWL

Assigned Tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Chandan Bankar
      Chandan Bankar

      Hello Fred,

      Thanks for sharing this. I believe it is really a good habit to share the knowledge .. no matter if it is known to many but might not be known to lots of others ... (in this case as me 🙂 )

      Thanks once again. Keep sharing the knowledge.

      Cheers,

      Chandan

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      🙂 Thanks, Chandan.

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      Hi, Chandan .

           Here is kind of Part 2 to this document .

          How custom queries work on OWL

      Regards,

      Fred

      Author's profile photo Former Member
      Former Member

      Hi Fred,

      Thanks for sharing. This really nice post.

      Regards

      Nitin

      Author's profile photo Former Member
      Former Member

      Hi Fred,

      How do we enable / disable these filters based on the business role or position of the employee? For e.g. Sales Manager should see My Accounts and My Team's Accounts where Sales Representative should only see My Accounts.

      Thanks and Regards,

      Sandeep

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      Hi Sandeep,

      Sorry, I dont know how to handle that.

      Regards

      Fred

      Author's profile photo Horst Schaude
      Horst Schaude

      Hello Fred, Sandeep,

      On the Control tab select the resp. DefaultSet. Then there's a property "VisibleField" which can be set to "Advanced".

      Then you can work with binding or a calculation rule.

      If the result is "false" the DefaultSet is hidden.

      Maybe this helps,

          Horst

      Author's profile photo Former Member
      Former Member

      Untitled picture.pngHi Fred,

      as mentioned in the PM.

      How to implement delete functionality based on this binding?

      The goal is to have both search and delete function in OWL.

      Many thanks

      Best

      Linh

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      Hi Linh,

      1. Add a BO action with this.Delete()

      2. Add bind the button with the BO Action under your custom Query (Assign Instance binding to Datalist)

      Cheers,

      Fred

      Author's profile photo Former Member
      Former Member

      Dear Fred,

      I tested your approach however when I click on the button, it runs infinitely ( I guess there must be an infinite loop the way I bind the BO).

      How should I do it correctly?

      I created a BO action with this.Deleted() as you suggested and bind the button as following:

      Capture2.PNGCheers

      Linh

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      Hi Linh,

      Try to bind the BO Action with RootLevel->ToParent->ToParent->Delete

      Hope this helps.

      Fred

      Author's profile photo Former Member
      Former Member

      Dear Fred,

      unfortunately it doesnt work either.

      What I can think of is to parse the datalist value to the action parameter (e.g. the NodeID) and then trigger the BOAction delete).

      Do you know how to define an action parameter ?

      Best

      Linh

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      Dear Linh,

      It works fine with me. 🙂

      Sorry, you can not define an action parameter for a custom action.

      You created you custom query on Root level right?

      Does your query work correctly?

      Here are some tips.

      1.Test the custom query (Execute Query) in the studio before using on UI.

      2. In the data model, bind Root with your custom BO

      4. Bind the datalist with the query.

      Good luck.

      Fred

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      Dear Linh,

      Here is another workaround.

      1. Create BOAction with this.Delete.

      2. In data model, bind a field under DataList with NodeID from custom query

      3. Create event hanlder

      4. Add BOOperation READ , use NodeID from datamodel

      5. Add BOAction to the same event handler and bind with the Delete action

      (instance binding is Root) And Dont forget to check Save After Execution.

      Good luck,

      Fred

      Author's profile photo Former Member
      Former Member

      Hi Fred,

      unfortunately, it doesnt work either 🙁 . Were you able to delete a salesorder ( as in your example) or just the sub-node (item) ?

      Thank you

      Best regards

      Linh

      Author's profile photo Fred K
      Fred K
      Blog Post Author

      Hi Linh,

      The last workaround with BOOPeration READ can delete a Root level record.

      Best Regards

      Fred