Created
May 30, 2019 19:42
-
-
Save sampoearas/f332122e3ec6aace585a5cb7c592d73c to your computer and use it in GitHub Desktop.
Relationship Search Property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Example: getting actual property from Part Goal relationship | |
System.Diagnostics.Debugger.Launch(); | |
Innovator inn = this.getInnovator(); | |
string actVal = ""; | |
//loop through returned collection from search | |
int counter = this.getItemCount(); | |
for(int i = 0; i < counter; i++){ | |
Item cItm = this.getItemByIndex(i); | |
cItm.fetchRelationships("Part Goal"); | |
Item relationships = cItm.getRelationships("Part Goal"); | |
int relCount = relationships.getItemCount(); | |
if (relCount < 1){ | |
cItm.setProperty("_reltest", "0"); | |
continue; | |
} | |
//need to decide which relationship you want to pull into grid? | |
//for first relationship: index = 0, for last: index = relCount - 1; | |
//for different relationship you will need code to select | |
Item relCol = relationships.getItemByIndex(0); | |
if (relCol == null){ | |
cItm.setProperty("_reltest", "0"); | |
continue; | |
} | |
//In this case, the relationship I have is null, so I just get the | |
//property off the relationship directly | |
actVal = relCol.getProperty("actual_value", "0"); | |
// If you have a normal relationship, this will pull the item | |
// Item relItm = relCol.getRelatedItem(); | |
// if (relItm == null){ | |
// cItm.setProperty("_reltest", "0"); | |
// continue; | |
// } | |
// actVal = relItm.getProperty("actual_value","0"); | |
cItm.setProperty("_reltest", actVal); | |
} | |
return this; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment