js 获取当前日期+时间-CarlZeng

nlapiDateToString(new Date())new Date() 可以得到当前日期.var cur_time = (new Date()).getTime(); 获取当前时间.——————————————Example 1The following example uses nlapiTransformRecord to cre…

nlapiDateToString(new Date())

new Date() 可以得到当前日期.

var cur_time = (new Date()).getTime(); 获取当前时间.

-—————————————–

Example 1

The following example uses nlapiTransformRecord to create an Item Fulfillment record from an existing Sales Order record.

var itemfulfillment = nlapiTransformRecord(‘salesorder’, 1500, ‘itemfulfillment’)

itemfulfillment.setFieldValue(‘trandate’, nlapiDateToString(new Date()) )

Example 2

The next script shows how to create an Item Receipt record from a Purchase Order.

function trans()

{

var fromrecord;

var fromid;

var torecord;

var trecord;

var qty;

fromrecord = ‘purchaseorder’;

fromid = 26 ; // Transform PO with ID = 26 ;

torecord = ‘itemreceipt’;

// Transaform a record with given id to a different record type.

// For example - from PO to Item Receipt

// Get the object of the transformed record.

trecord = nlapiTransformRecord(fromrecord, fromid, torecord,true);

qty = trecord.getLineItemValue(‘item’, ‘quantity’, 1 );

trecord.setLineItemValue(‘item’, ‘quantity’, 1, ‘2’ );

var idl = nlapiSubmitRecord(trecord, true);

nlapiSendEmail(-5, -5, ‘Transform Email’ + ‘Original Qty =

‘ + qty + ‘ ‘ + ‘Record Created = ‘ + idl , null);

}

Example 3

The following script shows how to create a Build item record from an Assembly record.

/* Assembly item Name = Computer and Id = 328

Location Name = West and Id = 3 // When Multi Location inventory is enabled

2 Member components of Assembly item

Member 1 Name = CPU - Quantity = 2

Member 2 Name = Memory - Quantity = 4

*/

function transformtest1()

{

var fromRecord = ‘assemblyitem’;

var fromId = 328;

var toRecord = ‘build’;

var defaultV = new Array();

defaultV.quantity =1; // Default quantity to build

defaultV.location =’3’; // Default location id

var record = nlapiTransformRecord(fromRecord, fromId, toRecord, defaultV);

var id = nlapiSubmitRecord(record, false);

}

个性化需求沟通 扫客服加V加群: