Bug reports Found a bug? Post it here please.
Version 4.x > Bug reports > CurrentDocument not available when referenced from Custom Form Control View modes: 
User avatar
Member
Member
richard.pendergast-notatallstrange - 5/4/2009 9:34:50 PM
   
CurrentDocument not available when referenced from Custom Form Control
From within a custom form control, there appears to be no way to reference the current document.

CMS.CMSHelper.CMSContext.CurrentDocument returns null

This bug can be reproduced within version 4.0 of KenticoCMS as follows:
- create a custom form control
- create a dummy field within any document type
- set the field type of the dummy field to the new form control
- from within any event of the form control attempt to reference CMS.CMSHelper.CMSContext.CurrentDocument

We are currently using a workaround:
CMS.TreeEngine.TreeNode currentNode = treeProvider.SelectSingleNode(CMS.GlobalHelper.QueryHelper.GetInteger("nodeid", 0));
but are already aware of cases where this will not work.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/11/2009 3:24:11 PM
   
RE:CurrentDocument not available when referenced from Custom Form Control
Hi,

On the FORM tab, when editing the document you cannot use the CurrentDocument property since you are not on the document but on the Form tab, so therefore it is null.

You can try to use this: CMS.FormControls.BasicForm.EditedObject and in this property is the information about the edited document.

Best Regards,
Juraj Ondrus