Contributor.. Contributor..

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","scdasp@bell.ca","scdasp@bell.ca","Subject","Message")

returns Value is NULL

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

Thanks for your assistance.



1 Reply
Contributor.. Contributor..

Re: doInsert into eventout returns wrong return code

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);

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.