Creating an Actionable Report
Now we will enable our original action, Publish, for the report we created earlier, ZBKS.AllBooks. Open reports/Bookstore.reports from the Bookstore project, and change the AllBooks report to the following:
<Report><Name>AllBooks</Name><SqlDefName="AllBooks"GroupName="SampleSqls"><![CDATA[select SYS_BOOK_ID, TITLE, AUTHOR, ISBN, PRICE_AMOUNT, PRICE_UOM, QUANTITY_SOLD, USERS.USER_NAME from ZBKS_BOOKinner join USERS on ZBKS_BOOK.SYS_SALES_REP_ID = USERS.SYS_USER_IDwhere ($TITLE_FILTER$ is null or upper(TITLE) like upper($TITLE_FILTER$) || '%')]]></SqlDef><ActionDef><PrimaryModelLevelType>ZBKS.Book</PrimaryModelLevelType></ActionDef><Filters><CustomFilterField><FieldReflevelType="ZBKS.Book"category="PDF"><FieldName>Title</FieldName></FieldRef><Type>STRING</Type><SimpleMappingsqlName="TITLE_FILTER"/></CustomFilterField></Filters><Retrieval><RetrievalFieldlevelType="ZBKS.Book"category="PDF"><FieldName>SysBookId</FieldName></RetrievalField><CustomRetrievalField><FieldReflevelType="ZBKS.Book"category="PDF"><FieldName>Title</FieldName></FieldRef><Type>STRING</Type><ColumnWidth>200</ColumnWidth><SimpleMappingsqlName="TITLE"/></CustomRetrievalField><RetrievalFieldlevelType="ZBKS.Book"category="PDF"><FieldName>Author</FieldName></RetrievalField><RetrievalFieldlevelType="ZBKS.Book"category="PDF"><FieldName>ISBN</FieldName></RetrievalField><RetrievalFieldlevelType="ZBKS.Book"category="PDF"><FieldName>QuantitySold</FieldName></RetrievalField><CustomRetrievalField><FieldReflevelType="ZBKS.Book"category="PDF"><FieldName>PriceAmount</FieldName></FieldRef><Hidden>true</Hidden><Type>STRING</Type><SimpleMappingsqlName="PRICE_AMOUNT"/></CustomRetrievalField><CustomRetrievalField><FieldReflevelType="ZBKS.Book"category="PDF"><FieldName>PriceUOM</FieldName></FieldRef><Hidden>true</Hidden><Type>STRING_ENUMERATION</Type><EnumerationType>CurrencyCode</EnumerationType><SimpleMappingsqlName="PRICE_UOM"/></CustomRetrievalField><CustomRetrievalField><FieldReflevelType="ZBKS.Book"category="PDF"><FieldName>Price</FieldName></FieldRef><Type>COMPOSITE</Type><Sortable>false</Sortable><CompositeFieldTypename="PRICE"><Componentname="PriceAmount"type="STRING"/><Componentname="PriceUOM"type="STRING_ENUMERATION"/></CompositeFieldType><ColumnWidth>110</ColumnWidth><SimpleMappingsqlName="PRICE"/></CustomRetrievalField><CustomRetrievalField><FieldReflevelType="ZBKS.Book"category="PDF"><FieldName>SalesRep</FieldName></FieldRef><Type>STRING</Type><SimpleMappingsqlName="USER_NAME"/></CustomRetrievalField></Retrieval></Report>
Note that the following things were added to the original report:
An ActionDef tag was added with a PrimaryModelLevelType which tells the report what specific model that we are acting upon.
SYS_BOOK_ID (the surrogate key) was added among the fields in the SqlDef and SysBookId was added to the Retrieval section, because actions utilize surrogate keys to determine which selected records are being acted upon.
Submit the report by clicking the
Submit button on the Studio toolbar.To use it within the report, we can create another instance of Book in the database using load-data. Open data/Books.xml from within the Bookstore_dataset project.
Add the following XML to the file after the existing <Book> element before </ModelList>.
<Bookxmlns="http://www.mybooks.com/Bookstore"><ValueChainId>9123</ValueChainId><Title>The Art of War</Title><ISBN>9788175257700</ISBN><Author>Sun Tzu</Author><PublishedDate>1994-02-11T00:00:00-00:00</PublishedDate><PublisherAddress><vc:Country>US</vc:Country><vc:ComponentType="STREET1">4055 Valley View Lane</vc:Component><vc:ComponentType="STREET2">Suite 400</vc:Component><vc:ComponentType="CITY">Dallas</vc:Component><vc:ComponentType="STATE">TX</vc:Component><vc:ComponentType="ZIP">75244</vc:Component></PublisherAddress><PublisherWebsite><ahref="http://www.onenetwork.com">www.onenetwork.com</a></PublisherWebsite><QuantitySold>500</QuantitySold><PriceAmount>34.99</PriceAmount><PriceUOM>USD</PriceUOM><PromotionalPeriodStartDate>2006-02-15T00:00:00-00:00</PromotionalPeriodStartDate><PromotionalPeriodEndDate>2006-03-15T00:00:00-00:00</PromotionalPeriodEndDate><Rating>9.7</Rating><ReturnPolicy>P30D</ReturnPolicy><SalesRepName>BookstoreUser</SalesRepName><SalesRepEnterpriseName>SampleEnterprise</SalesRepEnterpriseName><Genre>Non-Fiction</Genre></Book>Save the file and execute the load-data target from with Bookstore_dataset.
In NEO, open the All Books report from the menu, and you can see the book we just added, as well as a disabled Actions button (bottom-right of the page). Select the recently added book, click the button, and you should see the Publish action in the menu. (NOTE: Don't publish this book just yet; we will be doing that in the next section.