I'm calling the action as in the following but the req.metaData causes issues (the function is not shown by the browser):
// Create obj for the target
var target = {};
target.entityType = "collection";
target.Id = collectionid;
// build the request...
var req = {};
req.entity = target;
req.CollectionId = collectionid; // CollectionId is the input parameter of the process
req.getMetadata = function () {
return {
boundParameter: "entity",
parameterTypes: {
"entity": {
"typeName": "mscrm.collection",
"structuralProperty": 5
},
"CollectionId": { // CollectionId is the input parameter of the process
"typeName": "Edm.String",
"structuralProperty": 1
}
},
operationType = 0, // process is an action
operationName = "new_nameOfTheProcess"
}
};
collectionid was previously declared as in the following:
var collectionid = formContext.data.entity.getId();
The block of instructions to create the request works if I comment the block of code to get metadata, the values shown are the following (see comments):
var req = {};
req.entity = target; // Id: "{D4800847-7E4E-EB11-BF68-000D3A9C7067}" entityType: "collection"
req.EncyclopediaId = collectionid; // "{D4800847-7E4E-EB11-BF68-000D3A9C7067}"In the https://muìyOrganizationName.crm.dynamics.com/api/data/v9.1/$metadata I get the following info about the process/action:
<Action Name="myProcessName" IsBound="true">
<Parameter Name="entity" Type="mscrm.collection" Nullable="false"/>
<Parameter Name="CollectionId" Type="Edm.String" Unicode="false"/>
</Action>
...Which are the parameters (entity and Id) which I put inside the function to get metadata for the request object (see the first block of code above).
The process was created from Crm (from Processes -> new process) as in the following:
- Activate as Process
- Category: Action
- Entity: Collection
- Process Arguments:
Name : CollectionId
Type : String
Required : Optional
Direction : Input
The process is associated to a Custom Workflow Activity and the process argument CollectionId is bounded with the "collectionid" input parameter of the Custom Workflow Activity.