public static MapdeletePerson(DispatchContext dctx, Map context) {
MapresultMap = 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;
}
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.
Labels:
delegator,
DispatchContext,
findOne,
GenericEntityException,
GenericValue,
Java,
Map,
OFBiz,
remove(),
ServiceUtil
Subscribe to:
Post Comments (Atom)
You could do a .removeByPrimaryKey and save yourself a step... if you wanted.
ReplyDeleteyou have a nice site. thanks for sharing this site. there are various kinds of ebooks are available here
ReplyDeletehttp://feboook.blogspot.com
.removeByPrimaryKey is a deprecated method.
ReplyDelete<remove-value. I suggest you to use XML auto completion. Below, there is some useful information
ReplyDeletehttps://cwiki.apache.org/confluence/display/OFBIZ/Mini-Language+Guide