input parameter's value becomes -unavailable in current context-

input parameter's value becomes -unavailable in current context-

  

Hi,


 I have a input parameter that is first passed to a parent web block, and is then passed to the child web block. In the Parent Web Block, The Input Parameter has value, but when is passed down to the child web block, the value becomes -unavailable in current context-. Anybody have experienced this before?



Hi Lawrence,

If you're looking in debug, this happens when the code is optimized due the input not being used.

Check if this is the case. If you use it, should start appearing in the debug.

Cheers.

Hi Eduardo,

Here's my scenario:

Web Block 1 -> InputParameter -> WebBlock 2 -> InputParameter ->WebBlock 3.


My case is when the parameter is passed to the 2nd web block. In the 2nd web block it is a parameter to a query and is also passed to another web block as an input parameter. so the Input parameter is being used, not just passed.


I'm wondering why other input parameters do not become unavailable. 

If you can provide your OML or a simpler one that reproduces this behaviour, we can take a look.

Otherwise, the only explanation possible (for me) is "optimization" :)

Hi Lawrence,

I'll rewrite your scenario above slightly, the way I understood it. For the example scenario, I assume inputs are Integers:

  • WebBlock2 has InputParameter1
  • WebBlock1 passes 3 has InputParameter1 to WebBlock2
  • WebBlock3 has InputParameter2
  • WebBlock2 passes the value that InputParameter1 has (3) InputParameter2 to WebBlock3

When Debugging in the context of WebBlock2, InputParameter1 will be 3, but in the context of WebBlock3, InputParameter1 will be -unavailable in current context- and InputParameter2 will be 3.

That's because in the context of WebBlock3, there's no variable in scope named InputParameter1.

Hi Jorge,

Here is my case: This is version 8 btw and sorry i cannot attach an OML.


Here are the legends for easier understanding:

1. Blue box - Web Block 1.
2. Green Box - Web Block 2.

My Current problem is, when I pass value to Web block 2, it already becomes -unavailable in current context-.

the Parameter I am passing is used in the preparation in Web Block 2 thats why i dont understand why it is changing its value to unavailable in current context.

Sorry if I still dont understand regarding the context part, can you explain further?


So... let's see if i got this straight:

If you add a breakpoint in the Preparation of Web Block 2 (AutoSolution_SiteProduct), when you run the debugger and stop there, the value of AutoSolutionProductId is -unavailable in current context-? And AutoSolutionProductId is being used in the Preparation of the AutoSolution_SiteProduct Web Block?

Jorge Martins wrote:

So... let's see if i got this straight:

If you add a breakpoint in the Preparation of Web Block 2 (AutoSolution_SiteProduct), when you run the debugger and stop there, the value of AutoSolutionProductId is -unavailable in current context-? And AutoSolutionProductId is being used in the Preparation of the AutoSolution_SiteProduct Web Block?

Yes! thats exactly what is happening.


Ok, then we do need to see the OML to try and understand what's going on... can you please isolate this issue in a module and attach it here so we can take a look?

Solution

Hi Lawrence,

"unavailable in current context" is always because the debuger thinks the variable is not used or it is being optimized somehow.

If you ARE using it in the preparation, it should appear. But the debuger has some problems. Unfortunately, as you are using version 8, it seems that if this is a debug problem, you will have to stuck with it, as I don't think OutSystems is fixing this in version 8 (we are already on version 10...).

If the code works, than the better is to leave this way, as there is nothing you could do to "solve" this.

EDIT: If it is not working, than we have to investigate to see if we can find, at least, a workaround (like create a local variable and assign the input to it, and use the local variable).

Cheers,
Eduardo Jauch

Solution

Hi Eduardo,


 I tried what you said, I created a local variable and assigned the input parameter to the local variable. It worked. Thank you very much.