Referencing Custom Fields in NetSuite Web Service Calls

NetSuite Technical

Tags: , , ,

This article is relevant if you are working with NetSuite’s SuiteTalk Web Services technologies and you are seeking to insert a transactions (e.g., sales order, invoice).

Background

One of our clients is moving their eCommerce infrastructure to Shopify and they are seeking to have a relative robust integration to their NetSuite One World account.  They selected an integration partner with expertise in Shopify but with relatively new experience working with NetSuite.  Our team is providing advisory support for the endeavor.   The Integration Partner uses technology based on .NET client libraries; however, their core Extraction, Transformation, and Load (ETL) approach uses XML and XSLT.

Debugging and Logging

One of the first things we advise people to do when developing with NetSuite’s Web Services is to go to the Web Services log so you can see what is happening when you interact with the technologies.  It’s important to get comfortable reading the XML fragments to make interpretations of what is happening.  You can get to the log by going to Setup, Integration, Web Services Usage Log.

Custom Fields and NetSuite Record Inserts

Custom fields and records are often troublesome to work with when interacting with NetSuite’s SuiteTalk Web Services technologies.  The difficult stems mostly from a lack of good example documentation.  To help the situation, here is a fragment to add a NetSuite Invoice that also contains custom fields.  Notice the fields are part of a custom fields list array.

<s0:add>
	<q1:record xsi:type="q1:Invoice" xmlns:q1="urn:sales_2014_1.transactions.webservices.netsuite.com">
		<q1:customForm internalId="159"/>
		<q1:entity internalId="117841"/>
		<q1:location internalId="205"/>
		<q1:email/>
		<q1:tranId>RE090138CS</q1:tranId>
		<q1:externalId>RE090138CS</q1:externalId>
		<q1:tranDate>2014-09-24T00:00:00.000-07:00</q1:tranDate>
		<q1:class type="classification" internalId="24"/>
		<q1:billAddressList internalId="57865"/>
		<q1:otherRefNum/>
		<q1:account internalId="121"/>
		<q1:customFieldList>
			<customField xsi:type="StringCustomFieldRef" scriptId="custbodycust_inv" xmlns="urn:core_2014_1.platform.webservices.netsuite.com">
				<value>8523</value>
			</customField>
			<customField xsi:type="StringCustomFieldRef" scriptId="custbody_payment_reference" xmlns="urn:core_2014_1.platform.webservices.netsuite.com">
				<value/>
			</customField>
			<customField xsi:type="StringCustomFieldRef" scriptId="custbody_id007_external_sys_ref" xmlns="urn:core_2014_1.platform.webservices.netsuite.com">
				<value>TEC</value>
			</customField>
		</q1:customFieldList>
		<q1:itemList>
			<q1:item>
				<q1:item internalId="32308"/>
				<q1:location internalId="205"/>
				<q1:quantity>1</q1:quantity>
				<q1:amount>0</q1:amount>
				<q1:description>Item Desc</q1:description>
				<q1:class type="classification" internalId="1"/>
				<q1:taxCode internalId="38"/>
			</q1:item>
		</q1:itemList>
	</q1:record>
</s0:add>

Example Transaction with SOAP Header Information

Here is another example to add a Sales Order with SOAP envelope information:

<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Header>
        <passport xmlns="urn:messages_2013_2.platform.webservices.netsuite.com">
            <email xmlns="urn:core_2013_2.platform.webservices.netsuite.com">marty.zigman@prolecto.com</email>
            <password xmlns="urn:core_2013_2.platform.webservices.netsuite.com">************</password>
            <account xmlns="urn:core_2013_2.platform.webservices.netsuite.com">856865</account>
            <role internalId="3" xmlns="urn:core_2013_2.platform.webservices.netsuite.com"/>
        </passport>
        <preferences xmlns="urn:messages_2013_2.platform.webservices.netsuite.com">
            <warningAsError>false</warningAsError>
        </preferences>
    </soap:Header>
    <soap:Body>
        <add xmlns="urn:messages_2013_2.platform.webservices.netsuite.com">
            <record xsi:type="q1:SalesOrder" xmlns:q1="urn:sales_2013_2.transactions.webservices.netsuite.com">
                <q1:customForm internalId="110"/>
                <q1:entity type="customer" internalId="65443"/>
                <q1:orderStatus>_pendingFulfillment</q1:orderStatus>
                <q1:shipMethod internalId="130"/>
                <q1:shippingCost>60</q1:shippingCost>
                <q1:class type="classification" internalId="9"/>
                <q1:department type="department" internalId="4"/>
                <q1:location type="location" internalId="24"/>
                <q1:itemList>
                    <q1:item>
                        <q1:item type="inventoryItem" internalId="236"/>
                        <q1:quantity>1</q1:quantity>
                        <q1:description>A350W</q1:description>
                    </q1:item>
                </q1:itemList>
                <q1:customFieldList>
                    <customField scriptId="custbody_id001_order_brand" xsi:type="SelectCustomFieldRef" xmlns="urn:core_2013_2.platform.webservices.netsuite.com">
                        <value internalId="1"/>
                    </customField>
                </q1:customFieldList>
            </record>
        </add>
    </soap:Body>
</soap:Envelope>

NetSuite Technical Advisor

Our team is often asked to hold advisory roles for getting the most out of NetSuite.  If you would like help with your NetSuite project, contact us.

Be Sociable, Share!

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - YouTube

About Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

Biography • Website • X (Twitter) • Facebook • LinkedIn • YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *