hardik039 - Tuesday, April 6, 2010 9:37 AM:
Hi All,
Is it possible to set criteria in Search Dialog, when we click on “New relationship” command in relationship grid ?
please give me ur suggessions..
Regards,
Hardik
tstickel - Tuesday, April 6, 2010 2:21 PM:
Hi
Yes, this can be done. One way to do this that may meet your requirements is:
1. Create an JavaScript (client) method similar to:
var myInnovator = this.getInnovator();
var parentItem = myInnovator.newItem("Part");
parentItem.loadAML(inArgs.itemContext.xml);
if (parentItem.getProperty("item_number") == "TestAssm")
{return "/Part/Component/%";}
The inArgs.itemContext object holds the AML for the item that is displayed in the top of the form where the new relationship action was invoked. In this case I was on the Part form. You can see the test where I determine if the parent item has item_number = "TestAssm". If it does then I will return "/Part/Component/%" as the search criteria. In this case the search criteria will be for the classification property, see next step for why this occurs
2. In the Innovator Programmer's Guide. look for a section titled, "Cell Events". It explains how to associate a method with certain grid cell events, such as onEditStart, onEditFinish, and Default Search. So what I did was to link the method above to the "Default Search" event on the Part ItemType classification property. You do this by selecting the classification property on the Part Item Type definition form and right-click->"View Properties". This will bring up the Property Form for the classification property and you can define the link to the method there.
3. Note that the "Cell Events" section in the Programmer's Guide states that your method will be called with 5 arguments (e.g. relationshipID, relatedID, etc). Using a script debugger I found that my method was not receiving these 5 arguements, but did receive 2 arguments (inDom and inArgs). By looking at the contents of inArgs I found the itemContext.xml property that was needed by my method. Also, the onSearchDialog cell event may also be useful, but I did not try it.
hardik039 - Tuesday, April 13, 2010 4:45 AM:
Hi Terry
This was very useful information for me ...thanks
That u have posted is for search dialog for properties value, means if i have one attribute that has 'Item' as Datatype than its working.
" But, i want to set a criteria on new relationship dialog, which is used for add new related item "
If any other idea than plz suggest.
Thanks Again
Hardik Mehta
tstickel - Tuesday, April 13, 2010 10:01 AM:
Here is a screen shot of the Part Form, with the Bom Relationship tab.
Using the code example I described in my previous response, if you click on the "New Relationship" icon, with Pick Related set, then the following Search Relationship dialog will appear for adding a new related item.
As you can see the criteria, "/Part/Component/%" has been set for the Type property. If that is not what you are looking for then I don't understand your requirement.

