如何使用Suitescript 2.0创建发票? [英] How to create invoice using suitescript 2.0?

查看:69
本文介绍了如何使用Suitescript 2.0创建发票?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在客户端脚本事件中创建发票.

I have tried to create invoice in the client script event.

var objRecord = record.create({
    type: 'invoice',
    isDynamic: false
});

objRecord.setValue({
    fieldId: 'customform',
    value: '296',
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'account',
    value: '215',
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'entity',
    value: '13276',
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'currency',
    value: '1',
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'postingperiod',
    value: '294',
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'exchangerate',
    value: '1.0',
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'custbody_amortization_partner_currency',
    value: '6',
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'memo',
    value: v_adv_memo,
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'custbody_amortization_advance_id',
    value: v_advanceID,
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'trandate',
    value: parsedDateStringAsRawDateObjectdtl,
    ignoreFieldChange: true
});
objRecord.setValue({
    fieldId: 'duedate',
    value: v_adv_pymt_pymt_date,
    ignoreFieldChange: true
});
objRecord.selectNewLine({
    sublistId: 'item'
});
objRecord.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'item',
    value: '5825',
    ignoreFieldChange: true
});
objRecord.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    value: '1',
    ignoreFieldChange: true
});
objRecord.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'amount',
    value: '100',
    ignoreFieldChange: true
});
objRecord.commitLine({
    sublistId: 'item'
});

var recId = objRecord.save({
    enableSourcing: true,
    ignoreMandatoryFields: true
});

alert(recId);   

我不确定错误发生在哪里.有人可以帮我这个话题吗?

I am not sure where the error occurs. Can anyone help me on this topic ?

推荐答案

通常无法直接创建发票.您通常会执行以下任一操作.注意,对于动态模式,建议将自定义表单设置为初始化的一部分.

Directly creating an invoice is not normally done. You would normally do either of the following. Note setting the custom form as part of the initialization is recommended for dynamic mode.

var invRec = record.transform({
    fromType: record.Type.CUSTOMER,
    fromId: custId,
    toType: record.Type.INVOICE,
    isDynamic: true,
    defaultValues: {customform:296}
});

var invRec = record.transform({
    fromType: record.Type.SALES_ORDER,
    fromId: soId,
    toType: record.Type.INVOICE,
    isDynamic: true,
    defaultValues: {customform:296}
});

这篇关于如何使用Suitescript 2.0创建发票?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆