This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Set filter in Search Dialog Box

vishal_trivedi - Monday, November 29, 2010 6:15 AM:

Hi All,

-- I am giving have an Item type called "School".

-- It has relationship with "Document".

-- I want to restrict user to access some document at the time of adding it from the instance of "School".

-- At the time of adding "School" we can see "Document" as a tab and if we are adding a document over there it will show a popup (Search Dialog). 

   So, here I want to restrict the user to access some document.

   Please reply as quick as possible. It's very urgent.

-- Vishal



Brian - Tuesday, November 30, 2010 5:29 AM:

Hi Vishal,

What you are trying to do is called a "Filtered Item Browser"

Edit the Relationship Item for the relationship between the "School" and the "Document' ( will assume School Document is the name).

 So go to the Item Type TOC option. Look for "School Document" and edit

Select "Related_id" property. Right click and select "properties"

Create a Javascript Method called say "RestrictedDocuments" and set it to trigger on the "onSearchDialog"

Method should be something like this:

 

// Called from related_id grid cell onSearchDialog event of School Document

// Relationship item type.

// It is only valid for documents with the following criteria to be selected into an

// Status is "released"

// There is no "customer_response" item attached to the Document (these are custom properties of a document that I have added)

// The flag "customer_approval_required" must be checked (true)

//

 

// Use a filtered item browser

if (!inArgs.itemContext)

    {return;}

 

var ret_cat_id=inArgs.itemContext.getAttribute("id");

var qry1 = this.newItem("Document", "get");

qry1.setAttribute("where", "[Document].state='Released' AND [Document].customer_approval_required='1' AND ([Document].customer_response IS NULL)");

 

var res = qry1.apply();

 

if (res.isEmpty())

{

    inArgs.QryItem.item.setAttribute("idlist","");

    return ("");

}

if (res.isError()) {return res;}

var count=res.getItemCount();

var idarray=new Array();

for (i=0;i<count;i++){

  var item=res.getItemByIndex(i);

  idarray[i]=item.getID();

  var idlist=idarray.join(",");

}

inArgs.QryItem.item.setAttribute("idlist",idlist);

return("");

 

This will return a list of items that fit the criteria and will only allow the user to select one of these values.

 

Hope this helps.

Brian.