<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_create_a_QueryList_Widget</id>
	<title>How to create a QueryList Widget - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=How_to_create_a_QueryList_Widget"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_QueryList_Widget&amp;action=history"/>
	<updated>2026-04-06T16:39:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_QueryList_Widget&amp;diff=2776&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;== Introduction ==  This HowTo describes how to create a new widget that implements the Query/List Widget superclass. The generic documentation about what are widgets can be f...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=How_to_create_a_QueryList_Widget&amp;diff=2776&amp;oldid=prev"/>
		<updated>2021-12-16T03:23:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Introduction ==  This HowTo describes how to create a new widget that implements the Query/List Widget superclass. The generic documentation about what are widgets can be f...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This HowTo describes how to create a new widget that implements the Query/List Widget superclass. The generic documentation about what are widgets can be found [[Widgets|here]].&lt;br /&gt;
&lt;br /&gt;
A related Howto explaining how to embed a widget into a generated Window/Tab can be found in [[How_to_embed_a_Widget_into_a_Window_Tab|this]] other document.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developing the widget ==&lt;br /&gt;
&lt;br /&gt;
The new widget like all developments must belong to a module. [[How_To_Create_and_Package_a_Module#Creating_a_Module|Create a new one]] if you still don't have it.&lt;br /&gt;
&lt;br /&gt;
==== Create the widget ====&lt;br /&gt;
&lt;br /&gt;
All the widget definition is done in the ''Widget'' window.&lt;br /&gt;
&lt;br /&gt;
Create a new ''widget class'':&lt;br /&gt;
&lt;br /&gt;
;Widget title: is the title that appear on the widget header. Put here a short sentence that describes the widget.&lt;br /&gt;
;Superclass &amp;amp; Widget superclass: leave the flag unchecked and select the ''Query/List'' superclass widget from the drop/down menu.&lt;br /&gt;
;Height: set up any value, the Query/List override this value setting up the height based on the number of rows.&lt;br /&gt;
;Enable for all users: Check it if the widget has to be available to all roles. Otherwise leave unchecked and give access to the desired roles on the ''Widget Access'' tab.&lt;br /&gt;
&lt;br /&gt;
As the widget is implementing a superclass widget some parameters might have been created to the new widget. On the ''Query/List'' case the ''Number of Rows'' parameter is created automatically. This sets the number of rows visible on the grid.&lt;br /&gt;
&lt;br /&gt;
[[Image:how-to-querylist-widget-3.png|thumbnail|600px|center|Pending goods receipt widget class definition.]]&lt;br /&gt;
&lt;br /&gt;
==== Create the query ====&lt;br /&gt;
&lt;br /&gt;
The HQL query is defined on the ''Query'' tab. At this moment it is not possible to validate the ''HQL'' from the application so it is recommended to design it on an external tool. Eclipse has a nice [http://alostale.wordpress.com/2010/03/01/openbravo-erp-hql-prototyping-hibernate-tools/ plugin for it]. All columns on the select clause must have a unique alias. These aliases are used later to define the grid columns.&lt;br /&gt;
&lt;br /&gt;
[[Image:how-to-querylist-query-3.png|thumbnail|600px|center|Pending goods receipt HQL query definition.]]&lt;br /&gt;
&lt;br /&gt;
As the screenshot doesn't show the full text of the ''HQL'' used in our HowTo the following shows it in more detail. In query there are a few special things to notice:&lt;br /&gt;
&lt;br /&gt;
* Use of named aliases like '''orderId''' and '''organizationName'''. Those relate to the columns of the HQL-result to the grid-columns visible for the user which are explained further down in the ''Column'' section.&lt;br /&gt;
* Expressions like ''':productname''' -&amp;gt; ''HQL'' named parameters which relate to defined ''Parameters'' of the widget explained in the following.&lt;br /&gt;
* '''@optional_filters@''' keyword, which defines the position where the Widget will automatically add extra filters like the standard client &amp;amp; organization filters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;SQL&amp;quot;&amp;gt;&lt;br /&gt;
select ol.salesOrder.id as orderId, ol.salesOrder.organization.name as organizationName,&lt;br /&gt;
       ol.salesOrder.orderDate as dateordered,  ol.salesOrder.scheduledDeliveryDate as plannedDeliveryDate,&lt;br /&gt;
       ol.salesOrder.documentNo as salesorder, ol.salesOrder.businessPartner.name as bpartner,&lt;br /&gt;
       ol.product.name as productname, ol.attributeSetValue.description as attribute,&lt;br /&gt;
       ol.uOM.name as uom, ol.orderedQuantity as totalqty,    &lt;br /&gt;
       (select coalesce(sum(po.quantity),0) &lt;br /&gt;
        from ProcurementPOInvoiceMatch po &lt;br /&gt;
        where po.goodsShipmentLine is not null and po.salesOrderLine = ol) as qtyReceived,&lt;br /&gt;
       (select ol.orderedQuantity-coalesce(sum(po2.quantity),0) &lt;br /&gt;
        from ProcurementPOInvoiceMatch po2 &lt;br /&gt;
        where po2.goodsShipmentLine is not null and po2.salesOrderLine = ol) as qtyPending&lt;br /&gt;
from   OrderLine as ol &lt;br /&gt;
       left join ol.attributeSetValue &lt;br /&gt;
where  ol.salesOrder.client.id =:client and &lt;br /&gt;
       ol.salesOrder.organization.id in (:organizationList) and &lt;br /&gt;
       ol.salesOrder.documentStatus='CO' and &lt;br /&gt;
       ol.salesOrder.salesTransaction=false and&lt;br /&gt;
       ol.orderedQuantity &amp;lt;&amp;gt; (select coalesce(sum(po3.quantity),0) &lt;br /&gt;
                              from ProcurementPOInvoiceMatch po3 &lt;br /&gt;
                              where po3.goodsShipmentLine is not null&lt;br /&gt;
                              and po3.salesOrderLine = ol) and &lt;br /&gt;
       ol.salesOrder.scheduledDeliveryDate&amp;lt;=now() and &lt;br /&gt;
       ol.product.name like :productname and &lt;br /&gt;
       ol.salesOrder.businessPartner.name like :suppliername and &lt;br /&gt;
       ol.salesOrder.documentNo like :documentno and &lt;br /&gt;
       ol.salesOrder.organization.name like :organizationName and &lt;br /&gt;
       @optional_filters@&lt;br /&gt;
order by ol.salesOrder.scheduledDeliveryDate, ol.salesOrder.documentNo&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is possible to use ''named parameters'' on the query. Each ''named parameter'' must have a matching ''Parameter'' defined on the ''Parameter'' tab:&lt;br /&gt;
&lt;br /&gt;
;DB Column name:it must match the name used on the named parameter.&lt;br /&gt;
;Fixed &amp;amp; Fixed Value &amp;amp; Evaluate Fixed Value:when the flag is checked it is mandatory to enter the fixed value. If the ''Evaluate Fixed Value'' is checked the value has to be a javascript expression that it is validated on real time. It is recommended to add a filter by client id on all your queries using a named parameter and a fixed value with the following javascript expression: ''OB.getContext().getCurrentClient().id''. If the parameter is not fixed it will be prompted to the user on the ''Edit settings'' window.&lt;br /&gt;
;Name: is the label of the field of the parameter on the ''Edit Settings'' window.&lt;br /&gt;
&lt;br /&gt;
[[Image:how-to-querylist-parameters-3.png|thumbnail|600px|center|Pending goods receipt parameters list.]]&lt;br /&gt;
[[Image:how-to-querylist-param-3.png|thumbnail|600px|center|Pending goods receipt client parameter definition.]]&lt;br /&gt;
&lt;br /&gt;
==== Create the columns ====&lt;br /&gt;
&lt;br /&gt;
Once the query is defined and the necessary parameters created is time to define the columns that will be available on the grid on the ''Column'' tab:&lt;br /&gt;
&lt;br /&gt;
;Name:is the label of the column.&lt;br /&gt;
;Display expression:it has to match an alias of the query, it is the column of the query that will be displayed on the grid.&lt;br /&gt;
;Reference:it sets the type of cell on the grid.&lt;br /&gt;
;Include in:sets where is included the column.''Widget view'': included in all cases, ''Maximized view'': not shown on the widget view and ''Exported File'' only included on the exported file.&lt;br /&gt;
;Sequence number:sets the order of the columns.&lt;br /&gt;
;Width:sets the width of the column on the grid in percentage.&lt;br /&gt;
;Has link &amp;amp; Link Expression &amp;amp; Tab: it is possible to set up links on the cells to tabs of the application. The ''Link Expression'' has to be an alias of the query that returns a record id of the selected tab.&lt;br /&gt;
;Summarize Type:numeric columns can be summarized on the summary row. Available options are ''sum'', ''average'' and ''count''. It is not supported using summaries in columns that are defined using subqueries or using a summary function. For instance, if the ''qtyonhand'' column is defined in the query like this ''sum(ps.quantityOnHand) as qtyonhand'', it will not be supported using it with a not empty summarize type. If you set the summarize type of a column that is defined using an alias, you must also set the ''Where Clause Left Part'' field.&lt;br /&gt;
;Can be filtered &amp;amp; Where Clause Left Part:configures the ability to filter the grid by the column on the maximized view using the filter row of the grid. It is mandatory to define the left part of the where clause. This is usually the expression of the select clause identified by the alias set on the ''Display Expression'' field. It is also mandatory to define where in the HQL has to be included the where clause. There are 2 possibilities to achieve this: including the ''Display Expression'' value enclosed in &amp;quot;@&amp;quot; symbols in the where clause of the HQL or including the ''@optional_filters@'' string.&lt;br /&gt;
;Clientclass:(Since 3.0MP20. Issue [https://issues.openbravo.com/view.php?id=22902 22902]) In the same way that in the [[How_to_add_a_canvas_field_to_a_Form_or_Grid|from/grid view]], a custom canvas item can be added within the Quert List grid.&lt;br /&gt;
:Example 1: To add a % sign in an existing field:&lt;br /&gt;
::Set as &amp;quot;Clientclass&amp;quot; the following value &amp;quot;OBAddPercentageSign&amp;quot;&lt;br /&gt;
:Example 2: To add a 'Print' link button in a new column&lt;br /&gt;
::Create the new column&lt;br /&gt;
::Name: the column header title&lt;br /&gt;
::Display Column Alias: it doesn't mind the value, but ensure that is not used in any other column&lt;br /&gt;
::Reference: it doesn't mind the value, but 'String' works ok&lt;br /&gt;
::Width: the desired column width. &amp;quot;15&amp;quot; should be enough&lt;br /&gt;
::Has Link: checked&lt;br /&gt;
::Link Column Alias: point to the hql result matching the id of the record you want to print&lt;br /&gt;
::Tab: point to the tab which belongs the record you want to print&lt;br /&gt;
::Clientcanvas: set the following value &amp;quot;OBQLCanvasItem_Print&amp;quot;&lt;br /&gt;
:: &lt;br /&gt;
::Note that this 'Print' button works for PDF documents (like, for example, 'Sales Invoice' print behavior). For in-screen cards (like, for example, 'Business Partners' print behavior), the &amp;quot;Clientcanvas&amp;quot; value should be &amp;quot;OBQLCanvasItem_Print {&amp;quot;isDirectPDF&amp;quot;: false, &amp;quot;title&amp;quot;: &amp;quot;Print BP&amp;quot;}&amp;quot;&lt;br /&gt;
In the example of the image. The display expression alias is ''salesorder''. In the HQL this alias is defined like: ''ol.salesOrder.documentNo as salesorder''. So in the ''Where Clause Left Part'' is set ''ol.salesOrder.documentNo''. In the HQL as we want to be able to filter by all the columns and all the where clauses have to be set on the same where statement it is added ''AND @optional_filters@''. For this column we could have added as well the following code: ''AND @salesorder@''.&lt;br /&gt;
&lt;br /&gt;
[[Image:how-to-querylist-column-3.png|thumbnail|600px|center|Pending goods receipt column definition.]]&lt;br /&gt;
&lt;br /&gt;
== Adding the widget to your workspace ==&lt;br /&gt;
&lt;br /&gt;
Once the widget is done if you have access to it you are able to add it to your workspace. It is not needed to compile anything.&lt;br /&gt;
&lt;br /&gt;
On the ''Add widget'' menu select your new widget. If all the parameters have a default value or are fixed you will see the widget added on the workspace. Otherwise you will be prompted to fill the parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:how-to-querylist-add-params.png|thumbnail|600px|center|Pending goods receipt setting parameters.]]&lt;br /&gt;
&lt;br /&gt;
And the final result:&lt;br /&gt;
&lt;br /&gt;
[[Image:how-to-querylist-result.png|center|Pending goods receipt widget.]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>