How do I rearrange the order of the Mentions in a Expression in VersionOne?
-
21-12-2019 - |
سؤال
I create Conversations for VersionOne Assets programatically using the Java API. When checking the conversations on the Web UI, I see that the assets mentioned are alphabetically arranged.
I would like to know if there is a way to override the default arrangement of the mentions. The target arrangement would be from Parent Asset -> Children.
Something like this:
- Default: Add reset Button (Task), Add submit Button (Task), Create UI (Story)
- Target: Create UI (Story), Add reset Button (Task), Add submit Button (Task)
Some things I tried:
- Looking at the Expression and Message metadata. Can't find anything related to either sorting or ordering.
Adding the Parent Asset 1st followed by the children:
// create a new conversation; this will act as the container of the expression (message) IAssetType conversationType = super.connection.metaModel.getAssetType(CONVERSATION); Asset conversationAsset = super.connection.services.createNew(conversationType, Oid.Null); super.connection.services.save(conversationAsset); // create a new expression containing the error message IAssetType expressionType = super.connection.metaModel.getAssetType(EXPRESSION); IAttributeDefinition expressionContentAttr = super.connection.metaModel.getAttributeDefinition(EXPRESSION_CONTENT); IAttributeDefinition expressionBelongsTo = super.connection.metaModel.getAttributeDefinition(EXPRESSION_BELONGS_TO); IAttributeDefinition expressionMentionsAttr = super.connection.metaModel.getAttributeDefinition(EXPRESSION_MENTIONS); Asset expressionAsset = super.connection.services.createNew(expressionType, Oid.Null); // set the message expressionAsset.setAttributeValue(expressionContentAttr, message); // add the message to the conversation expressionAsset.setAttributeValue(expressionBelongsTo, conversationAsset.oid); // set the context of the expression to belong to the VersionOne record Oid oid = Oid.fromToken(entity.oid, super.connection.metaModel); expressionAsset.addAttributeValue(expressionMentionsAttr, oid); // add mentions of other assets to the conversation for (String assetOid : assetOids) { Oid otherOid = Oid.fromToken(assetOid, super.connection.metaModel); expressionAsset.addAttributeValue(expressionMentionsAttr, otherOid); } super.connection.services.save(expressionAsset);
المحلول
If you check meta, you’ll see that Mentions is a multi-relation attribute. Unfortunately there is no way to set the order of items in the multi-relational attribute. Here’s the query for checking meta:
https://www14.v1host.com/v1sdktesting/meta.v1/Expression?xsl=api.xsl
The VersionOne UI has some logic that is setting the order of the Conversation mentions before displaying them.