update field

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

update field

Ismail Al Kouz
Hello Dears.

How I can update field on entity using Java .

Thanks


Best Regards,

Reply | Threaded
Open this post in threaded view
|

Re: update field

Aditya Sharma
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 <[hidden email]> wrote:

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