Index was out of range. Must be non-negative and less than the size of the collection

Index was out of range. Must be non-negative and less than the size of the collection

  
Hello Experts,

I have created a widget user will be able to upload the document and can associate projects or participant with the each Document.
 
All was working perfectly but the issue what happened is the document was getting visible to all the tenants.The problem was I created the entities but did not give them the Multi Tenant property. I changed them and published. So now If I create the  new Document it says sometimes Index was out of range  and sometimes it works. If it it worked and created the Document again if I try to opne the attachment it sometimes says Index was out of range  and sometimes it works.
 
The error is not consistent, we tried to verify this with the multiple Clients. Same issue.
Hi,

the error says a lot but also nothing.
can you please provide an example oml how you do it.

J. wrote:

Hello J,

The issue is the Espace is bigger I couldnt add  the one which has the issue.

What I did was I tried to copy all the webscreen for widget and entities in to other espace without any changes and tried testing. The issue is I am not able see the same error.I am attaching the test espace
 
But now I am not able to see the uploaded file. Though I upload the file. I am not able to see them. But in my original espace one when I dont get the error I was able to see the document. It is very confusing.




Hi,

the error says a lot but also nothing.
can you please provide an example oml how you do it.
 
 
 
V,

somewhere you're logic is passing in an out of bounds value to the 'index' parameter, but that could be anywhere (in a loop, reset pagination, etc).  Run your app in debug mode without any break points, but leave the 'Break on all Errors' enabled.  That will take you to the node where the exception occurs and you can (possibly) see what value is passed, or at least know where the issue is.

If the occurance is too sporadic, you can always check your error logs and see the stack of objects that were involved.

I can only guess given the information you provided about adding multi-tenancy, is that somehow you may have null values in the tenant Id that may be passed on to this index from previous records?

Hope it helps.
Marco
Marco,

Ho do I run the app in debug mode. Just to remove all the breakpoints and just have the debugger started and run the application?? Where to enable Break on all Errors.??

Thanks
Here's a reference on how to debug in OutSystems: http://www.outsystems.com/help/servicestudio/9.1/index.htm#t=Debugging_eSpaces%2FDebug_an_eSpace.htm

Also, if you run multiple espace in your app, the node that's throwing may be in a referenced eSpace, which requires you to debug that one and set your Entry eSpace.  But to get started, see screenshot below:

Marco Asteriti wrote:

I see where the error is happening it is inside the a action

The error says in the action CLDDocument_CreateorUpdate. But when I see in the CLDDocument_CreateorUpdate looks good.

And this works prfectly without mulitenant property but shows in all tenant. Here I am not able to find the issue.
Also, if you run multiple espace in your app, the node that's throwing may be in a referenced eSpace, which requires you to debug that one and set your Entry eSpace.  But to get started, see screenshot below:

 
 
So, if the error is occurring on the CreateOrUpdateCLDDocument node, you just need to verify what parameter values are being passed in (or in this case, assigned to the CLDDocument variable you're creating/updating).

You can do this in the debugger, but need to catch the error in the referenced eSpace where that CLDDocument_CreateOrUpdate Action resides.

To do this, make sure your entry espace was published after the referenced espace (republish it if that's not the case).

Open the referenced eSpace, in the main menu at the top select Debugger > Select Entry eSpace, and choose the entry espace where you have that WidgetCLD block.

Then, first activate the debugger in the entry espace, then activate it in the referenced eSpace.  The order is important as OS debugging temperamental...if you do a little rain dance that may help get this to work as well.

At this point run the app again and this time it should break on the specific node in your referenced eSpace.  If you're lucky, you may be able to view the values set in the variables passed to the breaking node under one of the tabs ('In Use' or 'Locals') and catch the culprit.

You could also set a manual breakpoint right on that CLDDocument_CreateOrUpdate node, then when debugger breaks there, click the 'Step into' button to walk through the rest of the code in the referenced eSpace.

Best of luck!