Client script that displays a pop-up message confirming the removal of the associated RMA from the sales order while closing an exchange sales order.

function saveRecord(scriptContext) { 

            try { 

                let curRecord = scriptContext.currentRecord; 

                let customForm = curRecord.getValue({ 

                    fieldId: ‘customform’ 

                }); 

                if (customForm == 197) { 

                    let lineCount = curRecord.getLineCount({ 

                        sublistId: ‘item’ 

                    }); 

                    let flag = 0; 

                    for (let i = 0; i < lineCount; i++) { 

                        let status = curRecord.getSublistValue({ 

                            sublistId: ‘item’, 

                            fieldId: ‘isclosed’, 

                            line: i 

                        }); 

                        let qty = curRecord.getSublistValue({ 

                            sublistId: ‘item’, 

                            fieldId: ‘quantity’, 

                            line: i 

                        }); 

                        let fulfilled = curRecord.getSublistValue({ 

                            sublistId: ‘item’, 

                            fieldId: ‘quantityfulfilled’, 

                            line: i 

                        }); 

                        let invoiced = curRecord.getSublistValue({ 

                            sublistId: ‘item’, 

                            fieldId: ‘quantitybilled’, 

                            line: i 

                        }); 

                        if (status == false && qty != fulfilled && qty != invoiced) { 

                            flag = 1 

                            break; 

                        } 

                    } 

                    if (flag == 0) { 

                        alert(“While closing this sales order will remove the associated RMA from the sales order “) 

                        return true; 

                    } 

                } 

                return true; 

            } 

            catch (err) { 

                console.error(“error@saveRecord”, err); 

            } 

        } 

Leave a comment

Your email address will not be published. Required fields are marked *