XrmDefinitelyTyped icon indicating copy to clipboard operation
XrmDefinitelyTyped copied to clipboard

Add support for Quick View Forms

Open henrikhannemose opened this issue 8 years ago • 4 comments

When a Quick View Form is added to a form, the controls from the Quick View Form can be accessed in the following manner: Xrm.Page.getControl("quickViewFormName_quickViewFormName_relatedEntityName_fieldName"). This is currently not supported by XrmDefinitelyTyped.

Support for getting the controls from a Quick View Form could be added to XrmDefinitelyTyped. The attributes returned from getAttribute would possibly not have setValue available, since that is not supported as mentioned on MSDN:

The constituent controls within a quick view control are included in the controls collection and these controls have the getAttribute method. However, the attribute is not part of the attribute collection for the entity. While you can retrieve the value for that attribute using getValue and even change the value using setValue, changes you make will not be saved with the entity.

henrikhannemose avatar Jun 22 '17 12:06 henrikhannemose

With the release of 9.0 quick view forms can now be accessed in a different manner.

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/formcontext-ui-quickforms

Tolini avatar Mar 16 '18 11:03 Tolini

@Tolini , We need a way to set the visibility of quickview controls on the form. Since the getFormContext returns an object with tabs, controls and attributes excluding quickview controls, I don't find a way to get them.

As stated, formContext.ui.quickview.get should retrieve the right control, but this is not part of the getFormContext result since its not in the generated typings?

KimBon avatar Sep 23 '19 21:09 KimBon

Would be nice to have this feature!

mathiasbl avatar Dec 04 '19 10:12 mathiasbl

as far as I can tell you can use this as a workaround to get it to work currently. It does require some casting (oof) but might be a model to implement it with.

type BaseQuickFormControl =
    Pick<Xrm.BaseControl, 'getControlType'> &
    Pick<Xrm.Control<Xrm.Attribute<any>>, 'getDisabled'> &
    Pick<Xrm.BaseControl, 'getLabel'> &
    Pick<Xrm.BaseControl, 'getName'> &
    Pick<Xrm.BaseControl, 'getParent'> &
    Pick<Xrm.BaseControl, 'getVisible'> &
    Pick<Xrm.Control<Xrm.Attribute<any>>, 'setDisabled'> &
    Pick<Xrm.BaseControl, 'setFocus'> & 
    Pick<Xrm.BaseControl, 'setLabel'> &
    Pick<Xrm.BaseControl, 'setVisible'>

interface QuickFormControl extends BaseQuickFormControl {
    isLoaded(): boolean;
    refresh(): void;
}

// Form specific should be generated
type MyAccountQuickForm =
    Pick<Form.account.Quick.MyQuickForm, 'getControl'> & QuickFormControl;

type QuickFormCollection = Xrm.Collection<QuickFormControl> & {
    get(name: "quickform_control_on_form"): MyAccountQuickForm
}

type QuickFormUIExtension = {
    quickForms: QuickFormCollection
}

and then retrieve it using

const quickForm = (formContext.ui as (typeof formContext.ui) & QuickFormUIExtension)
    .quickForms.get("quickform_control_on_form");

The cast as any is to eliminate the fact that the quickForms collection doesn't exist

zunin avatar Feb 06 '20 08:02 zunin