How to get extra data from Custom Editor Form for newly created item in FNC Planner used in a Webcore project

Hi,

We are using FNCPlanner component in a TMSWebcore project to manages Events. We have used a separate custom editor form to replace inbuilt Item Editor dialog. The Custom Editor Form is inherited from TTMSFNCPlannerCustomItemEditorForm class and assigning the class to CustomItemEditorForm property as follow
TfrmCalendarEditor = class(TTMSFNCPlannerCustomItemEditorForm)
................
plannerCalendar.CustomItemEditorForm := TfrmCalendarEditor;

The custom editor form also having some extra fields to manage some extra data the need for an planner Item. We are trying to save the extra data for planner item as object with using Item.DataObject property but we are not getting the proper event or place where we can update and save the extra data for the newly created item.

For example the TfrmCalendarEditor for contains some extra fields like Event Priority, Event Status, Actions, FollowedBy etc. The form also contains a Submit and Cancel button. On cancel click, I just close the form and on Submit click, I am calling Planner.CloseEditingDialog

procedure TfrmCalendarEditor.btnSubmitClick(Sender: TObject);
begin
  ModalResult := mrOk;
  PlannerTitle := edtTitle.Text;
  PlannerText := memoNotes.Text;
  PlannerStartTime := DateOf(dtpStartDate.DateTime)+TimeOf(dtpStartTime.DateTime);
  PlannerEndTime := DateOf(dtpEndDate.DateTime)+TimeOf(dtpEndTime.DateTime);

  // how to update and store the extra data to item?//
  // As I checked the planner component code the PlannerItem property is NIL for new event item//
  // the item is created inside the CloseEditingDialog and also closes the editor form
  // Also could not find any link property between the planner and editor form

  Planner.CloseEditingDialog(False);
end;

So, how to get extra data from Custom Editor Form for newly created item in FNC Planner used in a Webcore project

Hi,

When calling the form for a new item, the item is not yet created, hence the reason why it is nil. After closing the dialog, the item will be inserted and an event will be called. The dialog is still created and open at that time. So you could use the following code to achieve this:

procedure TForm23.TMSFNCPlanner1AfterInsertItem(Sender: TObject; AStartTime,
  AEndTime: TDateTime; APosition: Integer; AItem: TTMSFNCPlannerItem);
var
  f: TTMSFNCPlannerCustomItemEditorForm;

  function FindForm: TTMSFNCPlannerCustomItemEditorForm;
  var
    I: Integer;
  begin
    Result := nil;
    for I := 0 to TMSFNCPlanner1.ComponentCount - 1 do
    begin
      if TMSFNCPlanner1.Components[I] is TTMSFNCPlannerCustomItemEditorForm then
      begin
        Result := TMSFNCPlanner1.Components[I] as TTMSFNCPlannerCustomItemEditorForm;
        Exit;
      end;
    end;

  end;
begin
  f := FindForm;
  if Assigned(f) then
  begin
    AItem.Text := (f as TForm25).Button1.Text;
  end;

end;

Note that TForm25 is a separate form inheriting from the custom editor form class for the planner.