Skip to main content
Solved

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

  • 29 December 2022
  • 4 replies
  • 282 views

Forum|alt.badge.img

 

Hi All,

I’m getting the below error in Service Order screen, 

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

 

 

please assist.

Best answer by aaghaei

@sujithra

The below code will do the work for you. You can add more fields to the selector following this footstep:

using PX.Data;
using PX.Objects.CR;
using PX.Objects.CS;

namespace PX.Objects.FS
{
    [PXNonInstantiatedExtension]
    public sealed class USRFSServiceOrderExt : PXCacheExtension<PX.Objects.FS.FSServiceOrder>
    {
        public static bool IsActive() => true;

        #region LocationID
        [PXMergeAttributes(Method = MergeMethod.Merge)]
        [PXSelector(typeof(Search2<Location.locationID,
            LeftJoin<Address, On<Address.addressID, Equal<Location.defAddressID>>>,
            Where<Location.bAccountID, Equal<Current<FSServiceOrder.customerID>>,
                And<Location.isActive, Equal<True>,
                    And<MatchWithBranch<Location.cBranchID>>>>>),
            typeof(Location.locationCD),
            typeof(Location.descr),
            typeof(Address.addressLine1),
            typeof(Address.addressLine2),
            typeof(Address.addressLine3),
            SubstituteKey = typeof(Location.locationCD),
            DescriptionField = typeof(Location.descr))]
        public int? LocationID { get; set; }
        #endregion
    }
}

And this is the screenshot from the Location Selector:

 

 

If you still face error after this change, you may have issues elsewhere.

View original
Did this topic help you find an answer to your question?

4 replies

Laura02
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3135 replies
  • December 29, 2022

Hello @sujithra ,

More information is needed, please.

  • Are you seeing the above message upon opening the Service Orders Preview List?  Or, are you seeing the above message upon selecting a service order to the screen? 
  • Is there any additional information in Tools → Trace? 
  • Is the Service Orders Preview List customized? 
  • What changed since this screen last worked correctly?

 

Thank you!


NuwanTharanga62
Varsity II
Forum|alt.badge.img+1
sujithra wrote:

 

Hi All,

I’m getting the below error in Service Order screen, 

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

 

 

please assist.



Hi @sujithra ,

This is most likely due to a customization or lack of a customization that the screen is looking for. 

If there are NO any ISV customizations; Please unpublished all customizations and see if the issue persists. 

If issue still persists or if you have any ISV customizations I suggest you to create support case on Acumatica (With access)  as this error should be investigate further.

Thanks!


Forum|alt.badge.img
  • Author
  • Freshman II
  • 16 replies
  • December 29, 2022

Hi @laura01,

Yes, I’m trying to customize service order screen.

I’m trying to add column AddressLine1 and AddressLine2 to the existing selector Location Field in Service order screen from Customer Location screen(AR303020). 

 

 

here is my code and not getting any error in Visual studio,

 

 

kindly assist if anything I’m missing/wrong in my code.

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1180 replies
  • Answer
  • December 30, 2022

@sujithra

The below code will do the work for you. You can add more fields to the selector following this footstep:

using PX.Data;
using PX.Objects.CR;
using PX.Objects.CS;

namespace PX.Objects.FS
{
    [PXNonInstantiatedExtension]
    public sealed class USRFSServiceOrderExt : PXCacheExtension<PX.Objects.FS.FSServiceOrder>
    {
        public static bool IsActive() => true;

        #region LocationID
        [PXMergeAttributes(Method = MergeMethod.Merge)]
        [PXSelector(typeof(Search2<Location.locationID,
            LeftJoin<Address, On<Address.addressID, Equal<Location.defAddressID>>>,
            Where<Location.bAccountID, Equal<Current<FSServiceOrder.customerID>>,
                And<Location.isActive, Equal<True>,
                    And<MatchWithBranch<Location.cBranchID>>>>>),
            typeof(Location.locationCD),
            typeof(Location.descr),
            typeof(Address.addressLine1),
            typeof(Address.addressLine2),
            typeof(Address.addressLine3),
            SubstituteKey = typeof(Location.locationCD),
            DescriptionField = typeof(Location.descr))]
        public int? LocationID { get; set; }
        #endregion
    }
}

And this is the screenshot from the Location Selector:

 

 

If you still face error after this change, you may have issues elsewhere.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings