You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Anil Patel <ap...@adititechlabs.com> on 2006/12/18 20:17:03 UTC

Duplicate Primary Key error while creating new Entity record like create FixedAsset

Hi,
We have forms that handle create/update entity data. One of the common
problems user run into is, In the Create New Form (e.g New FixedAsset) user
enters value in Id field. There is possibility that the value entered may
already exist in database. In such situations, Form returns with error
message, But also Opens existing entity in Edit/Update mode in the form.
This confuses user.

Most of these create/update form directly post to CRUD services. Is it OK if
I added a Simple Method event handler that took the request call and
forwarded to CRUD service and then on return of service check if there is
error, In case of error set the value of primary key field to nothing so the
create/update form will not be able to read existing entity to open it in
Edit mode.

If this is Ok to do, Should I add Event handler simple methods in existing
services xml files (e.g FixedAssetServices.xml) Or should I create a new
file that will have such event handler simple methods.

If I can get Feedback on this email it will be easy to prepare a patch to
fix http://issues.apache.org/jira/browse/OFBIZ-547.

Regards
Anil Patel

Re: Duplicate Primary Key error while creating new Entity record like create FixedAsset

Posted by David E Jones <jo...@undersunconsulting.com>.
Anil,

The pattern I've had in mind for this that works for most "standard"  
patterned screens in OFBiz is that if you enter an ID that exists it  
will show you the info for it. If that isn't what you intended, you  
can click on the "Create New Xxxxx" button that should always be just  
above the form, or the user can just hit the back button.

For large entities this is admittedly a pain because either the user  
doesn't think of hitting the back button, or the browser does  
something dumb and doesn't remember their info, and then they have to  
re-enter all of the data. We could add another link/button in this  
case to user the information they entered, ie purely from the  
parameters Map, and populate a new create form.

-David


On Dec 19, 2006, at 10:07 AM, Anil Patel wrote:

> Sorry to bother everybody again, But this Thread somehow got  
> deviated from
> main subject. The problem I have posted in this email is  
> encountered in Most
> of the CRUD Forms in Ofbiz. Please share if somebody can think of  
> Ideas on
> workaround this problem.
>
> Regards
> Anil Patel
>
>
>
>
> On 12/18/06, Anil Patel <ap...@adititechlabs.com> wrote:
>>
>> Hi,
>> We have forms that handle create/update entity data. One of the  
>> common
>> problems user run into is, In the Create New Form (e.g New  
>> FixedAsset)
>> user enters value in Id field. There is possibility that the value  
>> entered
>> may already exist in database. In such situations, Form returns  
>> with error
>> message, But also Opens existing entity in Edit/Update mode in the  
>> form.
>> This confuses user.
>>
>> Most of these create/update form directly post to CRUD services.  
>> Is it OK
>> if I added a Simple Method event handler that took the request  
>> call and
>> forwarded to CRUD service and then on return of service check if  
>> there is
>> error, In case of error set the value of primary key field to  
>> nothing so the
>> create/update form will not be able to read existing entity to  
>> open it in
>> Edit mode.
>>
>> If this is Ok to do, Should I add Event handler simple methods in  
>> existing
>> services xml files (e.g FixedAssetServices.xml) Or should I create  
>> a new
>> file that will have such event handler simple methods.
>>
>> If I can get Feedback on this email it will be easy to prepare a  
>> patch to
>> fix http://issues.apache.org/jira/browse/OFBIZ-547.
>>
>> Regards
>> Anil Patel
>>


Re: Duplicate Primary Key error while creating new Entity record like create FixedAsset

Posted by Anil Patel <to...@gmail.com>.
Sorry to bother everybody again, But this Thread somehow got deviated from
main subject. The problem I have posted in this email is encountered in Most
of the CRUD Forms in Ofbiz. Please share if somebody can think of Ideas on
workaround this problem.

Regards
Anil Patel




On 12/18/06, Anil Patel <ap...@adititechlabs.com> wrote:
>
> Hi,
> We have forms that handle create/update entity data. One of the common
> problems user run into is, In the Create New Form (e.g New FixedAsset)
> user enters value in Id field. There is possibility that the value entered
> may already exist in database. In such situations, Form returns with error
> message, But also Opens existing entity in Edit/Update mode in the form.
> This confuses user.
>
> Most of these create/update form directly post to CRUD services. Is it OK
> if I added a Simple Method event handler that took the request call and
> forwarded to CRUD service and then on return of service check if there is
> error, In case of error set the value of primary key field to nothing so the
> create/update form will not be able to read existing entity to open it in
> Edit mode.
>
> If this is Ok to do, Should I add Event handler simple methods in existing
> services xml files (e.g FixedAssetServices.xml) Or should I create a new
> file that will have such event handler simple methods.
>
> If I can get Feedback on this email it will be easy to prepare a patch to
> fix http://issues.apache.org/jira/browse/OFBIZ-547.
>
> Regards
> Anil Patel
>

Re: Duplicate Primary Key error while creating new Entity record like create FixedAsset

Posted by Chris Howe <cj...@yahoo.com>.
We have had to work with FixedAsset and we chose to
utilize a method more generic than the FixedAssetIdent
so that we wouldn't have to recreate the wheel for the
other entities where aliases (identifications) are
necessary.  We then used a junction table between
FixedAsset and our generic Identification entity. 
This many to many relationship available with the
junction table allows us to maintain manufacturer lot
numbers as well.


--- Anil Patel <to...@gmail.com> wrote:

> Thanks for your Idea Chris, I am not sure if you
> just gave example using
> FixedAsset or you really had to work with FixedAsest
> entity. Now I remember
> there is entity FixedAssetIdent table that we can
> use for this purpose.
> 
> Regards
> Anil Patel
> 
> On 12/18/06, Chris Howe <cj...@yahoo.com>
> wrote:
> >
> > I imagine this is an issue for you because you
> have
> > something else defining your fixedAssetId such as
> > Quickbooks.
> >
> > While the screens are setup to accommodate this
> > practice, this does set you up for problems down
> the
> > road (we ran into this early on with the product
> > entity).  FixedAsset.fixedAssetId is treated as a
> > surrogate key throughout the services of OFBiz.
> > Because of this trying, to apply meaning to the
> key is
> > likely to cause you problems later on, especially
> in
> > cases of data entry error (typos).
> >
> > What we've done in our deployment is something
> similar
> > to the GoodIdentification entity but generic to
> > accommodate more entities.  We chose this approach
> > over adding a FixedAsset.externalId field because
> we
> > wanted to normalize other identifications of the
> fixed
> > asset (serialNumber) so we could create generic
> > services to handle identification requests.
> >
> >
> > --- Anil Patel <ap...@adititechlabs.com> wrote:
> >
> > > Hi,
> > > We have forms that handle create/update entity
> data.
> > > One of the common
> > > problems user run into is, In the Create New
> Form
> > > (e.g New FixedAsset) user
> > > enters value in Id field. There is possibility
> that
> > > the value entered may
> > > already exist in database. In such situations,
> Form
> > > returns with error
> > > message, But also Opens existing entity in
> > > Edit/Update mode in the form.
> > > This confuses user.
> > >
> > > Most of these create/update form directly post
> to
> > > CRUD services. Is it OK if
> > > I added a Simple Method event handler that took
> the
> > > request call and
> > > forwarded to CRUD service and then on return of
> > > service check if there is
> > > error, In case of error set the value of primary
> key
> > > field to nothing so the
> > > create/update form will not be able to read
> existing
> > > entity to open it in
> > > Edit mode.
> > >
> > > If this is Ok to do, Should I add Event handler
> > > simple methods in existing
> > > services xml files (e.g FixedAssetServices.xml)
> Or
> > > should I create a new
> > > file that will have such event handler simple
> > > methods.
> > >
> > > If I can get Feedback on this email it will be
> easy
> > > to prepare a patch to
> > > fix
> http://issues.apache.org/jira/browse/OFBIZ-547.
> > >
> > > Regards
> > > Anil Patel
> > >
> >
> >
> 


Re: Duplicate Primary Key error while creating new Entity record like create FixedAsset

Posted by Anil Patel <to...@gmail.com>.
Thanks for your Idea Chris, I am not sure if you just gave example using
FixedAsset or you really had to work with FixedAsest entity. Now I remember
there is entity FixedAssetIdent table that we can use for this purpose.

Regards
Anil Patel

On 12/18/06, Chris Howe <cj...@yahoo.com> wrote:
>
> I imagine this is an issue for you because you have
> something else defining your fixedAssetId such as
> Quickbooks.
>
> While the screens are setup to accommodate this
> practice, this does set you up for problems down the
> road (we ran into this early on with the product
> entity).  FixedAsset.fixedAssetId is treated as a
> surrogate key throughout the services of OFBiz.
> Because of this trying, to apply meaning to the key is
> likely to cause you problems later on, especially in
> cases of data entry error (typos).
>
> What we've done in our deployment is something similar
> to the GoodIdentification entity but generic to
> accommodate more entities.  We chose this approach
> over adding a FixedAsset.externalId field because we
> wanted to normalize other identifications of the fixed
> asset (serialNumber) so we could create generic
> services to handle identification requests.
>
>
> --- Anil Patel <ap...@adititechlabs.com> wrote:
>
> > Hi,
> > We have forms that handle create/update entity data.
> > One of the common
> > problems user run into is, In the Create New Form
> > (e.g New FixedAsset) user
> > enters value in Id field. There is possibility that
> > the value entered may
> > already exist in database. In such situations, Form
> > returns with error
> > message, But also Opens existing entity in
> > Edit/Update mode in the form.
> > This confuses user.
> >
> > Most of these create/update form directly post to
> > CRUD services. Is it OK if
> > I added a Simple Method event handler that took the
> > request call and
> > forwarded to CRUD service and then on return of
> > service check if there is
> > error, In case of error set the value of primary key
> > field to nothing so the
> > create/update form will not be able to read existing
> > entity to open it in
> > Edit mode.
> >
> > If this is Ok to do, Should I add Event handler
> > simple methods in existing
> > services xml files (e.g FixedAssetServices.xml) Or
> > should I create a new
> > file that will have such event handler simple
> > methods.
> >
> > If I can get Feedback on this email it will be easy
> > to prepare a patch to
> > fix http://issues.apache.org/jira/browse/OFBIZ-547.
> >
> > Regards
> > Anil Patel
> >
>
>

Re: Duplicate Primary Key error while creating new Entity record like create FixedAsset

Posted by Chris Howe <cj...@yahoo.com>.
I imagine this is an issue for you because you have
something else defining your fixedAssetId such as
Quickbooks.  

While the screens are setup to accommodate this
practice, this does set you up for problems down the
road (we ran into this early on with the product
entity).  FixedAsset.fixedAssetId is treated as a
surrogate key throughout the services of OFBiz. 
Because of this trying, to apply meaning to the key is
likely to cause you problems later on, especially in
cases of data entry error (typos).  

What we've done in our deployment is something similar
to the GoodIdentification entity but generic to
accommodate more entities.  We chose this approach
over adding a FixedAsset.externalId field because we
wanted to normalize other identifications of the fixed
asset (serialNumber) so we could create generic
services to handle identification requests.


--- Anil Patel <ap...@adititechlabs.com> wrote:

> Hi,
> We have forms that handle create/update entity data.
> One of the common
> problems user run into is, In the Create New Form
> (e.g New FixedAsset) user
> enters value in Id field. There is possibility that
> the value entered may
> already exist in database. In such situations, Form
> returns with error
> message, But also Opens existing entity in
> Edit/Update mode in the form.
> This confuses user.
> 
> Most of these create/update form directly post to
> CRUD services. Is it OK if
> I added a Simple Method event handler that took the
> request call and
> forwarded to CRUD service and then on return of
> service check if there is
> error, In case of error set the value of primary key
> field to nothing so the
> create/update form will not be able to read existing
> entity to open it in
> Edit mode.
> 
> If this is Ok to do, Should I add Event handler
> simple methods in existing
> services xml files (e.g FixedAssetServices.xml) Or
> should I create a new
> file that will have such event handler simple
> methods.
> 
> If I can get Feedback on this email it will be easy
> to prepare a patch to
> fix http://issues.apache.org/jira/browse/OFBIZ-547.
> 
> Regards
> Anil Patel
>