我有同样的问题。我已经花了一周的时间试图解决它,最后我明白了。我希望它能解决你的问题。
我必须恢复列表中的所有 DDLRecords,并发现一个正在使用我的工作流,与 DDLRecord 的“recordSetId”相比,“recordSetId”属性。
最终的代码是这样的:
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portlet.dynamicdatamapping.storage.Field;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
import com.liferay.portlet.dynamicdatalists.model.impl.DDLRecordImpl;
import com.liferay.portlet.dynamicdatalists.service.*;
long companyId = GetterUtil.getLong((String) workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
String uuid = (String) workflowContext.get(WorkflowConstants.CONTEXT_USER_ID);
ServiceContext serviceContext = (ServiceContext) workflowContext.get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT);
long ddlRecordId = GetterUtil.getLong(serviceContext.getAttribute("recordSetId"));
List ddlRecordList = DDLRecordLocalServiceUtil.getDDLRecords(0,DDLRecordLocalServiceUtil.getDDLRecordsCount());
for(DDLRecord o : ddlRecordList){
if(o.getRecordSetId()==ddlRecordId){
Field field = o.getField("status");
String status = GetterUtil.getString(field.getValue());
if (status.contains("not")) {
returnValue = "No"
}
else {
returnValue = "Yes"
}
}
}