I have a VBScript function called constructPath which appears in the row equation for a field called Kind as:
=constructPath(item, itemparent, itemgparent)
The script of the function is:
Function constructPath(item, itemparent, itemgparent)
' This function creates a Windows-like hierarchical "path".
' Ideally, this function would be coded recursively, but I cannot find a way to make InfoQube return the parent of a given item in code.
' As coded, it only permits a three level hierarchy, grandparent, parent and item.
Dim fullPath
If itemparent = "" Then ' Item is a TLI
fullPath = "\\" + ftrim(item) + "\\" 'Note that it's necessary to use "\\" to assign a single backslash, because backslash escapes the next character in VBScript.
Else
if itemgparent = "" Then
fullPath = "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
else
' There is a grandparent:
fullPath = "\\" + ftrim(itemgparent) + "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
End If
End if
constructPath = fullPath
End Function
' This function creates a Windows-like hierarchical "path".
' Ideally, this function would be coded recursively, but I cannot find a way to make InfoQube return the parent of a given item in code.
' As coded, it only permits a three level hierarchy, grandparent, parent and item.
Dim fullPath
If itemparent = "" Then ' Item is a TLI
fullPath = "\\" + ftrim(item) + "\\" 'Note that it's necessary to use "\\" to assign a single backslash, because backslash escapes the next character in VBScript.
Else
if itemgparent = "" Then
fullPath = "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
else
' There is a grandparent:
fullPath = "\\" + ftrim(itemgparent) + "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
End If
End if
constructPath = fullPath
End Function
This works, in that Kind is set to values such as
\InfoMgt\WYSOCS\member\ |
for an item whose value is member and whose parent is WYSOCS and whose grandparent is InfoMgt.
But values are assigned for Kind for every new item, regardless of which grid it is created in.
As far as I can tell, there is no way to make code determine whether or not an item is present in a particular grid. So I cannot make the code dependent on the fact that this item appears in a particular grid.
Can anyone think of a way to assign a value to kind automatically but only for certain items?
Thank you!
Can anyone think of a way to assign a value to kind automatically but only for certain items?
Thank you!
Mark Gregory
EDIT:
Here is an answer I can give to my own question; I would still welcome better approaches and there is something here that I don't fully understand.
What I have done is to create a yes/no field called IsKind; I have given it the default value false. I show this in a grid based on item. For all items which I want to be considered as being of type Kind, I tick IsKind. I have amended the code of the function shown above, so that it now reads:
What I have done is to create a yes/no field called IsKind; I have given it the default value false. I show this in a grid based on item. For all items which I want to be considered as being of type Kind, I tick IsKind. I have amended the code of the function shown above, so that it now reads:
Function constructPath(item, itemparent, itemgparent, IsKind)
' This function creates a Windows-like hierarchical "path".
' Ideally, this function would be coded recursively, but I cannot find a way to make InfoQube return the parent of a given item in code.
' As coded, it only permits a three level hierarchy, grandparent, parent and item.
' The additional parameter IsKind must be set true for a path to be constructed. If it is false, a null path is constructed.
Dim fullPath
If IsKind Then
If itemparent = "" Then
fullPath = "\\" + ftrim(item) + "\\" 'Note that it's necessary to use "\\" to assign a single backslash, because backslash escapes the next character in VBScript.
Else
if itemgparent = "" Then
fullPath = "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
else
' There is a grandparent:
fullPath = "\\" + ftrim(itemgparent) + "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
End If
End if
else
fullPath = ""
end if
constructPath = fullPath
End Function
' This function creates a Windows-like hierarchical "path".
' Ideally, this function would be coded recursively, but I cannot find a way to make InfoQube return the parent of a given item in code.
' As coded, it only permits a three level hierarchy, grandparent, parent and item.
' The additional parameter IsKind must be set true for a path to be constructed. If it is false, a null path is constructed.
Dim fullPath
If IsKind Then
If itemparent = "" Then
fullPath = "\\" + ftrim(item) + "\\" 'Note that it's necessary to use "\\" to assign a single backslash, because backslash escapes the next character in VBScript.
Else
if itemgparent = "" Then
fullPath = "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
else
' There is a grandparent:
fullPath = "\\" + ftrim(itemgparent) + "\\" + ftrim(itemparent) + "\\" + ftrim(item) + "\\"
End If
End if
else
fullPath = ""
end if
constructPath = fullPath
End Function
One thing I do not fully understand is this. In the manage grids dialogue, for the grid whose name is kind, I have attempted, under the data properties, to "auto assign the following fields (comma separated list):" IsKind. This does not seem to do anything at all. If I create a new item in the kind grid, I have manually to set IsKind for the new item – I would have hoped that this would automatically have been set true. Am I misunderstanding something here? Does the default false value for the field override the true value that I had hoped auto assignment would give me?
Comments