solved: doInsert into eventout returns wrong return code

Hi All,

I'm trying to create a simple javascript email out script. The script works but it does not return a valid return value.  The values returned range from @1 to ` to NULL and once ran, the js cannot be recompiled (if it was already open in the ScriptLibrary editor), modified or otherwise touched.  The only way I found to be able to try again, is to close the ScriptLibrary editor for that js and open it again.

Here is the script:

function SimpleEmail(iFrom, iTo, iObject, iMsg) {
if (iFrom == null) return false;
if (iTo == null) return false;
if (iObject == null) return false;
if (iMsg == null ) { iMsg = iObject; iObject = "" } 

var cSep = "^";
var rteReturnValue = new SCDatum();
var rteVal = new SCDatum()

// the header information
var fEmail = new SCFile("eventout");
fEmail.evtype = "email";
fEmail.evsepchar = cSep;
fEmail.evtime = new Date();
fEmail.evexpire = fEmail.evtime;
system.functions.rtecall("getnumber", rteReturnValue, rteVal, "event");
fEmail.evsysseq = rteVal;
// The eventout out line
var vLine = iTo cSep iFrom cSep cSep iObject cSep iMsg ;
fEmail.evfields = vLine;

// If I comment the following line, I get a valid return value of false - but obviously, my email will not get out.
var rc = fEmail.doInsert();
//========== Problem above ====================

if (rc == RC_SUCCESS) return true;
return false;

From the debug window:

d jscall("cxFunction.SimpleEmail","","","Subject","Message")

returns Value is NULL

Am I doing something wrong or is this an undocumented feature?

Thanks for your assistance.



  • The function was not at fault.  I had triggers that were functional and correct but the interfered with the insert process.  To circumvent this, I have disabled and re-enable the trigger before and after the doInsert(), like this:

    var retour = system.functions.rtecall("trigger", rteReturnValue, 0);
    var rc = fEmail.doInsert();
    var retour = system.functions.rtecall("trigger", rteReturnValue, 1);