I have a scheme table for incentive calculation .Table Incentive with the
following fields :

<entity entity-name="MasterIncentive" title="Master  for Incentive" > 
        <field name="incentiveCode" type="id-ne"/> 
        <field name="maxNo" type="currency-amount"/>
        <field name="amount" type="currency-amount"/> 
        <prim-key field="incentiveCode"/>
</entity>

There is a form to create new scheme.
When the user fills in the form and enter the submit button.. the simple
method will check, whether the primary key inputted is already used. If it
is, it will display an error message “incentive code entered is already
used. Use another incentive code”. And if it isn’t, the simple method will
run as usual (). Here is my simple method code..

<simple-method method-name="createIncNewScheme" short-description="Create an
Incentive Scheme">

          <!-- add check duplicate -->
          <field-to-field field-name="incentiveCode" map-name="parameters"
to-map-name="lookupParams"/>
        <field-to-field string="incentiveCode" map-name="parameters" 
to-map-name="lookupParams"/>
        <find-by-primary-key use-cache="true" entity-name="MasterIncentive"
value-name="losCode" map-name="lookupParams"/>
        <if-empty field-name="incentiveCode">
                                <!-- end check -->
                <make-value value-name="newEntity"
entity-name="MasterIncentive"></make-value>
                        <set-nonpk-fields map-name="parameters"
value-name="newEntity"></set-nonpk-fields>
                        <set from-field="parameters.incentiveCode"
field="newEntity.incentiveCode"></set>
                                <if-empty field-name="newEntity.incentiveCode">
                                        <sequenced-id-to-env 
sequence-name="Hlid"
env-name="newEntity.incentiveCode"></sequenced-id-to-env>
                                <else>
                                        <check-id field-name="incentiveCode" 
map-name="newEntity"></check-id>
                                        <check-errors></check-errors>
                                </else>
                                </if-empty>
                        <field-to-result field-name="incentiveCode" 
map-name="newEntity"
result-name="incentiveCode"></field-to-result>
                        <create-value value-name="newEntity"></create-value>
                <else>
                        <add-error><fail-message message="incentiveCode is 
already used, use
another one"/></add-error>
                        <check-errors/>
                </else>
        </if-empty>
          
    </simple-method>

The problem with this code is that, the simple method keeps storing the new
scheme in the table, although it found another record in the table with the
same primary key.
Could anyone help me ??
Thanks


-- 
View this message in context: 
http://www.nabble.com/Simple-method-question%2C-checking-duplicate-primary-key-tf4941048.html#a14144328
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to