最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Netsuite Script: what causes THAT_RECORD_IS_NOT_EDITABLE error? - Stack Overflow

programmeradmin0浏览0评论

I am trying to modify a shipping order record using a netsuite script v2.

 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */


define(['N/search', 'N/record'],

    function(search, record) {
        function afterSubmit(context) {
            if (context.type !== context.UserEventType.CREATE){
                 return;
            }

            try {
              // Get the current Record
              var salesOrder = context.newRecord;
              salesOrder.setValue({fieldId: 'custbody_route_vendor', value: 1});
              salesOrder.save({enableSourcing: true, ignoreMandatoryFields: true});

            } catch (error) {
              log.error({title: 'Error: ', details: error });
            }

        }

    return {
        afterSubmit: afterSubmit
    };
});

This seems to be pretty straight forward. But when I save a sales order, it throws this error:

{"type":"error.SuiteScriptError","name":"THAT_RECORD_IS_NOT_EDITABLE","message":"That record is not editable.","stack":["createError(N/error)...

Which isn't very helpful because I don't know the types of things that would make a record uneditable.

I searched the docs and the internet, but can't find an reference for this error. The docs for that save function does not address possible errors:

.nl?fid=section_4267286323.html

Any suggestions would be very helpful.

I am trying to modify a shipping order record using a netsuite script v2.

 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 */


define(['N/search', 'N/record'],

    function(search, record) {
        function afterSubmit(context) {
            if (context.type !== context.UserEventType.CREATE){
                 return;
            }

            try {
              // Get the current Record
              var salesOrder = context.newRecord;
              salesOrder.setValue({fieldId: 'custbody_route_vendor', value: 1});
              salesOrder.save({enableSourcing: true, ignoreMandatoryFields: true});

            } catch (error) {
              log.error({title: 'Error: ', details: error });
            }

        }

    return {
        afterSubmit: afterSubmit
    };
});

This seems to be pretty straight forward. But when I save a sales order, it throws this error:

{"type":"error.SuiteScriptError","name":"THAT_RECORD_IS_NOT_EDITABLE","message":"That record is not editable.","stack":["createError(N/error)...

Which isn't very helpful because I don't know the types of things that would make a record uneditable.

I searched the docs and the internet, but can't find an reference for this error. The docs for that save function does not address possible errors:

https://system.na2suite./app/help/helpcenter.nl?fid=section_4267286323.html

Any suggestions would be very helpful.

Share Improve this question asked May 2, 2019 at 17:22 Patrick_FinucanePatrick_Finucane 7551 gold badge7 silver badges25 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

The context passed to the afterSubmit function is read only. You cannot modify and then save the newly created record. You would need to either:

  1. Use the beforeSubmit function instead. Using beforeSubmit allows you to change the record as you're doing, before it's submitted to the database - however, you should not call Record.save() on it, as the system will save the modified record after your beforeSubmit pletes.
  2. You can also use the afterSubmit function, but for this you need to load the record separately, modify it as required and then save.

I'll suggest using record.submitFields in afterSubmit instead of loading record and then saving it. It will save you execution units.

record.submitFields({
    id: context.newRecord.id,
    type: context.newRecord.type,
    values: {'custbody_route_vendor' : '1'}
})
发布评论

评论列表(0)

  1. 暂无评论