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.
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.
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.)
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.
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”.
I changed the title to “SO1 only”.Activate the OWL and let’s see the result:
*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.
That will do nothing to the OWL. We need to add it to DefaultSet mapping.
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.
Result :
Thanks for reading.
Fred.
Updated : Related Document
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
🙂 Thanks, Chandan.
Hi, Chandan .
Here is kind of Part 2 to this document .
How custom queries work on OWL
Regards,
Fred
Hi Fred,
Thanks for sharing. This really nice post.
Regards
Nitin
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
Hi Sandeep,
Sorry, I dont know how to handle that.
Regards
Fred
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
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
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
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:
Linh
Hi Linh,
Try to bind the BO Action with RootLevel->ToParent->ToParent->Delete
Hope this helps.
Fred
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
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
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
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
Hi Linh,
The last workaround with BOOPeration READ can delete a Root level record.
Best Regards
Fred