0

I try to create a new entity with MiniLang and a form.

The entity definition is:

<entity entity-name="station" package-name="org.ofbiz.mystations"
    title="Entity for station data">
    <field name="stationId" type="id-ne"></field>
    <field name="Name" type="id"></field>
    <field name="Strasse" type="id"></field>
    <field name="Hausnr" type="id"></field>
    <field name="PLZ" type="id"></field>
    <field name="Ort" type="id"></field>
    <field name="Beschreibung" type="id"></field>
    <prim-key field="stationId" />      
</entity>    

the form is this:

<form name="addStation" type="single" target="createStation">
<auto-fields-service service-name="createStation"/>
<auto-fields-entity entity-name="station"/>
<field name="stationId"><hidden/></field> 
<field name="Name"></field>
<field name="Strasse"></field>
<field name="Hausnr"></field>
<field name="Ort"></field>
<field name="Beschreibung"></field>
<field name="submitButton" title="add Station" widget-style="standardSubmit"><submit     button-type="button"/></field>
  </form>
</forms>

and the minilang-service definition is this:

<simple-method method-name="createStation" short-description="Create a Station"
  login-required="true">
  <make-value entity-name="station"  value-name="newEntity" />
  <set-nonpk-fields map-name="parameters" value-name="newEntity" />
  <set-pk-fields map-name="parameters" value-name="newEntity" />
  <create-value value-name="newEntity" />
 </simple-method>

Now the error I get is: Entity value not found with name: Method = createStation, File = file:/home/std/Dokumente/ofbiz/hot-deploy/mystations/script/org/ofbiz/mystations/mystationsServices.xml, Element = , Line 16null

What is going wrong? The entity "station" exists. Can I get further information (where is the error log?). How can I get debug information?

Thank you for your help!

Mike75
  • 504
  • 3
  • 18

1 Answers1

1

Now below I found the correct code for creating a new value. The simple-method-statement additional needs an sequenced-id statement to auto-increment the primary key (stationId).

Now it works!

Here is the code:

    <simple-method method-name="createStation" short-description="Create a Station"
      login-required="true">
      <make-value entity-name="station" map-name="parameters" value-field="newEntity" />
        <set-pk-fields map="parameters" value-field="newEntity" />
        <set-nonpk-fields map="parameters" value-field="newEntity" />        
        <if-empty field="newEntity.stationId">
            <sequenced-id sequence-name="station" field="newEntity.stationId" />
            <else>
                <check-id field="newEntity.stationId" />
                <check-errors />
            </else>
        </if-empty>  
      <create-value value-field="newEntity" />
     </simple-method>
Mike75
  • 504
  • 3
  • 18