Click here to Skip to main content
15,915,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried the below jscript for m3 lawson ERP customization. i need it to call only in the leaving point or clicking point of the "lotref 1 "textbox.

but below script calls when i open up the panel in my "pms050 "program in m3 lawson erp.

Please help me to sort it out
Thanks & Regards
Tish

What I have tried:

Java
import System;
import System.Windows;
import System.Windows.Controls;
import MForms;
import Mango.UI;
import Mango.UI.Core;
import Mango.UI.Core.Util;
import Mango.UI.Services;
import System.Collections.Generic;
import System.Collections;

package MForms.JScript {
    class ValidateField {
    var controller;
    var debug;
    var value;
    var textBoxlotref1Element;
    var max;
    var min;

    public function Init(element : Object, args : Object, controller : Object, debug : Object) {
    var content : Object = controller.RenderEngine.Content;
    textBoxlotref1Element =ScriptUtil.FindChild(content, "WLBREF").Text;
  
     debug.WriteLine(textBoxlotref1Element);
     this.debug=debug;
     GetValue(textBoxlotref1Element);}

 public function GetValue(textBoxlotref1Element) {
  
       //value.content = (textBoxlotref1Element.content.parseInt("WLBREF"));
       //value=001118;
       value=textBoxlotref1Element     
       
      if (value != null && value >= 001117 && value <= 365925 )
      {
      
       debug.WriteLine("ok");
      
      }
      else
      {
      debug.WriteLine("different" + textBoxlotref1Element+ " on the current panel");

      var message = "Invalid Batch Number";
      ConfirmDialog.ShowWarningDialog(message);
        return value;
      }
    }
 
      }
Posted
Updated 20-Mar-17 19:05pm
v2
Comments
Richard MacCutchan 7-Mar-17 10:41am    
It would help if you formatted your code properly. And, more importantly, if you explained what your problem was.

1 solution

You might want to try something along this line

JavaScript
public function Init(element : Object, args : Object, controller : Object, debug : Object) {
  var content : Object = controller.RenderEngine.Content;

  // Instead of accessing the text in the element, get a reference to the element
  textBoxlotref1Element =ScriptUtil.FindChild(content, "WLBREF");

  // No point writing this output. Info method is invoked only once at the     beginning 
  //debug.WriteLine(textBoxlotref1Element);

  this.debug=debug;

  // Don't call GetValue here. If you do, it will be executed only once when the Init method is invoked
  // GetValue(textBoxlotref1Element);

  // Instead, add an event handler for the click event of the element
  // getValue() will be called each time it's clicked
  textBoxlotrefElement.add_Click(getValue);
}

function getValue(sender, e : EventArgs) {
  // Move the logic of your GetValue function in here

}
 
Share this answer
 
Comments
tish1234 9-Mar-17 0:57am    
hello thanks a lot for your reply..but the problem is there is a run time error in "textBoxlotref1Element.add_Click(getValue);".
tish1234 10-Mar-17 0:58am    
this is the error that im getting when i execute the program
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.JScript.JScriptException: Function expected
at Microsoft.JScript.LateBinding.Call(Binder binder, Object[] arguments, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters, Boolean construct, Boolean brackets, VsaEngine engine)
at Microsoft.JScript.LateBinding.Call(Object[] arguments, Boolean construct, Boolean brackets, VsaEngine engine)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at MForms.ScriptManagerM3.RunScript(Type scriptType, ControlScript controlScript, Object runContext, IScriptDebugOutput scriptDebugOutput)
at Mango.UI.Script.ScriptToolControl.Run()

thanks
jseanm1 10-Mar-17 16:52pm    
Ok. Looking at this (http://stackoverflow.com/questions/8681700/microsoft-jscript-runtime-error-function-expected), it looks as if there is a naming error in the code. Can you please reedit your question to add the complete code (after making the edits I suggested) to your question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900