SDATA Error Message When POSTing/Creating AR_Customer

When attempting to use SDATA to POST an AR_Customer, I'm receiving an error:

<sdata:diagnosis>
<sdata:severity>error</sdata:severity>
<sdata:sdataCode>ApplicationDiagnosis</sdata:sdataCode>
<sdata:applicationCode xsi:nil="true" />
<sdata:message>Exception caught during the processing of a message
Verb: POST
Uri: https://[address]/sdata/[app]/[contract]/[company]/AR_Customer</sdata:message>
<sdata:stackTrace>System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Sage.Utilities.Collections.MarshalByRefList`1.get_Item(Int32 index)
at Sage.MAS.SData.SqlRequestHandler`1.GetEntryFromStream(FeedSerializer feedSerializer, Stream stream)
at Sage.MAS.SData.MAS90Adapter.PvxAdapter.ExecuteOperation(OperationType eOperType, IRequest request, RequestContext requestContext, IRequestHandler requestHandler, FeedEntry&amp; aFeedEntry)
at Sage.MAS.SData.MAS90Adapter.CMAS90Adapter.HandlePostRequest(IRequest request, RequestContext requestContext, IRequestHandler requestHandler)
at Sage.FR.SData.Adapter.HandleRequest(IRequest request)</sdata:stackTrace>
<sdata:payloadPath />
</sdata:diagnosis>
</sdata:diagnoses>

Thank you in advance for any help!

  • 0

    Greetings,

    It would help if you can share the XML payload being transmitted.  The data for one one of the columns is being set incorrectly.  My guess is that this is either ARDivisionNo which can only be two digits and must already be on file in AR Division Maintenance or CustomerNo which should only be 7 characters.

    Thanks,

    Kent

  • 0 in reply to Kent Mackall

    Thanks for the quick reply, Kent! I've confirmed hat the ARDivisionNo is on file. Regarding CustomerNo: I tried excluding it as well, to no avail. See below for the payload. (The majority of the fields are a copy from the ABC company)

    <?xml version="1.0" ?>

    <entry xmlns:sdata="schemas.sage.com/.../1"

          xmlns:xsi="www.w3.org/.../XMLSchema-instance"

          xmlns="www.w3.org/.../Atom">

     <id/>

     <title/>

     <content/>

     <sdata:payload>

       <AR_Customer>

         <ARDivisionNo>01</ARDivisionNo>

         <CustomerName>Great Matter</CustomerName>

         <CustomerNo>0000025</CustomerNo>

         <AddressLine1>123 Anywhere St.</AddressLine1>

         <AddressLine2>Suite A</AddressLine2>

         <AddressLine3 xsi:nil="true" />

         <City>Los Angeles</City>

         <State>CA</State>

         <ZipCode>91234</ZipCode>

         <CountryCode>USA</CountryCode>

         <TelephoneNo>(310) 555-1212</TelephoneNo>

         <TelephoneExt></TelephoneExt>

         <FaxNo xsi:nil="true"/>

         <EmailAddress>[email protected]</EmailAddress>

         <URLAddress>www.greatmatter.com</URLAddress>

         <EBMEnabled>Y</EBMEnabled>

         <EBMConsumerUserID xsi:nil="true" />

         <BatchFax>N</BatchFax>

         <DefaultCreditCardPmtType xsi:nil="true" />

         <ContactCode>ADAM WEISS</ContactCode>

         <ShipMethod>UPS BLUE</ShipMethod>

         <TaxSchedule>WI MILMIL</TaxSchedule>

         <TaxExemptNo xsi:nil="true" />

         <TermsCode>01</TermsCode>

         <SalespersonDivisionNo>01</SalespersonDivisionNo>

         <SalespersonNo>0100</SalespersonNo>

         <SalespersonDivisionNo2 xsi:nil="true" />

         <SalespersonNo2 xsi:nil="true" />

         <SalespersonDivisionNo3 xsi:nil="true" />

         <SalespersonNo3 xsi:nil="true" />

         <SalespersonDivisionNo4 xsi:nil="true" />

         <SalespersonNo4 xsi:nil="true" />

         <SalespersonDivisionNo5 xsi:nil="true" />

         <SalespersonNo5 xsi:nil="true" />

         <Comment>Call Ed for credit approval.</Comment>

         <SortField>AMER</SortField>

         <TemporaryCustomer xsi:nil="true" />

         <CustomerStatus>A</CustomerStatus>

         <InactiveReasonCode xsi:nil="true" />

         <OpenItemCustomer>Y</OpenItemCustomer>

         <ResidentialAddress>N</ResidentialAddress>

         <StatementCycle>M</StatementCycle>

         <PrintDunningMessage>Y</PrintDunningMessage>

         <CustomerType>A2</CustomerType>

         <PriceLevel>1</PriceLevel>

         <DateLastActivity>2010-05-31T00:00:00-05:00</DateLastActivity>

         <DateLastPayment>2010-05-31T00:00:00-05:00</DateLastPayment>

         <DateLastStatement>2010-05-01T00:00:00-05:00</DateLastStatement>

         <DateLastFinanceChrg>2010-04-30T00:00:00-05:00</DateLastFinanceChrg>

         <DateLastAging>2006-06-14T00:00:00-05:00</DateLastAging>

         <DefaultItemCode>/WIDGET</DefaultItemCode>

         <DefaultCostCode xsi:nil="true" />

         <DefaultCostType xsi:nil="true" />

         <CreditHold>N</CreditHold>

         <PrimaryShipToCode>2</PrimaryShipToCode>

         <DateEstablished>2009-01-01T00:00:00-06:00</DateEstablished>

         <CreditCardGUID xsi:nil="true" />

         <DefaultPaymentType xsi:nil="true" />

         <EmailStatements>N</EmailStatements>

         <NumberOfInvToUseInCalc>6</NumberOfInvToUseInCalc>

         <AvgDaysPaymentInvoice>4</AvgDaysPaymentInvoice>

         <AvgDaysOverDue>0</AvgDaysOverDue>

         <CustomerDiscountRate>0.0000</CustomerDiscountRate>

         <ServiceChargeRate>1.5000</ServiceChargeRate>

         <CreditLimit>120000.0000</CreditLimit>

         <LastPaymentAmt>864.2500</LastPaymentAmt>

         <HighestStmntBalance>3462.5400</HighestStmntBalance>

         <UnpaidServiceChrg>43.8900</UnpaidServiceChrg>

         <BalanceForward>0.0000</BalanceForward>

         <CurrentBalance>5732.3600</CurrentBalance>

         <AgingCategory1>0.0000</AgingCategory1>

         <AgingCategory2>0.0000</AgingCategory2>

         <AgingCategory3>0.0000</AgingCategory3>

         <AgingCategory4>0.0000</AgingCategory4>

         <OpenOrderAmt>8422.6400</OpenOrderAmt>

         <RetentionCurrent>0.0000</RetentionCurrent>

         <RetentionAging1>0.0000</RetentionAging1>

         <RetentionAging2>0.0000</RetentionAging2>

         <RetentionAging3>0.0000</RetentionAging3>

         <RetentionAging4>0.0000</RetentionAging4>

         <SplitCommRate2>0.0000</SplitCommRate2>

         <SplitCommRate3>0.0000</SplitCommRate3>

         <SplitCommRate4>0.0000</SplitCommRate4>

         <SplitCommRate5>0.0000</SplitCommRate5>

         <DateCreated>2006-06-14T00:00:00-05:00</DateCreated>

         <TimeCreated>10.74974</TimeCreated>

         <UserCreatedKey>0000000000</UserCreatedKey>

         <DateUpdated>2015-05-06T00:00:00-05:00</DateUpdated>

         <TimeUpdated>17.88852</TimeUpdated>

         <UserUpdatedKey>0000000003</UserUpdatedKey>

         <UseSageCloudForInvPrinting>N</UseSageCloudForInvPrinting>

       </AR_Customer>

     </sdata:payload>

    </entry>

  • 0 in reply to Great Matter

    Greetings,

    Thanks for posting the XML.  This looks like you copied every column form the table to build the payload.  That is not the best approach for using SData.  Not every column in the table can be set through SData/BOI, etc.  Some columns are controlled by the program code.  In particular the User and Date Created/Updated columns should cannot be set.

    You can use the File Layouts and Program Information provided in Sage 100 to help you determine if a column can be set by looking at the Column Description/Notes reference.  If the column notes show Read Only: Y then that column cannot be set.

    Example:

     87  UserCreatedKey. . . . . . . .    10 SNY  Creation User ID. . . . . . . .USER

                                                                         Read Only:Y Mask:0000000000

                                                                         FmtType:ZEROFILL ChngTag:Copy

                                                                         Min/DateCreated$

    A better approach is to create a test record in Sage 100 making note of the column values you are required to enter in order to create a record.  Then build your SData XML Payload using only those columns.  Once that is working you can add addtional columns as needed.

    For example, in order to create a customer record in AR_Customer, these are the only columns required:

     ARDivisionNo

     CustomerNo

     SalerpersonDivisionNo

     SalespersonNo

    Lastly, if you have not taken a look at our Sage 100 SData sample website/demo I reccomend that you do so.  This is available for Partners to download from SageSell.  If your comapny is not a Sage 100 Partner, please ask your Partner/Reseller to download this for you.

    Thank you,

    Kent

  • 0 in reply to Kent Mackall

    Thanks, Kent! I've reduced the payload, but am still getting the same error... I've created an identical record on Sage through the interface without issue; could there be something else I'm missing? I noticed in the interface that the division number is part of the Customer Number, but when I try the other formats, that doesn't seem to matter. Thank you again for helping!

    <?xml version="1.0" ?>

    <entry xmlns:sdata="schemas.sage.com/.../1"

          xmlns:xsi="www.w3.org/.../XMLSchema-instance"

          xmlns="www.w3.org/.../Atom">

     <id/>

     <title/>

     <content/>

     <sdata:payload>

       <AR_Customer>

         <ARDivisionNo>01</ARDivisionNo>

         <CustomerNo>TEST</CustomerNo>

         <SalespersonDivisionNo>01</SalespersonDivisionNo>

         <SalespersonNo>0100</SalespersonNo>

       </AR_Customer>

     </sdata:payload>

    </entry>

    <?xml version="1.0" ?>

    <entry xmlns:sdata="schemas.sage.com/.../1"

          xmlns:xsi="www.w3.org/.../XMLSchema-instance"

          xmlns="www.w3.org/.../Atom">

     <id/>

     <title/>

     <content/>

     <sdata:payload>

       <AR_Customer>

         <ARDivisionNo>01</ARDivisionNo>

         <CustomerNo>01-TEST</CustomerNo>

         <SalespersonDivisionNo>01</SalespersonDivisionNo>

         <SalespersonNo>0100</SalespersonNo>

       </AR_Customer>

     </sdata:payload>

    </entry>

  • 0 in reply to Great Matter

    Greetings,

    You didn't mention if you have a copy of the Sage 100 SData sample website?  This contains an example of creating a new customer in AR Customer Maintenance and I suggest that you obtain a copy of that sample website and review it to help with this issue.  All the code for the sample website is available as part of the download from SageSell.

    Just for starters, here is an excerpt of the AR Customer payload being built in the sample:  Note:this uses variables for the values being submitted since it is part of a larger set of code.

    var aUrl = '/sdata/MasApp/MasContract/' + gCompany + '/AR_Customer(\'' + ardivisionno + ';' + customerno + '\')';
    var aPayload = '<AR_Customer sdata:uri="' + aUrl + '" xmlns="">';
      aPayload += '<ARDivisionNo>' + ardivisionno + '</ARDivisionNo>';
      aPayload += '<CustomerNo>' + customerno + '</CustomerNo>';
      aPayload += '<SalespersonDivisionNo>' + ardivisionno + '</SalespersonDivisionNo>';
      aPayload += '<SalespersonNo>' + salespersonkey[1] + '</SalespersonNo>';
      aPayload += '</AR_Customer>';
    sdataPost(
      aUrl,
      aPayload,
      'AR_Customer'
    );

    Thank you,

  • 0 in reply to Kent Mackall

    Unfortunately, I don't have access to it, as far as I know. I've requested that our client (who is a partner) get us set up on that.

    In the meantime, though, assuming we're generating the XML properly, and have submitted it properly, what else could be causing this error, or is there a way to make it more verbose so that we can debug it further? (I get the same error even if the entire request is empty!)

  • 0 in reply to Great Matter

    Greetings,

    Without access to the system and seeing the full code and POST process, I don't have any more information.  I firmly believe that when you get access to the Sage 100 SData demo website that will help you resolve the issue.

    If you need more assistance, please contact Sage Customer Support and open a case so that we can gather all the information and schedule the appropriate resources to assist you,

    Thank you,

    Kent