Hi All,
I am trying to add a new form part to an existing form through X++ via extensions. I wasn’t able to find any documentation around this so any links would be greatly appreciated.
I created an event handler class and copied in the “OnInitialized” code from the form. This passes in a sender object of type FormRun. This class has 2 methods that I think I could use in order to add my part to the form:
My problem is that I am not able to create an instance of either of those objects based on my newly created form representing the part. Both constructors (for FormPartControl and FormPartReferenceControl) require a FormBuildControl and a FormRun object to be passed in. I assume I could pass in my “sender” object as the formRun, but how can I link my custom part form to the FormBuildControl object?
Thanks in advance!
Peter
Is there any reason for trying to do it in code? Isn’t it possible to add it in AOT (in a form extension)?
Hi Martin,
That would make my life a lot easier, but custom form parts are not allowed in form extensions as of yet (ie. when you right-click the Parts node, there is no New option) . I’m using the latest VM (Update 2 from August). Not sure if MS is planning to add this functionality in the future.
Thank you,
Peter
What a pity.
I don’t have any statement from Microsoft, but I would be very surprised if they didn’t intend to support it.
I’ve never seen any code adding form parts at runtime, so I can’t confirm that it’s possible (the only class calling addFormPart() is FormPartControl itself, so it may be an infrastructure method, not intended to be used by in your scenario). Nevertheless try calling it before initialization is finished.
If it’s tricky, it may be more efficient to just create a customization for now and refactor it when form parts become supported in form extensions.
Thanks Martin. I think I will go with your last suggestion until I find an extension equivalent or Microsoft implements the feature.
Perfect! I used dialog fly-outs as a temporary solution, but it was far from ideal. This is exactly what I needed.
Thanks again for your help Martin.
Peter