Filtered Search

rated by 0 users
This post has 2 Replies | 4 Followers

Top 50 Contributor
Posts 33
Points 540
Anthony Posted: Thu, Feb 4 2010 7:54 AM

Hello,

I'm trying to code an action in order to filter a search dialog.

I have 2 itemstype :

Customer and contacts and incident_report.

in my incident report form, I have to pick a customer (item 'customer' property), next I have to select a contact (item 'contact' property).

When the search Dialog for contact pops up, I want to limit the contacts results to the selected customer.

In order to do that, I added an action on the 'contact' property of my incident_report itemtype. The action is 'OnSearchDialog' and contains the following code :

if (!inArgs.itemContext) {return;}

var ret_id=inArgs.itemContext.getAttribute("id");
var item = this.newItem("incident_report","get");
item.setProperty("id",ret_id);
var res = item.Apply();

var Filter=new Object();
Filter["customer"]={filterValue:res.getPropertyAttribute("customer","keyed_name"),isFilterFixed:true};
return Filter;

This code only works if I save my item after choosing the customer as I perform a database search in order to get the name of the customer according to the Item ID.

Is there a way not to save the item before choosing the contact ?

Thanks for your help.

Anthony

Anthony

  • | Post Points: 20
Top 25 Contributor
Posts 56
Points 730
Harsha replied on Tue, Sep 11 2012 3:02 AM

Hi Anthony,

       I' m trying to set filtered search but not able do that. In my itemtype's form I have a dropdown selection , and one 'Item' field. Based on the dropdown selection,'Item' field should return the filtered values. I' m using the following code which is not working properly.

var thisItem = document.thisItem;
var department = thisItem.getProperty("department");
if(department=="Design")
{
var Filter = new Object();
Filter["organization_identity_id"]={filterValue:"Design", isFilterFixed:true};
return Filter;
}

'department' is my Itemtype's property.

And I also need to do filter the items before saving the form. Have you got any solution to this problem?

Please help me.

 

Thank You,

Harsha

  • | Post Points: 20
Top 10 Contributor
Posts 490
Points 7,205
Brian Pye replied on Thu, Sep 20 2012 9:45 AM

Hi Harsha,

The code looks about right. Have you tried debugging it to make sure that the context item is what you expect and that the "department" property is being found correctly?

You could also use the inArgs.contextItem.getProperty(...) which should have the correct context item.

I'm pretty sure you can only use the filtered item browser on saved data. The search dialog after all only searches the database entries.

Hope this helps.

Brian.

  • | Post Points: 5
Page 1 of 1 (3 items) | RSS