Forum Discussion

Former_Member's avatar
Former_Member
Accelerator III
8 years ago

Workflow Map and dependent relationship

I am trying to validate the proof-of-concept for a parser designed for automated integration of process models. I would like to use a server-side method in C#. Creating new workflow maps works so far. Unfortunately, I already fail in a basic functionality. I want to set an activity template as a child relation to a workflow map. Here is my previous code:
Innovator inn = this.getInnovator(); Item workflow = inn.getItemById("Workflow Map","AAE3732B971C4397917669FC46576DC8"); string id = getNewID(); // Create new instance of Relationship ItemType Item newWMA = inn.newItem("Workflow Map Activity","add"); newWMA.setProperty("source_id", "AAE3732B971C4397917669FC46576DC8"); Item relatedItem = newItem("Activity Template","add"); newWMA.setRelatedItem(relatedItem); workflow.addRelationship(newWMA); relatedItem.apply(); return this;
Unfortunately the execution always results in the following error code:
Dependent Activity Template cannot be create: source item not found.
The ItemType Activity Template is set to "dependent". I assume that the error is related to this. Many thanks for the help in advance. Greetings Rik

5 Replies

  • Hello, Instead of relatedItem.apply();, try using newWMA.apply();. It looks like the issue you're running into is that you're trying to add the Activity Template before it's parent Workflow Map Activity has been created. Chris
    Christopher Gillis Aras Labs Software Engineer
  • Dear Christopher, many thanks for the quick answer! The proposed solution works perfectly. I have another question, which also refers to the relationship structure of the data in the context of process modeling. Unfortunately I don't understand how the relationship between two Activity Templates is defined using Workflow Map Path. I have tried to show my current findings in the illustration. P1 Where is defined on which Activity Template a path points to? In my opinion it would be logical that this is referenced via the "related_id"-Property of the Workflow Map Path instance (Item Type). In a query, however, this value is always null. Also the Related Item Type of the Workflow Map Path is not defined. P2 I hope I can explain my problem properly. Many thanks and greetings Rik
  • Hi Rik, The data you're looking for is actually stored in the related_id property of the Workflow Map Path. The Workflow Map Path is a null RelationshipType, but if you inspect the properties on the ItemType, you'll see that the related_id does exist. I'm not personally sure of why this is the case. If I had to make an assumption, I'd say that this was for legacy purposes as the Workflow Map is one of the older ItemTypes in the standard Innovator platform. Chris
    Christopher Gillis Aras Labs Software Engineer
  • Hi Christopher, I found the property "related_id". I also found the error why I suspected that this variable is just not set to a value. For testing I often use the query capabilities of the Rest API. In this case I have not yet found a way to query the "related_id". Under certain circumstances this is related to the null RelationshipType. Or do I make a mistake with the query?! P3 For the documentation. The following method (C#) works and returns the correct relation
    Innovator inn = this.getInnovator(); Item process = inn.getItemById("Activity Template", "B9F2FE5B576546B18846A39AD854C2CF"); process.fetchRelationships("Workflow Map Path"); Item qryItem = inn.newItem("Workflow Map Path","get"); qryItem.setProperty("source_id", process.getProperty("id")); qryItem.setPropertyCondition("source_id", "eq"); Item results = qryItem.apply(); Item item = results.getItemByIndex(0); string output = "\r\n" + "Workflow Map Path ID: " + item.getProperty("id") + "\r\n"; output += "source_id: " + item.getProperty("source_id") + "\r\n"; output += "related_id: " + item.getProperty("related_id") + "\r\n"; return inn.newResult(output);
    <Result> Workflow Map Path ID: 654FF9665F2F415683722C6AA698A1DE source_id: B9F2FE5B576546B18846A39AD854C2CF related_id: 414750EF9F62450A87621429F7B7B339 </Result>
    When querying via Rest-API, I unfortunately don't get the desired success. Directly I can only query the "source_id"-Property. The Rest-Call
    plmserver/.../Workflow Map Path('654FF9665F2F415683722C6AA698A1DE')
    Results in the return of structured data in JSON format. However, the properties are not listed here.
    { "@odata.context": "plmserver/.../$metadata Map Path/$entity", "authentication": "none", "behavior": "float", "created_on": "2018-10-09T23:04:11", "generation": "1", "id": "654FF9665F2F415683722C6AA698A1DE", "is_current": "1", "is_default": "0", "is_override": "0", "is_released": "0", "keyed_name": "654FF9665F2F415683722C6AA698A1DE", "major_rev": "A", "modified_on": "2018-10-09T23:04:11", "name": "TestPath", "new_version": "1", "not_lockable": "0", "segments": "", "sort_order": "128", "x": "0", "y": "0" }
    The source id can be accessed by extending the query.
    plmserver/.../id
    { "@odata.context": "plmserver/.../$metadata Map Path('654FF9665F2F415683722C6AA698A1DE')/source_id/id", "value": "B9F2FE5B576546B18846A39AD854C2CF" }
    This procedure does not work with the related id.
    plmserver/.../id
    { { "error": { "code": "BadRequest", "message": "Value cannot be null.\r\nParameter name: criteria" } }
    The only possibility I have found is this query, but then the data is no longer structured.
    plmserver/.../$value
    This is not critical for my use case. But maybe this is interesting for future applications. Thanks again Christopher for your quick help. Greetings Rik
  • Hi Rik, There doesn't appear to be an easy way through the REST API alone to get the id of an Item property that does not have a data source. I'll file this internally to be added in a future release. I understand that this functionality isn't critical for your use case, but I did discover a solution that would allow you to get the ID as expected. You can create a server method with code like the sample below.
    string wmpId = this.getProperty("wmp_id");
    Item wmp = this.newItem("Workflow Map Path", "get");
    wmp.setID(wmpId);
    return wmp.apply();
    You can then call this method through the REST API and pass in the ID of the Workflow Map Path you want to get like:
    POST host/.../method.GetWorkflowMapPath
    {
    "@odata.type": "host/.../$metadata,
    "wmp_id": "654FF9665F2F415683722C6AA698A1DE"
    }
    The body of the response should contain the related_id as expected. Chris
    Christopher Gillis Aras Labs Software Engineer