Trouble passing Entity ID from Action Script to a Web Screen Preparation

Trouble passing Entity ID from Action Script to a Web Screen Preparation

  
When  passing  an Entity ID variable from web screen A to a web screen B via an action script, I have a problem. The value is lost and becomes zero.

If I use a normal link the value is passed from web screen A to a web screen B. No problems.

But it's another story if I use an action script. The action script is inside web screen A's scope. And within the action script the Entity ID variable has the value. At the end of the action script the Entity ID is passed to web screen B via a Go To Destination Web Screen link. Web screen B has a matching input parameter.

However in web screen B the Entity ID variable has a value of zero. Odd that.

I have tried making sure the Entity ID variable is within the scope of the action script by having a matching input parameter for the action script. The value was fine within the action script, but lost when passed to web screen B.

I have even tried passing the Entity ID variable to a local variable within the action script. Again the value was fine within the action script, but lost when passed to web screen B.

Is there some way to see the actual memory address of the variable?

I can do a work around using a session variable, but that's code smell.

Cheers


Hi Mark,

I tried the same but its working fine, if you can share the sample oml, then it will be easier to identify the issue.

Regards,
MJ
Mark,
On Link click you are passing id to the next screen and try refreshing your link every time you change entityid and than click , also do inspect element and you will see that what id it is paasing .

Regards
-PJ-
Hi Mark,

What do you mean by "action script"? Pramod probably has the solution if you're clicking on a link, but I'm not sure whether you are. Also, it would help if you could attach a simple example eSpace that exhibits the problem, like Manish said.
Kilian Hekhuis wrote:
Hi Mark,

What do you mean by "action script"? Pramod probably has the solution if you're clicking on a link, but I'm not sure whether you are. Also, it would help if you could attach a simple example eSpace that exhibits the problem, like Manish said.
 Sorry, I meant "screen action"
 
Hi Mark,

Thanks. Input parameters for screens are passed in the URL. So it would be fairly easy to see whether the right value is passed to screen B from screen A (something like https://yourserver/yourespace/b.aspx?entityid=5). If the URL does not show the input variable, or contains the wrong value, the problem is in A. If it has the right value, but isn't received correctly by B, the problem is there. However, like I said, it's easiest trying to create a minimal eSpace exhibiting the problem, so we can take a look at what goes wrong.
The application is here:

https://markcowan.outsystemscloud.com/Orders/Home.aspx

The error is thrown when I add a new item from the Order Details page.

I clearly have the Entity's ID just before going the the OrderItemDetails page.



But in the OrderItemDetails page the ID value is now zero



I've attached the oml file.
Mark,

A few notes:
1) There's a small bug in the "Add Item" link's "Visible" property: it is now always shown, regardless of the Status, since "Status <> A or Status <> B" is always true (Status can't be both A and B).
2) OrderID (any reason it isn't called OrderId with lowercase d?) is not used at all in the OrderItemDetails screen. It is therefore optimized away, and that's why the debugger shows it as 0. Again, check the page's link in your browser, and you'll discover the right Id is passed.

Lesson learned: don't rely too much on what the debugger shows in all cases.
Kilian Hekhuis wrote:
Mark,

A few notes:
1) There's a small bug in the "Add Item" link's "Visible" property: it is now always shown, regardless of the Status, since "Status <> A or Status <> B" is always true (Status can't be both A and B).
2) OrderID (any reason it isn't called OrderId with lowercase d?) is not used at all in the OrderItemDetails screen. It is therefore optimized away, and that's why the debugger shows it as 0. Again, check the page's link in your browser, and you'll discover the right Id is passed.

Lesson learned: don't rely too much on what the debugger shows in all cases.
 Hello,

Thanks for spotting the logic bug.

I'm giving it another try following your suggestions.
 
Okay. Here's what I've noticed.

There are two links to OrderItemDetails. One is via AddItem screen action and the other is in the Product Name column of  the OrderItemTable. Both the AddItem and  Product Name pass GetOrderById.List.Current.Order.Id to the OrderId input variable for the OrderItemDetails web screen.

Product Name is successful, but AddItem fails. Why?

Time to do some experimentation.

With an Order Details screen with some Order Items listed in the
OrderItemTable I tried to add a new item. So, AddItem passes two varibles to OrderItemDetails
  • OrderId = 10 (from GetOrderById.List.Current.Order.Id)
  • OrderItemId = NullIdentifier()
And it fails. In OrderItemDetails both input values OrderId and OrderItemId are zero. Even though in the URL it says "OrderItemDetails.aspx?OrderItemId=0&OrderId=10" Huh?

Okay. So, I change AddItem to pass

  • OrderId = 10 (from GetOrderById.List.Current.Order.Id)
  • OrderItemId = 17 (from OrderItemTable.List.Current.OrderItem.Id)
And it's successful. In OrderItemDetails OrderId = 10 and OrderItemId = 17.

Somehow, the
OrderItemId = NullIdentifier() causes OrderId to be Null too.

The solution - pass the OrderId via a session varible. Not elegant, but it'll work.
You can call the required page "OrderItemDetails.aspx" through ExternalURL and pass orderid as input parameter like as
"../Orders/OrderItemDetails.aspx?OrderID="+GetOrderById.List.Current.Order.Id+""
Now you can get OrderId value in next page.
While click on AddItem




please find attached modified Oml
@Sashi: That's a very bad idea. There's no need for workarounds like that, and it's very unmaintainable. Also, I doubt it works, as the URL will be exactly the same as the "non working" variant: as Mark already wrote, the URL seems ok!

@Mark: Don't use session variables for this. They're not meant for this, and it'll bite you later on. Back to your problem, I'd advise you to do little more in the preperation than a feedback message that displays the two values. Do not rely on the debugger, just show the values to the user. Does that still result in a "0" value for OrderId? I still think that you have botched logic somewhere, and the debugger is showing the wrong value.
Hello Kilian,

The OrderId is being passed to the server. Its value is in the httpConnection string. But the server doesn't seem to be picking it up.



And I have double checked - "Order New Item in order # 0". It calls for the OrderId input parameter.




Here's the same page, looking at an item that was already added to the order.


Mmm, that's extremely weird. I'd almost believe it's a bug. Can you post the latest version of the OML, with the screens you showed above?
Hello Kilian,

Here's the OML.
And here are all the screen shots
Solution
Hi Mark,

I investigated further, and I think it's a bug in the platform. I'll check whether I'm right, and if so I'll report it to OutSystems support. Meanwhile, the workaround is easy: change the order of the input parameters of OrderItemDetails to OrderId, OrderItemId (instead of the other way around). This seems to resolve the issue.
Solution
Oh, I forgot: the display of the order Id in the OrderItemDetails screen is wrong: you use the output from the preperation query, but that's empty in case of a new Item. Use OrderId instead.
Hello Kilian,

Sorry for the delay in replying. I've been busy switching over computers.

I hope I can check your work around this afternoon.

Cheers

Yeap. Moving the input parameter OrderId first worked. 

Thanks very much for all your help.

Great to hear it works Mark. I've sent a bug report to OutSystems support about this, but haven't heard from them yet.