Technical Resources
Sandbox Refresh Steps
4min
refreshing a sandbox may require additional steps for breadwinner for netsuite if you do not want to connect or use salesforce sandbox to your production netsuite account, you will need to delete the existing breadwinner for netsuite data from your sandbox follow the steps below to complete this process visit the breadwinner tab this will remove the production credentials and netsuite object configuration assign the admin breadwinner permission set to the user that is going to sync the data (needs to be a user with the salesforce admin profile) optional delete production data—during a refresh, salesforce pulls in production data, including those in our custom objects (customers, vendors, sales orders, invoices, etc ) this is optional, but it should be done to limit confusion and for security reasons breadwinner setup tab > troubleshoot > general open up the "delete netsuite data in salesforce" section select the 'others' tab (this may be your only option) delete all the records—salesforce limits us to deleting 10k records per click see the "delete production netsuite data from the sandbox" section below if you have a large amount of data connect to the netsuite sandbox configure ns object sync to match production (these records were deleted in sandbox step 1) optional use the additional where filter script below to add "additional where filters" to the netsuite object record for companies with large amounts of data, this will help with the sync time to only pull in 'some' of the data click the "start syncing netsuite objects" button on the breadwinner setup page additional where filter script this will help if you have a large amount of data but don't need all the netsuite data in your salesforce sandbox this will add a date filter so we only bring in the last x days worth of data // add your netsuite org id string netsuiteorgid = 'xxxxxxxxx'; / add your where filter to filter by date, you need to convert the current date/time into an epoch date which you can do here https //www epochconverter com/ / string additionalwherefilter = 'datecreated>1672531200'; / to update all the objects with the same filter, leave the objectlabellist empty otherwise, add the list of objects to the objectlabellist supported object labels are item, customer, contact, vendor, estimate, salesorder, cashsale, invoice, returnauthorization, cashrefund, creditmemo, customerpayment, itemfulfillment purchaseorder, vendorbill, vendorpayment, vendorcredit, check / list\<string> objectlabellist = new list\<string>{}; //list\<string> objectlabellist = new list\<string>{'customer','contact','salesorder','invoice','creditmemo'}; string qry = 'select id, name, breadwinner ns additional where filter c ' + 'from breadwinner ns bw netsuite object c ' + 'where ' + 'name like \\'' + netsuiteorgid + ' %\\' and ' + 'breadwinner ns netsuite org id c = \\'' + netsuiteorgid + '\\' and ' + 'breadwinner ns subsidiary r breadwinner ns internalid c = null and ' + 'breadwinner ns subsidiary r name = \\'' + netsuiteorgid + '\\''; if (!objectlabellist isempty()){ qry += ' and breadwinner ns netsuite object label c in (\\'' + string join(objectlabellist,'\\',\\'') + '\\')'; } system debug(qry); list\<breadwinner ns bw netsuite object c> nsobjectlist = database query(qry); list\<breadwinner ns bw netsuite object c> updatensrecordlist = new list\<breadwinner ns bw netsuite object c>(); for(breadwinner ns bw netsuite object c nsrecord nsobjectlist){ breadwinner ns bw netsuite object c bwno = new breadwinner ns bw netsuite object c( id=nsrecord id, breadwinner ns additional where filter c = additionalwherefilter ); updatensrecordlist add(bwno); } system debug('updating records count '+nsobjectlist size()); system debug('updating records'+nsobjectlist); // uncomment the line below after verifying the debug logs have the correct org id, object label, and filter // update updatensrecordlist; delete production netsuite data from the sandbox due to salesforce limits, you can only delete 10,000 records at a time depending on the amount of data, you may also run into dml, cpu, or heap size errors, but rerunning the script over and over will eventually delete all the records you cannot delete production subsidiaries using apex code to delete production subsidiaries, go to the breadwinner for netsuite tab, then click the "delete netsuite subsidiaries" button on the troubleshoot > general > delete netsuite data in salesforce > others tab // add your netsuite production org id string productionnetsuiteorgid = 'xxxxxxxxx'; / this is the list of objects that the data will be deleted from / list\<string> objlist = new list\<string>{ 'breadwinner ns bw location c', 'breadwinner ns bw metadata c', 'breadwinner ns bw currency c', 'breadwinner ns bw price level c', 'breadwinner ns bw employee c', 'breadwinner ns bw item c', 'breadwinner ns bw company c', 'breadwinner ns bw contact c', 'breadwinner ns bw estimate c', 'breadwinner ns bw sales order c', 'breadwinner ns bw invoice c', 'breadwinner ns bw return authorization c', 'breadwinner ns bw credit memo c', 'breadwinner ns bw payment c', 'breadwinner ns bw item fulfillment c', 'breadwinner ns bw bill c', 'breadwinner ns bw purchase order c', 'breadwinner ns bw check c', 'breadwinner ns bw address c', 'breadwinner ns bw line item c', 'breadwinner ns bw payment transaction c', 'breadwinner ns bw package c', 'breadwinner ns bw item price c', 'breadwinner ns bw inventory location c' }; for (string obj objlist){ list\<object> recordlist = database query('select id, name from ' + obj + ' where breadwinner ns netsuite org id c = productionnetsuiteorgid limit 10000'); system debug(recordlist); // uncomment the line below after verifying the debug logs // database delete(recordlist,false); } you could also put the above code into a batch apex class that calls itself until all the records are deleted and have it run after the sandbox refresh