...
And looking at how "Devices" are linked to "Hosts"
Take a note that the attribute we are interested in has and ID = 79. We will need this later.
Now we need to check how the REST API call looks like for the particular device to see how the data looks like. As integration between ConfiForms and Riada's Insight is done through the REST APIs (https://documentation.riada.io/display/INSSERV/Version+1.0+documentation)
We will call the following REST API service
...
Expand | ||
---|---|---|
| ||
|
This is important bits that we need to get from the example JSON
We need to look at attribute with ID 79 and check how the objects are linked, which attribute is responsible and how the data is stored
Code Block |
---|
"objectTypeAttributeId": 79,
"objectAttributeValues": [
{
"referencedObject": {
"id": 2,
"label": "another host",
"objectKey": "ITS-2",
"avatar": {
"url16": "http://vertuna-dev:2990/jira/rest/insight/1.0/objecttype/2/icon.png?size=16&uuid=6a49b7fe-b69d-4e2a-a74a-d23cf3e84eb7",
"url48": "http://vertuna-dev:2990/jira/rest/insight/1.0/objecttype/2/icon.png?size=48&uuid=6a49b7fe-b69d-4e2a-a74a-d23cf3e84eb7",
"url72": "http://vertuna-dev:2990/jira/rest/insight/1.0/objecttype/2/icon.png?size=72&uuid=6a49b7fe-b69d-4e2a-a74a-d23cf3e84eb7",
"url144": "http://vertuna-dev:2990/jira/rest/insight/1.0/objecttype/2/icon.png?size=144&uuid=6a49b7fe-b69d-4e2a-a74a-d23cf3e84eb7",
"url288": "http://vertuna-dev:2990/jira/rest/insight/1.0/objecttype/2/icon.png?size=288&uuid=6a49b7fe-b69d-4e2a-a74a-d23cf3e84eb7",
"objectId": 2
},
"objectType": {
"id": 2,
"name": "Host",
"type": 0,
"description": "",
"icon": {
"id": 153,
"name": "Host",
"url16": "http://vertuna-dev:2990/jira/rest/insight/1.0/objecttype/2/icon.png?size=16&inherited=false&abstract=false&time=1572434653734",
"url48": "http://vertuna-dev:2990/jira/rest/insight/1.0/objecttype/2/icon.png?size=48&inherited=false&abstract=false&time=1572434653734"
},
"position": 0,
"created": "30/Oct/19 1:24 PM",
"updated": "30/Oct/19 1:24 PM",
"objectCount": 0,
"parentObjectTypeId": 1,
"objectSchemaId": 1,
"inherited": false,
"abstractObjectType": false,
"parentObjectTypeInherited": false
},
"created": "30/Oct/19 1:36 PM",
"updated": "30/Oct/19 1:36 PM",
"hasAvatar": false,
"timestamp": 1572435390277,
"_links": {
"self": "http://vertuna-dev:2990/jira/secure/ShowObject.jspa?id=2"
},
"name": "another host"
},
"displayValue": "another host"
}
], |
This will tell us the the link is stored in the "referencedObject" node, under "id" attribute and this will help us to make a correct expression for the filtering in our ConfiForms Rules for Field Definition macro configuration
Where actual expression for the filter looks like this:
Code Block |
---|
devices.attributes.objectTypeAttribute(objectTypeAttributeId=79).objectAttributeValues.referencedObject.id:[entry.hosts.id] |
Which reads as - filter "devices" by referencedObject's id property whcih is available under attribute number 79 and check it against the current selection in the "hosts" field
Now you have a fully working example of a ConfiForms form that has 2 dependent Insight fields.
Full code for the form is here:
Code Block |
---|
<p class="auto-cursor-target">
<br/>
</p><ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="2a72b451-7d52-4802-83c0-320f7017dc38">
<ac:parameter ac:name="formName">myform1</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1"
ac:macro-id="b868bdae-a52b-4008-9187-46ebdbf105d3">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1"
ac:macro-id="d8db23fc-ad9c-46db-9611-263cd38af5f3">
<ac:parameter ac:name="fieldName">hosts</ac:parameter>
<ac:parameter ac:name="fieldLabel">Hosts</ac:parameter>
<ac:parameter ac:name="values">2</ac:parameter>
<ac:parameter ac:name="type">insightselect</ac:parameter>
<ac:parameter ac:name="separator">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1"
ac:macro-id="d343a87b-a122-4d43-b878-9f1be81ca55e">
<ac:parameter ac:name="fieldName">devices</ac:parameter>
<ac:parameter ac:name="fieldLabel">Devices</ac:parameter>
<ac:parameter ac:name="values">3</ac:parameter>
<ac:parameter ac:name="type">insightselect</ac:parameter>
<ac:parameter ac:name="separator">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
<p>
<ac:structured-macro ac:name="confiform-field-definition-rules" ac:schema-version="1"
ac:macro-id="e75fc6ef-9a1d-42f4-b5eb-07c2f96c4d3f">
<ac:parameter ac:name="condition">!hosts:[empty]</ac:parameter>
<ac:parameter ac:name="fieldName">devices</ac:parameter>
<ac:parameter ac:name="values">
devices.attributes.objectTypeAttribute(objectTypeAttributeId=79).objectAttributeValues.referencedObject.id:[entry.hosts.id]
</ac:parameter>
<ac:parameter ac:name="action">Apply Filter on a field</ac:parameter>
<ac:parameter ac:name="actionFieldName">hosts</ac:parameter>
</ac:structured-macro>
</p>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p> |