You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Ismail Al Kouz <iA...@bi-bst.com> on 2017/04/03 09:23:38 UTC

update field

Hello Dears.

How I can update field on entity using Java .

Thanks


Best Regards,


Re: update field

Posted by Aditya Sharma <ad...@hotwaxsystems.com>.
Hello Ismail,

First of all Apache OFBiz is a *service oriented architecture *and you
will *find
a service* for all the CRUD operations.You can find a service using
https://localhost:8443/webtools/control/ServiceList .

Alternately, you can create a new service with *service-engine as
entity-auto* that performs the operations automatically like this service
created in OOTB.


<service name="updatePartyAttribute"
default-entity-name="PartyAttribute" engine="entity-auto"
invoke="update" auth="true">
    <description>updates a party attribute record</description>
    <permission-service service-name="partyBasePermissionCheck"
main-action="UPDATE"/>
    <auto-attributes include="pk" mode="IN" optional="false"/>
    <auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>

Here you don't have to implement the service.


If you still prefer to create your own service. Here is the code

*GenericValue entityRecord =
EntityQuery.use(delegator).from(EntityName).where("primaryKeyFieldName",
primaryKeyFieldValue).queryOne();*

*---fetching record from entity*

*entityRecord.setNonPKFields(parameters, true);*

*--- sets all values from parameter Map and true is setIfEmpty field which
is used to specify whether empty/null values in the parameters Map should
over-write non-empty values in this entity*

*entityRecord.store();*

*----store the updated values in entity*




Thanks & Regards,
Aditya Sharma
Enterprise Software Engineer
Hotwax Systems
http://www.hotwaxsystems.com/

On Mon, Apr 3, 2017 at 2:53 PM, Ismail Al Kouz <iA...@bi-bst.com> wrote:

> Hello Dears.
>
> How I can update field on entity using Java .
>
> Thanks
>
>
> Best Regards,
>
>