-
Type: Improvement
-
Status: Resolved
-
Priority: Minor
-
Resolution: Won't Fix
-
Affects Version/s: 5.9.2
-
Fix Version/s: 5.9.4
-
Component/s: Automation, Layouts & Widgets
When one wants to store a document field other than the document uid in a custom select2 via the 'idProperty' widget property, he'll also need to specify a custom operation to resolve this reference during the init phase of the select2 via the 'initOperationId'.
This is a pain and this represents too much developments to achieve a simple requirement.
We should be able to provide a generic operation that will be passed to the 'initOperationId' widget property whenever the 'idProperty' is specified.
The operation will be like:
@Operation(id = S2GenericInitOperation.ID, category = Constants.CAT_UI, label = "xxx", description = "yyy") public class S2GenericInitOperation { public static final String ID = "S2GenericInitOperationID"; @Context protected CoreSession session; @Param(name = "value", required = true) protected String value; @Param(name = "xpath", required = true) protected String xpath; @OperationMethod public DocumentModel run(DocumentModel doc) throws ClientException { Object[] paramaters = new Object[1]; paramaters[0] = value; DocumentModelList l = session.query(NXQLQueryBuilder.getQuery( "SELECT * FROM Document WHERE " + xpath + " = ?", paramaters, true, false)); if (l.size() == 1) { return l.get(0); } else if (l.isEmpty()) { return null; } else { throw new ClientException("More than one result!"); } } }