Forum Discussion

AngelaIp's avatar
AngelaIp
Catalyst II
6 months ago

How can I choose a specific Search Mode when opening a Search Dialog via Method?

Hi community,

I use following code to open a classic Part search dialog. 

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:e11e18e7-06f2-4dd3-8697-899cd4f649c4:type=javascript&text=const%20param%20%3D%20%7B%0A%20%20%20%20aras%3A%20aras%2C%20%0A%20%20%20%20type%3A%20%27SearchDialog%27%2C%0A%20%20%20%20dialogWidth%3A%201200%2C%0A%09dialogHeight%3A%20500%2C%0A%20%20%20%20itemtypeName%3A%20%27Part%27%2C%20%20%0A%20%20%20%20defaultSearchMode%3A%20%22AML%22%2C%20%20%2F%2F%20%3F%3F%3F%3F%3F%3F%0A%7D%3B%0A%0Aconst%20topWnd%20%3D%20aras.getMostTopWindowWithAras%28%29%3B%0AtopWnd.ArasModules.MaximazableDialog.show%28%27iframe%27%2C%20param%29.promise.then%28callback%29%3B]

Is it possible to pre-select the used search mode?

Typically the "Simple" (Einfach) search mode is preselected. I have an additional custom search mode that is similar to Simple, but allows users to search for all generations of a Part.

In my use case user shall be able to search and select previous Part versions. So it would be convenient if my custom search mode would be selected automatically when the search dialog is opened. 

I guess this is currently not possible. But maybe somebody has an idea?

Thanks!

Angela

5 Replies

  • Hi Angela,

    I usually try to use 'Default Search' option on item_number property


    Which result in search window like below:


    Not sure this helps with your requirement

    • AngelaIp's avatar
      AngelaIp
      Catalyst II

      Thanks for your fast help! I have to admit, you answered my question very accurate and precisely! Unfortunately, my screenshot was a bit misleading. Here's what I'm was actually looking for:

      I don´t think it´s possible to pre-select the search mode in the dropdown. But - good news: I think it was a bad idea from the start and I currently don´t need a solution anymore!

      The use case was related to a custom change management process. For a very specific scenario users should select only previous item revisions.

      But now I will just start from the latest item and than automatically collect previous versions and let user decide if they want to do an update/float of the items. There are more than one previous item versions anyway.

      The whole idea is related to this post to achieve a controlled float behavior:  link 

  • Thanks for the update — your new approach sounds like a smart workaround! Starting from the latest item and programmatically gathering previous versions makes sense, especially when multiple revisions are involved. It keeps the UI cleaner and avoids relying on dropdown behavior that’s hard to control. animal rampage 3d

    I’m also curious about your controlled float strategy — are you planning to log user decisions when they choose to float or not? Would love to hear more about how you’re implementing that logic.

  • A easy way to search for all generations is to unhide the generation property in the ItemType.
    Then you are able to search with * in the generation property for all generations.

     

  • I did something similar to enable simple search mode for all relationships grids. I want to belive my example will be usefull to you to find your CUI location and update similar methods:

     

    I've tried to not change the code tree files and perform changes only in the innovator database.
    The easiest way to achieve such behavior is to use CUI feature and CUI items. More detailed infomration about this feature and examples you can find in the official documentation:
    Aras Innovator XX - Configurable User Interface Administrator Guide.pdf


    You will have possibility to override the behavior for specific items, itemTypes or globally for all entire application
    You will have possibility to override the behavior for specific identities for different level of application described above.

    I will use global presentation to change the behaviour for all items in the innovator
    I know that my control is placed in ItemView.Rel-shipCommandBar section:


    I will change DropDown CUI item for searchMode:


    I will change InitHandler Method to add logic during initialization force search mode for all relship grids:


    The comparison view what I've added to init method(cui_common_searchmode_init):


    The method code is below:
    const arasInstance = window.aras;
    const redlineViewController = window.redlineController;
    const shouldSearchDialogEventBeInvoked = window.searchContainer._onSearchDialogEventMustBeInvoked();
    const initProperties = {
    value: currentSearchMode && currentSearchMode.id,
    disabled: (redlineViewController && redlineViewController.isRedlineActive) || shouldSearchDialogEventBeInvoked
    };
    if (!target.options || !target.options.length) {
    const searchModes = arasInstance.getSearchModes() || [];
    initProperties.options = searchModes.map(function(currentMode) {
    return {
    label: arasInstance.getItemProperty(currentMode, 'label') || arasInstance.getItemProperty(currentMode, 'name'),
    value: arasInstance.getItemProperty(currentMode, 'id')
    };
    });
    }
    if (redlineViewController) { //use this condition to detect that we are curently execute this method for relatioship grid actually any other better condition can be used
    const searchContainer = window.searchContainer;
    const searchModeId = 'BD84BCA3EC064D77BF3772A9D93308B6'; // id if simple search mode
    if (searchContainer && searchModeId) {
    const gridControl = searchContainer.grid;
    searchContainer.showSearchMode(searchModeId);
    if (gridControl.RefreshHeight) {
    gridControl.RefreshHeight();
    }
    }}
    return initProperties;