You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Alfresco SDK 3:如何访问表单中未显示的变量

Accessing Hidden Form Variables in Alfresco SDK 3

Hey there! Let's break down how to get those hidden form variables from your wfvd:activitiReviewTask type defined in workflow-validation-model.xml. These variables are actually custom properties on the Alfresco task node (since your type extends wf:activitiReviewTask, a subtype of bpm:workflowTask), so we'll need to interact with Alfresco's core services to fetch them.

1. Backend Approach (Java Code)

If you're working in a Java delegate, web script, or any backend component in your SDK 3 project, here's how to access the properties:

Step 1: Inject Required Services

First, autowire the core services needed to link the Activiti task to its Alfresco node and read properties:

@Autowired
private NodeService nodeService;

@Autowired
private TaskService taskService;

Step 2: Fetch the Task Node Reference

Every Activiti task in Alfresco is tied to a bpm:workflowTask node. Use the task ID to retrieve this node's NodeRef:

// Replace with your actual task ID (you can get this from DelegateExecution or task queries)
String taskId = "your-task-uuid-here";
NodeRef taskNodeRef = (NodeRef) taskService.getVariable(taskId, "bpm:workflowTask");

Step 3: Read the Hidden Properties

Define the QName for each property (matching your model's namespace) and fetch their values:

// Replace with your model's namespace URI (check workflow-validation-model.xml for this)
String WFVD_NAMESPACE = "http://your-namespace-uri/model/workflowvalidation/1.0";

QName retourMedecinQName = QName.createQName(WFVD_NAMESPACE, "retourMedecin");
QName nomServiceQName = QName.createQName(WFVD_NAMESPACE, "nomService");
QName newPatientQName = QName.createQName(WFVD_NAMESPACE, "newPatient");

// Retrieve property values (adjust types based on your model definitions)
String retourMedecin = (String) nodeService.getProperty(taskNodeRef, retourMedecinQName);
String nomService = (String) nodeService.getProperty(taskNodeRef, nomServiceQName);
Boolean newPatient = (Boolean) nodeService.getProperty(taskNodeRef, newPatientQName);

// Use the values as needed
System.out.println("Retour médecin: " + retourMedecin);

2. Frontend/REST Approach

If you need to access these variables from a Share custom page or external app, use Alfresco's REST API:

  • First, fetch the task details via GET /alfresco/api/-default-/public/alfresco/versions/1/workflow-tasks/{taskId} to get the nodeId field (this is the ID of the linked bpm:workflowTask node)
  • Then call the node properties endpoint to retrieve all properties, including hidden ones:
    GET /alfresco/api/-default-/public/alfresco/versions/1/nodes/{task-node-id}/properties
    

Key Notes

  • Namespace Check: Double-check the namespace URI in your workflow-validation-model.xml (look for the <namespace> tag) — this must match what you use in your QName definitions.
  • Model Deployment: Ensure your model is properly loaded in your SDK 3 project. Add this bean to your service-context.xml (under platform-jar/src/main/resources/alfresco/module/platform-jar/context/):
    <bean id="workflowValidationModel" parent="dictionaryModel">
        <property name="location" value="classpath:alfresco/module/platform-jar/model/workflow-validation-model.xml"/>
    </bean>
    
  • Task ID Retrieval: If you don't have the task ID upfront, use TaskService.createTaskQuery() to filter tasks by process instance ID, assignee, or other criteria.

内容的提问来源于stack exchange,提问作者anakin59490

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:46:11