In this example, the scheduled script closes the case after a certain number of days has passed:
A. Create a case search to filter the cases that should auto-close.
1. Navigate to Lists > Search > Saved Searches > New.
2. Click Case.
3. Enter criteria based on business needs. Ex:
Status is In Progress
Date Last Modified is on or before 30 days ago
4. Click Results tab.
5. Add/Remove fields based on need but make sure that Status is one of the fields.
6. Check the Public check box.
7. Enter a name in the Search Title field. (Ex. Case for Auto-Close)
8. Save.
B. Create a script.
1. Open Notepad. Use the code below:
function caseAutoClose(type)
{
var searchresults = nlapiSearchRecord('supportcase', 'customsearch22');
for (var i in searchresults)
{
var searchresult = searchresults[i];
nlapiSubmitField('supportcase', searchresult.getId(), 'status', 5);
var caseStatus = searchresult.getText('status');
nlapiLogExecution('DEBUG', 'Search Result', caseStatus);
}
}
2. Click File > Save As:
a. File name = [Name].js
b. Save as type = All Files
3. Click Save.
4. In NetSuite, navigate to Customization > Scripting > Scripts > New.
5. Click Scheduled.
6. Provide a name for this script.
7. On the Scripts tab, select the .js file in the Script File field.
8. Set the Function field to caseAutoClose.
9. Click Save and Deploy.
10. On the New Script Deployment Page, set the following:
a. Title
b. ID
c. Status is Scheduled
d. Log Level is Debug
e. Set the desired schedule on the Schedule tab.
12. Click Save.
Note: This is an alternate solution for Enhancement 85364.
No comments:
Post a Comment