Hello
as per title - how can we set the filter for search dialog in javascript
Hello
as per title - how can we set the filter for search dialog in javascript
Hi JWT007,
I want to join your question! I actually found some solution, but it doesn´t work reliable. In my case I face the problem, that end users can call the Action/Dialog from the grid but also from the Form. This variant just works when a called from Form:
// parent.thisItem -> only available when Action was triggered from Form
if (parent.thisItem !== undefined){
var state = parent.thisItem.getProperty("state","*");
// Set filter in an onSearchDialog event
var Filter = {};
Filter["state"] = { filterValue: state, isFilterFixed: true };
return Filter;
}
This was my first thought as well. Rather than passing the data to the search dialog event, simply look it up from the parent window that opens the search dialog.
To JWT007's use case, the user is prompted to select some target life cycle state. Perhaps you could clarify how this is done. One way to do this that would make it agnostic to where this action is called from would be to direct the user to an intermediate dialog that would contain one field that lets them choose the target life cycle state and one button that launches the search dialog. From the context of the search dialog event, the parent window in this use case would be the intermediate dialog, so you could look up the value of the target life cycle that the user specified and then use that in your filter just as Angela's code does above.
Chris
Hello Christopher, thanks for your response.
Since I had no luck with the modal SearchDialog, I ended up creating a Form Dialog for this, which I then lookup and populate it with just enough information to satisfy the OnSearchDialog criteria for the Item field on that form.
To clarify the selection of the target life-cycle state, this is also done using a form populated that is handed the response of a server method (the lifecycle information from a SQL query) and in the OnLoad this information is moved from the context into a drop-down field on the form. I obtained the result from this dialog on "OK" and used it to ultimately feed the second custom dialog.
My problem was with only opening a search dialog without an intermediate form. Here it would be a great addition to pass some kind of context which could then be queried in the OnSearchDialog linked method (without using an intermediate form).
Cheers, Jeff
1- Assign param.parentItem to the current item
var param = {
aras: top.aras,
type: 'SearchDialog',
dialogWidth: 1000,
dialogHeight: 450,
itemtypeName: 'Part',
sourceItemTypeName: 'a_IMDS Part',
sourcePropertyName: 'related_id',
multiselect : false,
parentItem : thisItem
};
2- Modify core code ..Innovator\Client\javascript\search_container.js
Add the below line to "this._fireSearchEvents = function (searchAML) {"
methodArgs.parentItem = searchArguments.parentItem;
3- In the filter method...
var Filter = {};
var parentItem = inArgs.parentItem;