umesh shukla
umesh shukla

Reputation: 171

Populate NetSuite Custom Field

I have added a Custom field in Netsuite 'Test Field' of Record Type Account using NetSuite GUI(Web), but when fetching Account data using Netsuite API, I am getting all build in fields but not getting my custom field. I am using below code to get Account data

 public DataTable getAccountSearchBasic()
        {
            DataTable dtData = new DataTable();
            AccountSearchBasic objSearch = new AccountSearchBasic();

            try
            {
                string errorMsg = "";
                LoginToService(ref errorMsg);

                SearchResult result = _serviceInstance.search(objSearch);

                try
                {
                    _serviceInstance.logout();
                }
                catch (Exception ex)
                {

                }

                List<Account> lstData = new List<Account>();
                if (result.status.isSuccess)
                {
                    for (int i = 0; i <= result.recordList.Length - 1; i += 1)
                    {
                        lstData.Add((Account)result.recordList[i]);
                    }
                }
                dtData = ConvertToDataTable<Account>(lstData);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dtData;
        }

Also please suggest me a way to get all fields (including custom) of a Record (Account, Department, Location) including their datatypes from NetSuite as I have to show these fields on my mapping screen.

Thanks in advance.

Upvotes: 0

Views: 707

Answers (2)

Alex
Alex

Reputation: 1

To get the fields on a record, you may run the get or getlist api which will retrieve all fields with values on the record you are querying.

Upvotes: 0

Jimerson
Jimerson

Reputation: 96

Each Account in result.recordList should have a customFieldList property that is itself a list of "CustomFieldRef" objects. Each of these should represent a custom field on the Account record and will be of a specific subtype, for example "StringCustomFieldRef" or "BooleanCustomFieldRef".

The customFieldList property should be accessible on any record Type that can have custom fields applied to it.

Hope that helps!

Upvotes: 1

Related Questions