hey all. I’m using the SOAP API, and I’m having is...
# suitetalkapi
b
hey all. I’m using the SOAP API, and I’m having issues setting the
costEstimate
field on the subrecords within the
SalesOrderItemList
sublist of
SalesOrder
. Here’s the error message:
Copy code
type=\"ERROR\"><platformCore:code>INSUFFICIENT_PERMISSION</platformCore:code><platformCore:message>You do not have permissions to set a value for element item.costestimate due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases.</platformCore:message><
and here’s my SOAP message:
Copy code
<record externalId=\"lkj209lkjasjkmnsb\" xsi:type=\"tranSales:SalesOrder\">
    <tranSales:entity internalId=\"3\"/>
    <tranSales:itemList replaceAll=\"true\">
        <tranSales:item>
            <tranSales:amount>50</tranSales:amount>
            <tranSales:costEstimate>47.5</tranSales:costEstimate>
            <tranSales:costEstimateType value=\"_custom\"></tranSales:costEstimateType>
            <tranSales:item internalId=\"225\"/>
            <tranSales:poRate>47.5</tranSales:poRate>
            <tranSales:quantity>1</tranSales:quantity>
            <tranSales:rate>50.000000</tranSales:rate>
        </tranSales:item>
        <tranSales:item>
            <tranSales:amount>50</tranSales:amount>
            <tranSales:costEstimate>48.5</tranSales:costEstimate>
            <tranSales:costEstimateType value=\"_custom\"></tranSales:costEstimateType>
            <tranSales:item internalId=\"225\"/>
            <tranSales:poRate>48.5</tranSales:poRate>
            <tranSales:quantity>1</tranSales:quantity>
            <tranSales:rate>50.000000</tranSales:rate>
        </tranSales:item>
    </tranSales:itemList>
    <tranSales:tranDate>2023-01-25T00:00:00+00:00</tranSales:tranDate>
</record>
any suggestions on what might be wrong? note: I’m able to create/update/upsert this record if I exclude the
costEstimate
field. I’m also able to upsert the whole record via the REST API, but I’d like to do it via SOAP to take advantage of batching.
b
whatever you are using to generate the xml is doing it incorrectly
costEstimateType is a string
b
@battk without costEstimate, this xml works. and sets costEstimateType correctly. If I put the costEstimateType enum string in the context of the xml element, I get an error in the api response
the
costEstimate
field is what’s giving me trouble unfortunately
b
you cant set the cost estimate without setting the cost estimate type
👍 1
b
@battk any chance you happen to have some examples of what you’d expect the XML to look like? also, wondering what WSDL version you’re using
I’m on
WSDL_v2021_1_0
b
I gotcha. What I’m experiencing in practice is that when I send the field like this:
Copy code
<tranSales:costEstimateType>_custom</tranSales:costEstimateType>
i get an error. but when i make an upsert call like this:
Copy code
<tranSales:costEstimateType value=\"_custom\"></tranSales:costEstimateType>
it works and sets the costEstimateType
going to try quoting the value in the xml element content and a couple other variants
b
Copy code
<tranSales:costEstimateType value=\"_custom\"></tranSales:costEstimateType>
should not set the cost estimate type at all, you might want to try setting it to other valid values to make sure
👀 1
👍 1
if you are guessing how your xml should look like
🙌 1
then the easiest way is to make the transation in the ui
🙌 1
then get it via soap
ideally using the same user/role in both the ui and soap if you want to debug permission issues
b
@battk you saved my butt here. I messed around with the raw XML and this works:
Copy code
<record externalId=\"lkj209lkjasjkmnsb\" xsi:type=\"tranSales:SalesOrder\">
	<tranSales:entity internalId=\"3\"/>
	<tranSales:itemList replaceAll=\"true\">
		<tranSales:item>
			<tranSales:amount>50</tranSales:amount>
			<tranSales:costEstimate>47.5</tranSales:costEstimate>
			<tranSales:costEstimateType xsi:type=\"xsd:string\">_custom</tranSales:costEstimateType>
			<tranSales:item internalId=\"225\"/>
			<tranSales:poRate>47.5</tranSales:poRate>
			<tranSales:quantity>1</tranSales:quantity>
			<tranSales:rate>50.000000</tranSales:rate>
		</tranSales:item>
		<tranSales:item>
			<tranSales:amount>50</tranSales:amount>
			<tranSales:costEstimate>48.5</tranSales:costEstimate>
			<tranSales:costEstimateType xsi:type=\"xsd:string\">_custom</tranSales:costEstimateType>
			<tranSales:item internalId=\"225\"/>
			<tranSales:poRate>48.5</tranSales:poRate>
			<tranSales:quantity>1</tranSales:quantity>
			<tranSales:rate>50.000000</tranSales:rate>
		</tranSales:item>
	</tranSales:itemList>
	<tranSales:tranDate>2023-01-25T00:00:00+00:00</tranSales:tranDate>
</record>
like you said, it was an issue with the construction of the
costEstimateType
field. going to look into cleaning up my XML generation. I really appreciate your help in locating the issue 🙏
very weird that this was accepted by the api
Copy code
<tranSales:costEstimateType value=\"_custom\"></tranSales:costEstimateType>
anyways, just to document for anyone else who runs into a similar thing, seems like the issue was missing specification of the
xsi:type
attribute. needed to look like this
Copy code
<tranSales:costEstimateType xsi:type=\"xsd:string\">_custom</tranSales:costEstimateType>