How to replace default App-Open with Customization

Yep.

OK, I think I know where we’re headed.

I just created a new button then add the widgets that are used in the base event. Here is an idea from start activity. You need to modify this a the main MES screen. You will see where you type in the layer that you want. Look at the info on the default button to create the new one. The base is locked.

Thanks Mike,
This is what I was expecting, but hoping to avoid.

I will now weigh this against @klincecum’s idea and see where I end up.

Doc Brown Fly GIF by Back to the Future Trilogy

You just need the very first part of that post.

Give me a sec, I had another thread with just forcing a layer, which is all you need.

An easier option you can do is just copy the event and then call that copied event of the EndActivity from the new button click with EventNext and call the new copied event. In the new event just modify the layer for your customization.

I like people to play with my code, but I also like this solution :slight_smile:

I think that with the BPM solution I can get Kinetic to behave the way it should by default (in my opinion)…

I already assigned the Customization Layer to the End Activity menu item in Menu Maintenance, and I would expect it to honor that, the same way it does for the main MES screen. Just because it happens to be a slide-out triggered by a button event, shouldn’t mean it ignores the customization layer defined on the menu item.

In the BPM I can look up the menu item in the database, get it’s Kinetic Layer property, and apply it.

Just remember, anything that request that app, even application studio, will pull that layer
with it when that BPM is enabled.

Interesting, I did not see that at first using the BPM to set it. I like that also. I meant the second was easier than my first suggestion.

Yes, I was hoping to find some metadata in the dataset to selectively apply this. I’ll give it a try, I may end up going with the duplicated event approach in Application Studio.

Maybe someone with a few more brain cells will pop in later with an easier and less hacky solution.

Now that I think about it, we should be able to restrict it to just the one place called from.
I think I already did that, gotta check who called it.

If you don’t figure it out first, I’ll look at that later. Gotta go get about 4 inches of mop cut off
my head before Insights.

I’m getting somewhere…

if (request.id == "Erp.UI.EndActivityEntry" && request.properties.mode != "AppStudio" && request.properties.additionalContext.ContainsKey("menuId"))

The mop is gone, but it looks like I’m not needed. :tada:

It worked!
Celebrate Doc Brown GIF by Back to the Future Trilogy

Incredibly, it worked on the first attempt.

/// The following BPM script applies Kinetic UI layers to a MetaFX GetApp request.
/// Business Object: Ice.Lib.MetaFX
/// Method: GetApp
/// BPM Type: Pre-Processing

// Kinetic UI App/Resource Name
var requestID = "Erp.UI.EndActivityEntry";

// Only modify the request if:
// It matches the desired Request ID
// It is not in 'AppStudio' mode
// It contains a 'menuId' property. This is required to look up the Menu item from the database.
if (request.id == "Erp.UI.EndActivityEntry" && request.properties.mode != "AppStudio" && request.properties.additionalContext.ContainsKey("menuId"))
{
  // Get the Menu ID from the request.
  var menuID = (string)request.properties.additionalContext["menuId"];
  
  // Get the existing Layer Names from the request. Convert to a list so we can add items.
  var layers = request.properties.layers.ToList();

  // Get the Menu Item from the database, preferring the company-specific menu item.
  var menuItem = Db.Menu.Where(x => x.MenuID == menuID).OrderByDescending(x => x.Company == callContextClient.CurrentCompany).FirstOrDefault();
  
  if (menuItem != null)
  {
    // Get the URL parameters from the Menu Item
    var parameters = menuItem.WebResourceURL.Split('?')[1].Split('&');
    
    // Get the Layer Names parameter, and get an array of layer names.
    var layerNamesParameter = parameters.FirstOrDefault(x => x.StartsWith("layerNames"));
    var layerNames = layerNamesParameter?.Split('=')[1].Split(',');
    
    // Loop through the layer names and if it does not already exist in the list, add it.
    foreach (var layerName in layerNames)
    {
      if (!layers.Contains(layerName))
      {
        layers.Add(layerName);
      }
    }
    
    // Replace the layers in the request with our new list
    request.properties.layers = layers.ToArray();
  }
}

Thank you @klincecum for pointing me in the right direction.

1 Like

ehhh… :dumpster_fire:

I likes the way you code.
Noice Thats Nice GIF