In this solution the script sets the value of a custom transaction body field when creating a new sales order. The custom field is of date/time type and has an internal id of 'custbody_current_date'. The Preferences setting for the Date format is 'MM/DD/YYYY' and the Time format is 'hh:mm (24 hours)'.
Create a client script
1. Navigate to Customization > Scripting > Scripts > New > Type = Client.
2. Fill out the Name and ID field.
3. In the Scripts tab, upload the script file below:
function load_current_date(type){
if (type == 'create') {
var temp_date = new Date();
var myDate = nlapiDateToString(temp_date);
var myTime = nlapiDateToString(temp_date, 'timeofday');
var current_date = myDate + ' ' + myTime;
nlapiSetFieldValue('custbody_current_date', current_date);
}
}
4. In the Scripts tab > Page Init function field, type load_current_date.
5. Save and Deploy.
6. In the Deployments page > set Applies To = Sales Order, Execute as Admin = Checked, Deployed = Checked, Status = Released, Log Level = Error.
7. In the Deployments page > Audience > Roles > Set All Roles = Checked.
8. Save.
No comments:
Post a Comment