Removeline function is not working

Answered

I have created a Sales Order and I want to remove one line from the Sales Order using the subscript , I am using the below code

=========================================

var ObjRec = context.currentRecord;
ObjRec.removeLine({
sublistId: ‘item’,
line: ‘1’,
ignoreRecalc: true
});

=========================================

Pl suggest.

Rookie Asked on June 22, 2023 in Order Management.
Add Comment
6 Answer(s)

Hi,

You wouldn’t normally put quotes around 1 but that shouldn’t cause the problem.

What is your “context” here? i.e. script / entry point / etc?

Thanks,

Chris

Intermediate Answered on June 23, 2023.
Add Comment

my context is here scripting the code is not working, it should remove the line from the sales order.  That is not removing.

Rookie Answered on July 1, 2023.
Add Comment

Hi,

When I say context, I am asking about whether this is a client script, for example. And is it fieldChanged?

Could you please share your full script.

Thanks,

Chris

Intermediate Answered on July 2, 2023.
Add Comment

/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define([‘N/record’,’N/error’,’N/ui/message’],

function(record,error,message) {

function beforeLoad(context) {

}

function beforeSubmit(context) {

// when we edit a SO Record and then again hit the save button I want to remove the 1 line of line level
var ObjRec = context.currentRecord;
ObjRec.removeLine({
sublistId: ‘item’,
line: 1,
ignoreRecalc: true
});
alert (“Here we are removing the line”);
}

function afterSubmit(context) {

}

return {
beforeLoad: beforeLoad,
beforeSubmit: beforeSubmit,
afterSubmit: afterSubmit
};

});

Rookie Answered on July 3, 2023.
Add Comment
Best answer

In a User Event script, there is no currentRecord within context.

You need to use context.newRecord.

Intermediate Answered on July 3, 2023.
Add Comment

Thank you Chris, its Working.

Rookie Answered on July 5, 2023.

Brilliant. I’m glad it’s sorted.

on July 5, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor