Function for automatic document generation through standard conversion

131 views
Skip to first unread message

Paula Opris

unread,
Jul 11, 2025, 5:11:16 AM7/11/25
to Softone Developers Network
Hello,

Is there any way to automatically generate a document using standard conversion?
I need to auto-exectute and save a document.

I tried using the function below:

function create_doc(findoc) {
 
    try {

        myObj = X.CREATEOBJFORM('CONVERTDLG');
        myObj.SETPARAM('SOSOURCE', 1351);
        var vSelRecs = 'FINDOC IN (' + findoc + ')';
        myObj.SETPARAM('SELRECS', vSelRecs);
        myObj.SETPARAM('PHOTO', 'TEST');
        var cnvFprms = myObj.FINDTABLE('CONVERTFPRMS');
        cnvFprms.SERIES = 30056; //
        myObj.DBPOST();
    } catch (e) {
        if (myObj != null)
            X.WARNING("Eroare generală: " + e.message + "\nEroare obiect: " + myObj.GETLASTERROR);
        else
            X.WARNING("Eroare generală: " + e.message);
    }
}

I receive an sql error and it seems the problem is here
var vSelRecs = 'FINDOC IN (' + findoc + ')';

myObj.SETPARAM('SELRECS', vSelRecs);

selrecs is not recognized.

Thank you 


Νίκος Μάλιακκας

unread,
Jul 12, 2025, 5:54:31 AM7/12/25
to Softone Developers Network
I think  CONVERTDLG is a Batch object, so it needs myObj.BatchExecute() in order to work.
also CreateObjForm should close with myObj.ShowObjForm(), so the user will interact with the form, the code pauses, and continues after the user clicks whatever she wants.

Paula Opris

unread,
Jul 14, 2025, 5:18:24 AM7/14/25
to Softone Developers Network
Hello, 

The issue is caused by the fact that "selrecs" is not being set properly. It seems the parameter is not recognized, so the system doesn't "know" which FINDOC I want to process.

The user should not perform any action — I want the function to run without any user interaction.

Thank you
Reply all
Reply to author
Forward
0 new messages