Creating an Actionable Report

  1. 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>
    <SqlDef Name="AllBooks" GroupName="SampleSqls"><![CDATA[
    select SYS_BOOK_ID, TITLE, AUTHOR, ISBN, PRICE_AMOUNT, PRICE_UOM, QUANTITY_SOLD, USERS.USER_NAME from ZBKS_BOOK
    inner join USERS on ZBKS_BOOK.SYS_SALES_REP_ID = USERS.SYS_USER_ID
    where ($TITLE_FILTER$ is null or upper(TITLE) like upper($TITLE_FILTER$) || '%')
    ]]></SqlDef>
    <ActionDef>
    <PrimaryModelLevelType>ZBKS.Book</PrimaryModelLevelType>
    </ActionDef>
    <Filters>
    <CustomFilterField>
    <FieldRef levelType="ZBKS.Book" category="PDF">
    <FieldName>Title</FieldName>
    </FieldRef>
    <Type>STRING</Type>
    <SimpleMapping sqlName="TITLE_FILTER"/>
    </CustomFilterField>
    </Filters>
    <Retrieval>
    <RetrievalField levelType="ZBKS.Book" category="PDF">
    <FieldName>SysBookId</FieldName>
    </RetrievalField>
    <CustomRetrievalField>
    <FieldRef levelType="ZBKS.Book" category="PDF">
    <FieldName>Title</FieldName>
    </FieldRef>
    <Type>STRING</Type>
    <ColumnWidth>200</ColumnWidth>
    <SimpleMapping sqlName="TITLE" />
    </CustomRetrievalField>
    <RetrievalField levelType="ZBKS.Book" category="PDF">
    <FieldName>Author</FieldName>
    </RetrievalField>
    <RetrievalField levelType="ZBKS.Book" category="PDF">
    <FieldName>ISBN</FieldName>
    </RetrievalField>
    <RetrievalField levelType="ZBKS.Book" category="PDF">
    <FieldName>QuantitySold</FieldName>
    </RetrievalField>
    <CustomRetrievalField>
    <FieldRef levelType="ZBKS.Book" category="PDF">
    <FieldName>PriceAmount</FieldName>
    </FieldRef>
    <Hidden>true</Hidden>
    <Type>STRING</Type>
    <SimpleMapping sqlName="PRICE_AMOUNT" />
    </CustomRetrievalField>
    <CustomRetrievalField>
    <FieldRef levelType="ZBKS.Book" category="PDF">
    <FieldName>PriceUOM</FieldName>
    </FieldRef>
    <Hidden>true</Hidden>
    <Type>STRING_ENUMERATION</Type>
    <EnumerationType>CurrencyCode</EnumerationType>
    <SimpleMapping sqlName="PRICE_UOM" />
    </CustomRetrievalField>
    <CustomRetrievalField>
    <FieldRef levelType="ZBKS.Book" category="PDF">
    <FieldName>Price</FieldName>
    </FieldRef>
    <Type>COMPOSITE</Type>
    <Sortable>false</Sortable>
    <CompositeFieldType name="PRICE">
    <Component name="PriceAmount" type="STRING" />
    <Component name="PriceUOM" type="STRING_ENUMERATION" />
    </CompositeFieldType>
    <ColumnWidth>110</ColumnWidth>
    <SimpleMapping sqlName="PRICE" />
    </CustomRetrievalField>
    <CustomRetrievalField>
    <FieldRef levelType="ZBKS.Book" category="PDF">
    <FieldName>SalesRep</FieldName>
    </FieldRef>
    <Type>STRING</Type>
    <SimpleMapping sqlName="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.

  2. Submit the report by clicking the images/download/attachments/144836620/submit_btn-version-1-modificationdate-1670861430000-api-v2.png Submit button on the Studio toolbar.

  3. 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.

  4. Add the following XML to the file after the existing <Book> element before </ModelList>.

    <Book xmlns="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:Component Type="STREET1">4055 Valley View Lane</vc:Component>
    <vc:Component Type="STREET2">Suite 400</vc:Component>
    <vc:Component Type="CITY">Dallas</vc:Component>
    <vc:Component Type="STATE">TX</vc:Component>
    <vc:Component Type="ZIP">75244</vc:Component>
    </PublisherAddress>
    <PublisherWebsite>&lt;a href=&quot;http://www.onenetwork.com&quot;&gt;www.onenetwork.com&lt;/a&gt;</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.

  5. 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.