I have a Customer Record with a button that runs a...
# suitescript
w
I have a Customer Record with a button that runs a client script. It loads the estimate record in Dynamic Mode and adds new lines to it. Regular items work fine. When I try to add an Item Group I get a "Group item without matching End Of Group at line XX". I've tried different variations of ignoreFieldChange and forceSyncSourcing, as well as enableSourcing on save.
b
what does the code look like? In general that class of error will come from trying to add an additional line before the previous one has finished sourcing
w
Here is what I have:
Copy code
function addGroup(){
            var estimateID = currentRecord.get().id;
            var estimateRecord = record.load({
                type: record.Type.ESTIMATE,
                id: estimateID,
                isDynamic: true,
            });
            log.debug(estimateRecord);

            estimateRecord.selectNewLine({
                sublistId: 'item'
            })
            estimateRecord.setCurrentSublistValue({
                sublistId: 'item',
                fieldId: 'item',
                value: 735028,
                ignoreFieldChange: false,
                forceSyncSourcing: true
            })
            estimateRecord.commitLine({
                sublistId: 'item',
            })
            estimateRecord.save({
                enableSourcing: true,
            })
        }
I've also noticed I'm getting a POST error in the Browser Developer tools. It's say INVALID_CUSTOMER_RCRD -- > This customer record -1 is not valid. Please create the customer first. I moved the button to be on the Estimate Record to help figure out where the issue is. I get the above error on the Custom Record as well as the Estimate Record. So it seems odd that it is complaining about the customer being incorrect on the Estimate record as the Customer field has a valid customer in it. If I change the item to not be an Item Group it all works just fine.
b
it sounds like the estimate record is running code designed for the estimate record in the ui and failing since suitescript isnt the ui. You can try submitting a support case, but it will almost certainly be faster if you made your button make a request to a suitelet instead. Make the suitelet modify the estimate
w
Ok.. I'll try the support case just to see what they say as well. I will give the suitelet route a try as I will need this to add a bunch of groups, so it will probably end up being run server side anyway.. Thanks for taking the time to look at this.