Sublist values cleared after pageInit Client Script

Hello!!
I am trying to inizialize a Purchase Order created from a Sales Order with Special Order.
I prepared a Client Script with pageInit function.
The body fields are initialized without any problem.

When I initialize the items from “Item” sublist, something strange happens. In particular, I am trying to set the rate field by taking values from a custom field that was inherited from Sales Order. The value is correctly initialized (i see it from the log) but it is cleared immediately afterwards. Obviously I tried the triggers like fireSlavingSync with no effects.
I also tried to use lineInit or sublistChanged entry points without any luck.

Has anybody experienced something like that? Does anybody know what is clearing the values?

Thanks in advance!

Rookie Asked on April 8, 2022 in SuiteScript.

I am trying the same in JE. I couldn’t set the value for the account sublist field but can set the value for the Amount field. Also couldn’t commit the line. whatever changes made are only applying to the first line. (can set body fields though)

The script,

function pageInit(context) {
        try {
            //custbody_ic_reversal_auto_entry
            // throw ‘skipped for now’
            let currRec = context.currentRecord;
            let subsidiary = getParameterByName(‘custparam_subsidiary’);
            // let date = getParameterByName(‘custparam_date’);
            // let memo = getParameterByName(‘custparam_memo’);
            let repInvs = getParameterByName(‘custparam_repinv’);
            try {
                repInvs = JSON.parse(repInvs);
            } catch (error) {
                log.debug(‘repInvs error’, error);
                repInvs = null;
            }
            if (subsidiary) {
                currRec.setValue(‘subsidiary’, subsidiary);
            }
            // if (date) {
            //     // currRec.setValue(‘trandate’, date);
            // }
            // if (memo) {
            //     currRec.setValue(‘memo’,memo+’ Reversal Journal entry’);
            // }
            log.debug(‘repInvs’,repInvs);
            if (repInvs) {
                currRec.setValue(‘custbody_rep_in_je’,repInvs);
            }
            let lines = getParameterByName(‘custparam_lines’);
                try {
                    lines = JSON.parse(lines);
                } catch (error) {
                    log.debug(‘lines error’, error);
                    lines = null;
                }
                log.debug(‘lines’,lines);
                if (lines) {
                    currRec.selectLine(‘line’,0);
                    currRec.setCurrentSublistValue({
                        sublistId: ‘line’,
                        fieldId : ‘account’,
                        value: lines.acc1,
                        ignoreFieldChange: true
                    });
                    currRec.setCurrentSublistValue({
                        sublistId: ‘line’,
                        fieldId : ‘credit’,
                        value: lines.amount,
                        ignoreFieldChange: true
                    });
                    currRec.commitLine(‘line’);
                    currRec.selectLine(‘line’,1);
                    currRec.setCurrentSublistValue({
                        sublistId: ‘line’,
                        fieldId: ‘account’,
                        value: lines.acc2,
                        ignoreFieldChange: true
                    });
                    currRec.setCurrentSublistValue({
                        sublistId: ‘line’,
                        fieldId : ‘debit’,
                        value: lines.amount,
                        ignoreFieldChange: true
                    });
                    currRec.commitLine(‘line’);
                }
        } catch (error) {
            log.debug(‘pageInit error, Terminating pageInit sequence’,error);
        }
    }
on July 16, 2024.
Add Comment
1 Answer(s)

UPDATE.

I solved by setting not only the field “rate” but also the field “origrate”. Somebody suggested to set the price level to custom (price=-1) but this had not effect on the problem.

Rookie Answered on April 8, 2022.
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   SuiteMigration   Become a Sponsor