Codeunit.RUN

ImaspalImaspal Member Posts: 68
Hi Experts!

I have to run a codeunit and at the same time I have to send a parameter to this same codeunit.

Because OnRun - Trigger can't take parameters, I have made RunMe(Boolean)-function to this same codeunit. So, when I want to run this codeunit and at the same time send a parameter to it, I use this RunMe(Boolean) function.

The problem is, that I need to know if the codeunit have been run correctly. If I use the OnRun-trigger like that:
[Ok] := Codeunit.RUN(Number [, Record])
the return value gives the message TRUE, if the codeunit have been run correctly. Is there an easy way to clarify this same issue, when I'm using my own, RunMe(Boolean)-function.

Yours,
IP

Comments

  • BeliasBelias Member Posts: 2,998
    what's wrong with this?
    MyCodeunit.RunMe;
    if Mycodeunit.run then begin
      //bla bla bla
    end;
    
    //Mycodeunit is a variable of type codeunit...
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • McClaneMcClane Member Posts: 40
    You could declare your codeunit as a variable and create a new function within it (e.g. "SetMyValues"). So you can use it like this:
    Clear(MyCodeunit);
    MyCodeunit.SetMyValues(Value1,Value2, ...);
    Ok:=MyCodeunit.run(MyRec);
    
  • BeliasBelias Member Posts: 2,998
    :-k
    You could declare your codeunit as a variable and create a new function within it (e.g. "SetMyValues"). So you can use it like this:
    Code:
    Clear(MyCodeunit);
    MyCodeunit.SetMyValues(Value1,Value2, ...);
    Ok:=MyCodeunit.run(MyRec);

    isn't it what he has done?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • girish.joshigirish.joshi Member Posts: 407
    I don't think so. I think he combined he just created his own 'RUN-like' function that does all of the processing.
  • ReinhardReinhard Member Posts: 249
    maybe have a global variable boolean runToCompletion which you immediately set to false. at the end of your code that should run to completion set it to true. then go and get its value to see if your code ran all the way...
    CU.RunMe(true/false);
    IF CU.getRunToCompletion THEN... ELSE...
    
  • ImaspalImaspal Member Posts: 68
    McClane wrote:
    You could declare your codeunit as a variable and create a new function within it (e.g. "SetMyValues"). So you can use it like this:
    Clear(MyCodeunit);
    MyCodeunit.SetMyValues(Value1,Value2, ...);
    Ok:=MyCodeunit.run(MyRec);
    

    I used this solution and it worked! Thank you for your help.

    Yours,
    IP
  • BeliasBelias Member Posts: 2,998
    what's wrong with this?
    Code:
    MyCodeunit.RunMe;
    if Mycodeunit.run then begin
    //bla bla bla
    end;

    //Mycodeunit is a variable of type codeunit...

    Yes, I forgot to write the values to pass in "runme"
    :mrgreen::mrgreen::mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.