Skip to content

Instantly share code, notes, and snippets.

@sampoearas
Created May 30, 2019 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sampoearas/f332122e3ec6aace585a5cb7c592d73c to your computer and use it in GitHub Desktop.
Save sampoearas/f332122e3ec6aace585a5cb7c592d73c to your computer and use it in GitHub Desktop.
Relationship Search Property
//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