locked
Custom form for Windows Computer RRS feed

  • Question

  • Hi all,

    we have created a new Class called "Applicationset" representing an set of applications that is related to a windows computer. Therefore we also introduced the relationship "WindowsComputerHasApplicationset". 

    That all works well but now we want to have a custom form to display all Applicationsets attached to a specific windows computer. We have build a custom form and I have created the type projection. The custom form is targeted to that new type projection. Target of the type projection is the class "windows computer". 

    When I create a view with the Type projection as the target, it still shows up the built in windows computer form. 

    When I use any other custom class in the type projection as the target, the custom form shows up. 

    So I think the problem is that the windows computer class ships with its own form.

    So my question is how can I display my own custom form for windows computers, but only when open it from a custom view targeted to my type projection. 

    Is this possible ? Or do I need to create a custom class that is derived  from Windows Computer Class ? That worked well in my tests, but I think that would be bad design, as I don't add any properties to the class and I would only use it to bring up the custom form. Another issue then is that I need to build the relationship between the derived custom class and the applicationset. I don't like that design and it would add unnecessary overhead.

    thanks 


    Tuesday, April 15, 2014 2:18 PM

Answers

  • There can be only one form for each class. you'll want to either replace or edit the existing computer form. 

    • Proposed as answer by BuchatechMVP Thursday, April 17, 2014 5:14 AM
    • Marked as answer by Sebastian Zolg Monday, April 21, 2014 5:46 PM
    Tuesday, April 15, 2014 4:19 PM
  • Forms can be extended by only one FormExtension (and therefore one MP), but you can re-open and re-edit that extension multiple times. 

    typically, when i'm extending forms, i'll create a new MP in the authoring tool, or Visual studio for the braver, and store only that extension in that MP. if i need to change that FormEntension, then you can go back to your unsealed source file, edit it in the authoring tool to make your changes, re-seal it and re-import it, and other bits of Service Manager that depend on that form extension will be none the wiser. 

    • Proposed as answer by BuchatechMVP Thursday, April 17, 2014 5:14 AM
    • Marked as answer by Sebastian Zolg Monday, April 21, 2014 5:45 PM
    Wednesday, April 16, 2014 9:16 PM
  • Hi Thomas,

    I've made a decision. I've extended the Windows Computer Form. I wrote a user control in VS having a few controls and a lot of logic in Code Behind. Then I added the user control to a new tab item called "Application Management" which I added with a few lines of XML to the base windows computer form.

    Worked like charm and I am happy with the solution as it is straight forward. I now have a few more relationship types for windows computer which are all reflected in the additional tab. 

    I have a few more questions:

    - I've extended the Microsoft.Windows.Computer class with two additional properties of type enum. By default, the "Extension" tab is now shown in the Windows Computer form. I know how to hide that tab, but in this case I want to keep it for the moment. The fields are populated with the enum values. So far so good. But when I add my tab with the user control to the windows computer form, then the controls on the "extention" tab lose there binding. I can select a value but it is not stored anymore and even not loaded when I set the value through powershell. If I remove the tab with the user control, the controls on the extension tab are bound again. Expected? Any Workaround?

    - I need to do some logic when the windows computer form is closed. Therefore I registered to the "SubmittedEvent" in the code behind of the user control. That works if I use my own form, but when I do so in a form extension, the method is not raised in my code. When debugging I see that the hander is added without an exception, but the method is never raised. How can I add a handler to the on submitted event using a custom user control in a extend form? Here is the Line of code I use. "OnSubmitted" is my Method that does a little logic, specially updating the relationships for windows computer and populates some vales on relationship properties: AddHandler(FormEvents.SubmittedEvent, new EventHandler<FormCommandExecutedEventArgs>(OnSubmitted)); 

    Saturday, April 19, 2014 1:18 PM
  • Hi Thomas,

    On "Submitted" Event handler: Found a solution. The problem is that this event can only be registered on the root user control and not on a child, what my extension in this case is. So the solution is to find the root user control and add it there. 

    Found this here: http://social.technet.microsoft.com/Forums/de-DE/8e08b481-963c-4463-86e9-6ada53bae3f1/formeventspreviewsubmitevent-not-working?forum=customization

    Works! 

    Thx 

    • Marked as answer by Sebastian Zolg Wednesday, April 23, 2014 5:54 PM
    Tuesday, April 22, 2014 6:40 PM

All replies

  • There can be only one form for each class. you'll want to either replace or edit the existing computer form. 

    • Proposed as answer by BuchatechMVP Thursday, April 17, 2014 5:14 AM
    • Marked as answer by Sebastian Zolg Monday, April 21, 2014 5:46 PM
    Tuesday, April 15, 2014 4:19 PM
  • Hi Thomas,

    thx.

    Hmm...the problem with this is that the custom form would be very complex from a UI perspective. 

    So a custom wpf user control and then customize the default form of windows computer ? 

    I think creating a new class and derive from windows computer is then the better way. Something like "ManagedWindowsComputer"...

    Any better idea? 

    Tuesday, April 15, 2014 4:59 PM
  • Why don't you set this up as a related class, similar to the way that Operating System is related to Computer, but some of the properties are displayed on the computer form. 

    the problem with an inherited class is that you won't be able to "upgrade" an existing instance to the child class. an Extension class might also work, but then it would be on every computer, just mostly not populated. 

    as an alternative, you can call the form from a task. The only problem with the task model is that it would change the expected behavior of your view. i.e. doubleclicking on the object would open the "class" form, and clicking the task would open the "custom" form. 

    • Edited by Thomas Bianco Wednesday, April 16, 2014 6:50 PM clairify myself
    Wednesday, April 16, 2014 6:46 PM
  • Hi Thomas,

    thanks a lot. 

    You mean a "hosted" scenario ? Like Windows Computer hosts applicationset ? The thing with the applicationset is that a computer can have multiple applicationsets and that this applicationsets have a order number. So there is applicationset 1, 2, 3 and so on. During installation time, they get executed in that order and it's important to do so. 

    I've realized this behavior having a property "OrderNumber" on the relationship class self which connects a computer to a applicationset. Works well and we did so in a couple of other project. 

    Ok, I missed the point with the "upgrade" of to the child class. That's a valid point. 

    Hmm, I don't like the idea of having a Task for doing it because any other implementation is done double clicking the item. 

    Maybe I should think again of extending the windows computer class and adding a additional tabitem to the builtin form and adding a usercontrol on it which contains all the complex UI stuff....

    By the way, can one form be extended with additional user controls multiple times by multiple management packs? Or can a form only be extended once by one MP `?

    thanks


    Wednesday, April 16, 2014 7:51 PM
  • Forms can be extended by only one FormExtension (and therefore one MP), but you can re-open and re-edit that extension multiple times. 

    typically, when i'm extending forms, i'll create a new MP in the authoring tool, or Visual studio for the braver, and store only that extension in that MP. if i need to change that FormEntension, then you can go back to your unsealed source file, edit it in the authoring tool to make your changes, re-seal it and re-import it, and other bits of Service Manager that depend on that form extension will be none the wiser. 

    • Proposed as answer by BuchatechMVP Thursday, April 17, 2014 5:14 AM
    • Marked as answer by Sebastian Zolg Monday, April 21, 2014 5:45 PM
    Wednesday, April 16, 2014 9:16 PM
  • Hi Thomas,

    I've made a decision. I've extended the Windows Computer Form. I wrote a user control in VS having a few controls and a lot of logic in Code Behind. Then I added the user control to a new tab item called "Application Management" which I added with a few lines of XML to the base windows computer form.

    Worked like charm and I am happy with the solution as it is straight forward. I now have a few more relationship types for windows computer which are all reflected in the additional tab. 

    I have a few more questions:

    - I've extended the Microsoft.Windows.Computer class with two additional properties of type enum. By default, the "Extension" tab is now shown in the Windows Computer form. I know how to hide that tab, but in this case I want to keep it for the moment. The fields are populated with the enum values. So far so good. But when I add my tab with the user control to the windows computer form, then the controls on the "extention" tab lose there binding. I can select a value but it is not stored anymore and even not loaded when I set the value through powershell. If I remove the tab with the user control, the controls on the extension tab are bound again. Expected? Any Workaround?

    - I need to do some logic when the windows computer form is closed. Therefore I registered to the "SubmittedEvent" in the code behind of the user control. That works if I use my own form, but when I do so in a form extension, the method is not raised in my code. When debugging I see that the hander is added without an exception, but the method is never raised. How can I add a handler to the on submitted event using a custom user control in a extend form? Here is the Line of code I use. "OnSubmitted" is my Method that does a little logic, specially updating the relationships for windows computer and populates some vales on relationship properties: AddHandler(FormEvents.SubmittedEvent, new EventHandler<FormCommandExecutedEventArgs>(OnSubmitted)); 

    Saturday, April 19, 2014 1:18 PM
  • On Extension Bindings: Typically this type of binding issue is due to the console cache after updating a form. restart the console and see if it persists. if it does, the extensions tab is generated dynamically, so i'm not sure what to do about that. you might remove and re-import the Form MP, or version and reimport to ensure it's loaded correctly.

    On the "Submitted" Event handler: Consider overriding the OnPreviewSubmit() function on the form class, as Travis did in his Example Service Request for 2010. This function is implemented and registered with the event handler in the class prototype, so no special action is required except replacing that code. I've used this method to do pre-submit checks on a few forms, but i typically avoid Visual Studio stuff, when i can. plus it has the advantage that you can abort the submit if something doesn't match. 

    Monday, April 21, 2014 8:43 PM
  • Hi Thomas,

    On "Submitted" Event handler: Found a solution. The problem is that this event can only be registered on the root user control and not on a child, what my extension in this case is. So the solution is to find the root user control and add it there. 

    Found this here: http://social.technet.microsoft.com/Forums/de-DE/8e08b481-963c-4463-86e9-6ada53bae3f1/formeventspreviewsubmitevent-not-working?forum=customization

    Works! 

    Thx 

    • Marked as answer by Sebastian Zolg Wednesday, April 23, 2014 5:54 PM
    Tuesday, April 22, 2014 6:40 PM