Issue with DME variable scope

 0 Replies
 0 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
Chad Dirst
Advanced Member Send Private Message
Posts: 42
Advanced Member

I have added a DME query to an ESS screen and am having issues with when I can use the variable. I define a globalvariable called EmployeeProcessLevel.   During one of the original Lawson functions, I call my function (QueryOEEmployeeProcessLevel) to get the data I need.  This dme function in turn calls the SetOEProcessLevel function which should set the global variable (EmployeeProcessLevel) I defined.  The issue is that when control passes back to the original non-modified function, it does not recognize the variable (ie. undefined).  However, the funny thing I found by placing alerts in the code is that after the original non-modified function runs, it seems to call the function that defnies the global variable.  I would have expected this function to be called by the DME. Any thoughts/suggestions?  Thanks in advance. Chad var EmployeeProcessLevel;  function QueryOEEmployeeProcessLevel() {

   var dmeObj      = new DMEObject(authUser.prodline,"employee");    dmeObj.out      = "JAVASCRIPT";    dmeObj.index    = "empset1";    dmeObj.field    = "company;employee;process-level";    dmeObj.max      = "10";    dmeObj.debug = false;    dmeObj.key      = parseInt(authUser.company,10) + "=" + parseInt(authUser.employee,10);    dmeObj.func = "SetOEProcessLevel()";    DME(dmeObj,"jsreturn");  }

  function SetOEProcessLevel() {

 if (self.jsreturn.NbrRecs)    {        EmployeeProcessLevel = self.jsreturn.record[0].process_level;    }    else    {         EmployeeProcessLevel = "";     } }

.// In Lawson delivered function code I call:  QueryOEEmployeeProcessLevel();