Order of sc_include for of files in internal libraries make or break the GENERATE CODE

INTERNAL LIBRARY with :-

  1. data_validations.php
  2. email_service.php (this calls PHPMailer v7 which is uploaded in External Libary)
  3. A few other libraries
    APPLICATION: Form
    onScriptInit:
    If the include is as follows
    sc_include(“email_service.php”, “prj”); // Email sending service
    sc_include(“data_validations.php”, “prj”);

Generate Source fails with error as follows -
Undefined variable $nm_php_seg_func | Script: /Applications/Scriptcase/v9-php81/wwwroot/scriptcase/devel/class/generator/nmDados.class.php linha: 7706

If the include is as follows

sc_include("data_validations.php", "prj");  
sc_include("email_service.php", "prj");      // Email sending service

Generate Source successful

Strange thing : This does not happen with blank application. I tried with multiple form applications to with same type of error

SCRIPTCASE Version 9.13 , postgres 18

ATTN TO SCRIPTCASE TECHNICAL TEAM: I am willing to share the libraries, the forms if they want to check this further

In email_service.php, are you calling sc_include_library inside or outside a function?

No include inside emailservice.php. Call as follows
$mail = new PHPMailer\PHPMailer\PHPMailer(true);

Ok.

Give this a shot.

Check where PHPMailer is marked as Use library in External Libraries.
Ensure the sc_include_library settings is applicable to your environment, but I think this should work.

Replace with:

sc_include_library(“sys”, “PHPMailer”, “PHPMailer/PHPMailer/src/Exception.php”, true, true);
sc_include_library(“sys”, “PHPMailer”, “PHPMailer/PHPMailer/src/PHPMailer.php”, true, true);
sc_include_library(“sys”, “PHPMailer”, “PHPMailer/PHPMailer/src/SMTP.php”, true, true);

$mail = new PHPMailer\PHPMailer\PHPMailer(true);

thank you . will try and get back