Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

Need to know when report overwriting occurs.

edited June 2003 in End User
Hi,
Recently I bumped into a problem: How should I process my savings when
report overwriting occurs?
I am using several additional tables connected with reports via
RB_ITEM.ITEM_ID field. Before report is loaded(or created) several of my
dialogs pop up, user can make some changes there and later, when the report
is saved into database changes made in my pop up dialogs are saved to the
database as well. (I get and assign report Id manually thus having total
control over report creation process). So far so good.
But some time ago I tried to overwrite the report and that is when
unexpected problem arised.
When I'm creating the new report, I'm supposed to work with new record and
new report Id that is being created in my application. But when user tries
to overwrite an existing report - I cannot use this approach anymore,
because the overwriting of EXISTING report occurs.
Thus the question: Since I need to change the Id of the report for saving my
pop up dialogs changes into DB, FROM the one I was going to create in
OnAfterInsert event of Item's dataset ON the one(Id, that is) that is of
report that is being overwritten - When and how do I know the Id of the
report that is going to be overwritten?
I can extract the id if I know the name of the report and Id of the folder.
I can get overwritten report name from
TppReport.Template.DatabaseSettings.Name property in Template.OnSaveStart
event, but how do I know the Id of the folder where this report is going to
be saved to?
Also it would be very good if I could somehow detect that an overwritting
has actually occured.
It seems I will probably need to use Custom Save Dialog method for this, but
I still don't know how to do it.

Help me, please?

MB.

Comments

  • edited June 2003
    You can search on Name, ItemType and CurrentFolderID. Reference the
    ReportExplorer's properties for the currently selected folder:

    property CurrentItemName: String read FCurrentItemName write
    FCurrentItemName;
    property CurrentItemType: Integer read FCurrentItemType;
    property CurrentFolderId: Integer read FCurrentFolderId write
    FCurrentFolderId;

    One way to do this is to create a function like this:

    function TppReportExplorer.LocateItemRecord(const aItemName: String;
    aItemType, aFolderId: Integer): Boolean;
    var
    lsFieldNames: String;
    begin

    lsFieldNames := FItemFieldNames.FolderId + ';' +
    FItemFieldNames.ItemType + ';' +
    FItemFieldNames.Name;

    Result := FItemPipeline.Locate(lsFieldNames, VarArrayOf([aFolderId,
    aItemType, aItemName]), [pploCaseInsensitive]);

    end; {procedure, LocateItemRecord}

    So, this is for the current folder, but you want to know what
    FolderID/ItemID they will be trying to save to. You can verify a user's
    request to save a report template by implementing your own save process on
    the TppDesigner by using the TppDesigner.OnCustomSaveDoc event.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited June 2003
    Damn, that seems to be a little hard for me. (No time to try and understand
    it all).
    Thanks for the tip, but rewriting saving process is too much for overwriting
    routine.
    Can't I just prohibit overwriting at all?

    MB

  • edited June 2003
    TppDesigner.OnCustomSaveDoc is the event to use to control the saving
    process of a report.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.