Showing posts with label remove(). Show all posts
Showing posts with label remove(). Show all posts

Deleting a Record in OFBiz using Java

This is an example on how to delete a record in OFBiz using Java. I am assuming that the you have created the service of this method in you service.xml.

public static Map deletePerson(DispatchContext dctx, Map context) {
Map resultMap = ServiceUtil.returnSuccess();
String id = (String) context.get("id");

try {
GenericValue personGV = delegator.findOne("Person", UtilMisc.toMap("id", id), false);
if (personGV != null && !personGV.isEmpty()) {
personGV.remove();
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError("Failed. " +e.getMessage());
}
return resultMap;
}