Wednesday, December 7, 2016

3. Adding linked fields



1.      You need to create two lists, one for Type and one for Subtype.
In this case we used the following fields:
List - Support Types
List - Support SubTypes


2.      We then Created a custom Record type to link the Types and the subtypes it has two fields.
Support Issue Type -  a single value field looking at the Support Type List
Support Issue Subtype – a multi select field that looks at the Support SubTypes list

The Custom Record Type is:
Support Issue Categories

3.      We then create one Support Issue Category Record for each Type


4.      Create 2 new  CRM fields
Sub-Type                      custevent_tc_col_subtype                            List/Record                Columbus Support SubTypes                                                                                                     Y                                            
Type                               custevent_tc_col_type                    List/Record        VSC Support Issue Categories

On the SubType field on the sourcing and filtering tab we set the Source List Field and the Source From Field.
The Source List field is set to Type.
The Source From field is set to Support Issue SubType


5.      Add the Type and Subtype fields to the cases form



After the lists are created you can add additional type and subtypes by doing the following:


Adding New Types and Subtypes to cases
Add the new Type
1.       In NetSuite navigate to Customization->Lists, Records and Fields->Lists
2.       Find the list called Support Issues.
3.       Open the List and add the new Value
Add the new SubTypes
1.       In NetSuite navigate to Customization->Lists, Records and Fields->Lists
2.       Find the list called Support SubIssue
3.       Open the list and add/inactivate values
4.       Save the record, once the record is saved the entry will be given an ID
Associate the Type and Sub-Type records
1.       In NetSuite navigate to Customization->Lists, Records and Fields->Record Types
2.       Find the Record Type called Support Issue Categories
a.       If you are updating an existing Category click list and open the correct document
b.      If you are creating a new category click New Record
3.       Select the Support Issue Type
4.       Select the Associated Support Issues(use ctrl to select multiple)
5.       Save the record and check the Case form to ensure your new values are there

Wednesday, May 4, 2016

View the XML for a NetSuite record

To view the XML Representation of a NetSuite Record add &xml=T to the end of the URL.

Monday, March 14, 2016

2. Replies to Locked/Closed Cases

 To handle replies to cases that have been locked and closed(our system is set to lock cases after 15 days).

We found that users were responding to old cases, in some instances the employee previously assigned to the case was no longer with the company. The message would get attached to the old case, but no one was aware.

 I created the following script that is attached to the Message Record.
The script creates a New case and assigns it to the tech support queue.


function messageAfterSubmit(type)
{
//************************************************** ******************************
//************************************************** ******************************
// This script is run when new messages are sent into NetSuite
//Purpose: To Capture messages sent into closed and locked cases
//Outcome: A new cases will be created and assigned to Tech Support
//
//New cases are created only if the following criteria are met:
// 1. The case is for the our Subsidiary(internal ID: 1)
// 2. The case has a status of Closed(id 5) or Closed on First Contact(7)
// 3. The case has been closed for more than 15 days(Locked by the system)
//
//************************************************** ******************************
//************************************************** ******************************


var record = nlapiGetNewRecord();
var recordId = record.getFieldValue('activity');
var isCase = false;

if (recordId != null && recordId != '')
{
            // Do a case search and determine if the id is indeed of a case
            var filters = new Array();

             var search = nlapiSearchRecord('supportcase', null, filters, null);
             if (search != null && search != '')
                 {
                    isCase = true;
                 }
             if (isCase)
               {
                 var subsidiary=nlapiLookupField('supportcase',recordId ,'subsidiary');
                 //Check the subsidiary, 1 is the subsidiary for our subsidiary, this script will only run for   our cases
                 if(subsidiary=='1'){
                    var originalcasenum=nlapiLookupField('supportcase',rec ordId,'casenumber');
                   var initMessage=record.getFieldValue('subject');
                   var currentStatus = nlapiLookupField('supportcase',recordId,'status');
                   var testuser=nlapiLookupField('supportcase',recordId,' casenumber');

//Check to see that the cases is closed
                       if(currentStatus=='5'||currentStatus=='7'){ //5 is the internal id for closed, 7 is the internal id for closed on first contact
//Check for to see if the case has been closed for x days
// Get the Current Time
//************************************************** ****************************
//**********************Date and Time Functions*********************************
//************************************************** ****************************
// Get the current date
                          var currentDate = new Date()
                          var month = currentDate.getMonth()
                          var day = currentDate.getDate()
                         var year = currentDate.getFullYear()
                         var caseStatus="";
                         actualDate=month + "/" + day + "/" + year;

// Get the Current Time
                         var currentTime = new Date()
                         var hours = currentTime.getHours()
                         var minutes = currentTime.getMinutes()
                         var ampm="";

                         if (minutes < 10){
                             minutes = "0" + minutes
                         }

                         if(hours > 11){
                            ampm="pm";
                         } else {
                            ampm="am";
                         }
                         DateActual = new Date(year,month,day,hours,minutes,0);
                         actualTime=hours + ":" + minutes + " "+ampm;

                         var sDate = new Date(Date.parse(DateActual,"MM/dd/yyyy hh:mm:ss"));
// Get the Closed Date

                         var EndDate = nlapiLookupField('supportcase',recordId,'enddate') ;
                         var closedDate= new Date(Date.parse(EndDate,"MM/dd/yyyy hh:mm:ss"));
                         var timediff=sDate-closedDate;

                         timediff=((timediff/1000/60)/60)/24; // difference in days between closed date and now divided by 1000 , divided by seconds, minutes, hours

//************************************************** ****************************
//****************** End Date Functions ****************************************
//************************************************** ****************************

// Check to see that the cases is at least 15 days old(locked)
                         if(timediff>15){
                           var newMSG=initMessage+' - RESPONSE TO LOCKED CASE #'+originalcasenum;
                         var sCase = nlapiCopyRecord('supportcase', recordId); //Copy the original case record

                         sCase.setFieldValue('title', newMSG);
                         sCase.setFieldValue('status', 1); //Internal ID for status 'Not Started'
                         sCase.setFieldValue('assigned',77115); //Internal id of the Technical Support Group

// Blank out fields
                         sCase.setFieldValue('custevent_tc_case_scheduled_c allback','');
                         sCase.setFieldValue('custevent_tc_scheduled_callba ck_time','');
                         sCase.setFieldValue('custevent_tc_case_assigned',' ');

//Mapping Fields
                         sCase.setFieldValue('custevent_tc_init_response',' ');
                         sCase.setFieldValue('custevent_tc_initial_close',' ');
                         sCase.setFieldValue('custevent_hoursonhold','');
                         sCase.setFieldValue('custevent_mapping_submitted_b y','');
                         sCase.setFieldValue('custeventonhold','');
                         sCase.setFieldValue('custeventeventonholdtime','') ;
                         sCase.setFieldValue('custeventrestarted','');
                         sCase.setFieldValue('custeventrestartedtime','');

//Submit the new record to NetSuite
                         id = nlapiSubmitRecord(sCase, true);

//************************************************** ***************************
//************************* Email the Customer ******************************
//************************************************** ***************************
// var initEmail=record.getFieldValue('author');
// var outSubject=newMSG;
// var outBody=newMSG;
// nlapiLogExecution('Debug', 'Sender = ', initEmail);
// nlapiSendEmail(7, initEmail, outSubject, outBody);

                                                  }

                                        }
                               }
                         }
                     }
}

1. Mass Delete Script


** be careful with this once the records are deleted they are gone for good, if you have a sandbox or dev account I would recommend trying it there first.

1. Take the following code paste it into notepad and save it as a .js file and upload the file into your NetSuite file cabinet into the script folder. 

function massDelete(rec_type, rec_id)
{
    try {
        nlapiDeleteRecord(rec_type, rec_id);
        nlapiLogExecution ('DEBUG', rec_id + ' was deleted successfully');
    }
    catch(e) {
        nlapiLogExecution ('DEBUG', rec_id + ' was not deleted\n' + e);
    }
}

2. Create a new Script

3.  select the Mass Update


4.  Select the Script File that you uploaded in Step 1 and enter massDelete for the function


5. Click Save and Deploy

6. Select the Document type that the deployment applies to and set the Status to “Released” and the Execute as Role to “Administrator”

7. Save the Deployment

8. Create  a new Mass Update

9. You should find the script deployment under Custom Updates

10. Open your mass update and set the criteria. Select the criteria to limit which records you want to delete. 

11. Preview and run your Mass Update