To calculate Mileage on an Expense Report (Navigation Path: Transactions > Employees > Enter Expense Report).
Follow the steps to create custom fields and Script to calculate Expense Report:
1. Create Transaction Line custom Field "Distance".
a. Navigate to Setup > Customization > Transaction Line Fields.
b. Label = Distance (Note : user can change this to desired label)
c. ID = _distance (Note: Auto-generated by system, but can be changed to user's preference. If changed, please make sure to do the necessary changes in the code.)
d. Type = Decimal
e. Store Value = Checked
f. In the "Applies To" Subtab, check "Expense" and "Expense Report".
g. In the "Display" subtab, Display Type = Normal.
h. Click Save.
2. Create another Transaction Line custom Field "Rate".
a. Navigate to Setup > Customization > Transaction Line Fields.
b. Label = Rate (Note: user can change this to desired label)
c. ID = _rate (Note: Auto-generated by system, but can be changed to user's preference. If changed, please make sure to do the necessary changes in the code.)
d. Type = Decimal
e. Store Value = Checked
f. In the "Applies To" Subtab, check "Expense" and "Expense Report".
g. In the "Display" subtab, Display Type = Normal.
h. Click Save.
3. Write the JavaScript code for calculating Mileage
(Note: This scripts work only for "Travel" keyword in the "Category")
a. Create a JavaScript file "Calculate_Mileage.js".
b. Copy - paste the code below:
4. Create a Client Side Script to "Calculate Mileage".
a. Navigate to Setup > Customization > Scripts > New. Select Type as "Client".
b. Name = Calculate_Mileage (Note: user can change this to desired label )
c. ID = _calculate_mileage
d. Under the "Scripts" subtab, Script File = Calculate_Mileage.js (Note: Add the JavaScript file created in Step - 3) and Validate Line Function = xExpenseReport.
e. Under the "Deployments" subtab, set Applies To = Expense Report, ID = _calculate_mileage, Deployed = Yes, Status = Testing/Released.
f. Click Save.
Now once user creates an Expense Report and selects "Travel" in category, and insert Distance and Rate in the respective line fields, clicking the "Add" button will compute the "Mileage" and assign it to "Amount" field.
DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Netsuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Netsuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Netsuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Netsuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
No comments:
Post a Comment