I would like to use an existing service (createInvoice
)
within an new ofbiz
component.
In my componentScreens.xml I added: a section
<decorator-section name="body">
<section>
<widgets>
<screenlet title="${uiLabelMap.AccountingCreateNewSalesInvoice}">
<include-form name="NewSalesInvoice" location="component://accounting/widget/InvoiceForms.xml"/>
</screenlet>
<screenlet title="${uiLabelMap.AccountingCreateNewPurchaseInvoice}">
<include-form name="NewPurchaseInvoice" location="component://accounting/widget/InvoiceForms.xml"/>
</screenlet>
</widgets>
</section>
</decorator-section>
which is displayed fine. But the NewPurchaseInovice-form
calls a service createInvoice
, which is defined in /accounting/servicedef/services_invoice.xml
So when my form calls the service ofbiz
states an error:
org.ofbiz.webapp.control.RequestHandlerException: Unknown request [createInvoice]; this request does not exist or cannot be called directly.
One solution might be to redefine (copy) the service in my components services.xml:
<service name="createInvoice" engine="simple" default-entity-name="Invoice"
location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="createInvoice">
<description>Create Invoice Record</description>
<permission-service service-name="acctgInvoicePermissionCheck" main-action="CREATE"/>
<auto-attributes mode="INOUT" include="pk" optional="true"/>
<auto-attributes mode="IN" include="nonpk" optional="true"/>
<override name="invoiceTypeId" mode="IN" optional="false"/>
<override name="partyIdFrom" mode = "IN" optional="false"/>
<override name="partyId" mode = "IN" optional="false"/>
<override name="description" allow-html="safe"/>
<override name="invoiceMessage" allow-html="safe"/>
</service>
But maybe there is an easier solution (maybe there is a way to specify the location of the service in the request-map?).
The error org.ofbiz.webapp.control.RequestHandlerException: Unknown request [createInvoice]; this request does not exist or cannot be called directly.
states that the component cannot find the specified request, it's not about the service definition. Inside the request definition you specify which event or service has to be processed.
Your form calls a request which has either to be specified in your component's controller.xml or the form's request must point to the accounting component's request which already exists.
You don't have to copy the service definition to use it in you component, OFBiz registers all service definitions by name and handles them for all components.