Forum Discussion
Gopikrishnan
7 years agoIdeator I
Hi Zachary
Try below code and let me know if it works. You can use fetchRelationships of particular relationship name (here I used Part BOM). (Assuming that the property ts_complete_date and name is on Relationship Item type)
string log = string.Empty;
Innovator inn = this.getInnovator();
string today = DateTime.Now.ToString("yyyy/MM/dd");
DateTime nowdate = Convert.ToDateTime(today);
this.fetchRelationships("Part BOM");
Item thisrela= this.getRelationships("Part BOM");
for(int a = 0 ; a < thisrela.getItemCount(); a++)
{
Item tR = thisrela.getItemByIndex(a);
string updateday = Convert.ToDateTime(tR.getProperty("ts_complete_date")).ToString("yyyy/MM/dd");
DateTime update = Convert.ToDateTime(updateday);
if(DateTime.Compare(nowdate,update)>0)
{
log += tR.getProperty("name") +update+ "Error.";
}
}
if(!String.IsNullOrEmpty(log))
{
return inn.newError(log);
}
return this;
If the property ts_complete_date and name is on Part Item type then use below line after Item thisrela= this.getRelationships("Part BOM"); to get the related item property.
Item relItem = tR.getRelatedItem();
You can use like relItem.getProperty("ts_complete_date") to get the values.
Thanks
Gopikrishnan R
- Mavis5 years agoIdeator I
Hi Gopikrishnan,
I tried fetchrelationship
but tested that it only works in add mode(onbeforeadd)
When modifying the mode((onbeforeupdate)), it only records the initial data
And the relationship that I added in the modified mode he does not saveCan you please tell me why this is happening and how I can fix it?