Pre- and Post-publish notifications not triggered from ExtendScript

Adobe Community Professional ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

I am having a problem with FrameMaker 2020 and notifications in ExtendScript. If I have this code in my startup folder:

 

Notification (Constants.FA_Note_PrePublishDitamap, true);
Notification (Constants.FA_Note_PostPublishDitamap, true);

function Notify (note, object, sparam, iparam) {
    switch (note) {
        case Constants.FA_Note_PrePublishDitamap:
            alert ("1. In FA_Note_PrePublishDitamap event.");
            break;           

        case Constants.FA_Note_PostPublishDitamap:
            alert ("2. In FA_Note_PostPublishDitamap event.");
            break;
    }
}

I save a ditamap as a FrameMaker book with components, both events are triggered and I see the alerts. However, when I save the ditamap from ExtendScript, the events are not triggered. This is the code I am using to save the ditamap:

function saveMapAsFmBook (map, ditaval) {      

    var params, returnParams, i, saveName, book;

    saveName = map.Name.replace (/\.[^\.]+$/, ".book");
    params = GetSaveDefaultParams ();
    returnParams = new PropVals ();

    i = GetPropIndex (params, Constants.FS_FileType);
    params[i].propVal.ival = Constants.FV_SaveFmtBookWithFm;
    i = GetPropIndex (params, Constants.FS_AutoBackupOnSave);
    params[i].propVal.ival = Constants.FV_SaveNoAutoBackup;
    i = GetPropIndex (params, Constants.FS_FileIsInUse);
    params[i].propVal.ival = Constants.FV_ResetLockAndContinue;
    i = GetPropIndex (params, Constants.FS_ShowProgressBar);
    params[i].propVal.ival = Constants.FV_DoYes;
    i = GetPropIndex (params, Constants.FS_DontNotifyAPIClients);
    params[i].propVal.ival = false;
    if (ditaval) {
        i = GetPropIndex (params, Constants.FS_DitavalFile);
        params[i].propVal.sval = ditaval;
    }

    book = map.Save (saveName, params, returnParams);
    if ((book) && (book.Name)) {
        return book;
    }
}

Should the notifications get triggered when the save is called from a script?

TOPICS
Publishing , Scripting

Views

44

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 29, 2021 Sep 29, 2021

Copy link to clipboard

Copied

LATEST

Hello Rick,

I think events are only raised by the core FM code, not by your ExtendScript, even when it is calling FM functions. I have seen similar behaviour when using events on opening XML files - when done from ExtendScript there were no events. They did appear when opening the XML file from the GUI.

So I guess you should call your Notify function from the ExtendScript after you save the map as book. As you are in control of that code you should be able to add that call. Of course a nicer way is to have your Notify call another method, which is then also available to call from the script that saves the book as map. Keeps things tidier.

Kind regards from rainy Amsterdam

Jang

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines