Forum Discussion

reinke_patrick_smc_com's avatar
1 month ago
Solved

Refresh challenge of CommandBarSectionItem - Dropdown

Dear Aras community,

This is my first discussion thread, so please let me briefly introduce myself. I am the team manager of a small CAD/PLM team at a German company, and we recently managed to transition from a 20‑year‑old PLM system to a new one that all of you should know. 

We went live in December 2024, and little by little the Aras fan base in our company is growing. 

1. UseCase introduction

We handle many of our customizations ourselves, and we make extensive use of Aras Program Management. To track the work we do for our customers, everything needs to be linked to a customer project. That’s why we implemented a project_origin_id on every relevant business object (Part, Document, CAD, ECO, and other processes).

If a user is connected to a project, then anything they add (create) is automatically associated with that project. This is visible through relationships on the Project ItemType.

Users can connect themselves to a project via an action on the project called Assign Project Context.

Now, after more than one year of running the system in production, we want to improve this feature for changing the project context.

The idea is to have a dropdown list that displays every relevant and active Project item. When the user selects a project from the list, the OnClick method will attach the user to that project: (user.project_context_id = dropdown.value).

In the following screenshot you will see our implementation so far:

1: should refresh the list (2)

2: dropdown list with all relevant customer projects

3: opens the current selected project in a new tab

4: detach the user from the project and should refresh the list (2)

 

2. The challenge

The dropdown initialization and the OnClick method work as expected. However, we are facing a very frustrating challenge: the dropdown list needs to be refreshed whenever Button 1 or Button 4 is clicked. Unfortunately, we have not been able to implement this. At the moment, the dropdown list is only re‑rendered when the user logs in to Aras.

2.1 Include Events

We could identify that the Command Bar Section Item of the dropdown item has a configuration field which is called IncludeEvents. When you select an event named Update State than the dropdown list gets initiallized too often:

Perform a search on an random ItemType -> 4 x dropdown init gets started

Perform a refresh an an random ItemType form -> 2x dropdown init gets started

Switch tabs -> 2x dropdown init gets started

Commit a change on a random ItemType -> 2x dropdown init gets started

Because of performance issues we can not use IncludeEvents.

 

2.2 Initialiaze Dropdown

We did manage to initiallize the dropdown when other Buttons gets clicked. But the values and labels does not gets rendered in the dropdown item. 

Below you see our code example for Button 1 (refresh).

 

let dropdown = control.data.get("user_project_scope_list"); // Name = Name des CommandBarItem (DropdownListe)
if (!dropdown){
  aras.AlertError("The dropdown list was not found. This is an unknown error. Please contact your administrator.");
  return;
}

let newOptions = {value: "testID", label: "Project Test - Customer Test"};
dropdown.options = newOptions;
dropdown.value = "testID";

// TODO: INIT oder REFRESH, ODER RENDER

aras.AlertSuccess("The button has been refreshed.");

When I am debugging this method I see that in my local scope the object this: Window exist.

this.mainLayout.init seems to initialize the whole window but I only want to initialize my dropdown button.

 

3. The Question

So my questions is if anyone of you did manage to new render a Command Bar Section Item in the header of Aras which is found under Command Bar Section: com.aras.innovator.cui_default.mwh_header?

This would helps us a lot to gets this new feature Live in 3 weeks. I would appreciate every hint you can give me. 

Regards

Patrick

Ps.: Sry for formating ... I could not publish my very first discussion here without any disallowed html tags.

8 Replies

  • I made a short tests...this one worked!!! 

     

     

    • Hi Angela,

      this is fully functional. For me it is totally fine that you have to add content manually. It produces dublicate code, but it works :)

      Thank you very much and respect!

       

  • Ah ok, I think we need a bit more to make this work. I did a quick test. I added two buttons to the mwh header. One acts as regular button, the other one renders the content as text.

    I added following click Method to the button:

    const key = "ai_mytestlabel"; // Name of second CUI element
    const data = control.data.get(key);

    const updatedDataObject = Object.assign({}, data, {
       value: "testvalue",
       label:"testlabel"
    });

    control.data.set(key, updatedDataObject);
    control.render();

    When I click the button, the label is updated -->

    I think this concept could also work for a dropdown update, but I haven´t tried yet....

    • angela's avatar
      angela
      Catalyst II

      EDIT: Also my idea is probably not the perfect solution. Instead of reloading the dropdown, the concept would add the content manually. 

      But if it leads to the same results, users would not notice a difference. So it would be a sufficient workaround.

      I will try to render the dropdown content if I find some time. It´s an interesting use case!

       

  • Willkommen in der Aras Welt! Man erkennt die Deutschen an den technisch sehr detaillierten Beiträgen :). 

    "com.aras.innovator.cui_default.mwh_header" is the top header it self. As far as I remember the header is only rendered once at startup. When I remember things right there are also some "aria restrictions" that prevent any further re-rendering, but I am currently not sure in which context I saw this.

    More important:

    Which Innovator version is used?
    Where does the content for the Project list come from? Is this is classic "list" or ItemType data?

     

    • angela wrote:

      Willkommen in der Aras Welt! Man erkennt die Deutschen an den technisch sehr detaillierten Beiträgen :). 

      In der Kürze liegt die Würze. Nicht meine - unsere ? - Stärke. ;)

      Innovator version is Release 29. 
      The content from the project list comes from an AML query <Item type = 'Project' action ='get' ...> 

      angela wrote:

      "com.aras.innovator.cui_default.mwh_header" is the top header it self. As far as I remember the header is only rendered once at startup.

      When working with IncludeEvents, it is possible to trigger a rerender of the Command Bar Section Items every time an event from IncludeEvents is fired. Therefore, there must be a solution to force this behavior.

      I could also verify that if I run this command,

      this.mainLayout.init();

      (...) in my OnClick methods, than the dropdown button gets also refreshed. But I do not like that behaviour, because the whole window gets refreshed and other strange things happens.


      • angela's avatar
        angela
        Catalyst II

        Can you test following: 

        control.render();