0

I am making a usereventcript that computes for the rate using subfields from the sales order item list. trying to save and deploy the script launches an error Fail to evaluate script: {"type":"error.SuiteScriptModuleLoaderError","name":"UNEXPECTED_ERROR","message":"missing } after property list (SS_SCRIPT_FOR_METADATA#32)","stack":[]}

enter image description here

/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(
[
    'N/record'
],
function (record) {

    /**
    * @param {UserEventContext.beforeSubmit} context
    */
     function beforeSubmit(context) {
        //get taxcode
        var taxcode = context.newRecord.getValue({
            fieldId: 'taxcode'
          });
        if(taxcode !== 0 || taxcode !== 4){
            // Gets the Total Amount
            var amount = context.getValue.getValue({
              fieldId: "amount"
            });

        // Gets the quantity of an item selected
        var quantity = context.newRecord.getValue({
        fieldId: 'quantity'
        });            
        var rate_ = amount/quantity;
        var newRate = context.newRecord.setValue({
            fieldId : 'rate'
            value : ('rate',rate_)
            });
        }
    }


    return {

        // beforeSubmit: beforeSubmit,

    };
});

1 Answer 1

2

Your code is not syntactically valid. Please replace below code

var newRate = context.newRecord.setValue({
  fieldId: 'rate'
  value: ('rate', rate_)
});

with

var newRate = context.newRecord.setValue({
  fieldId: 'rate',
  value: ('rate', rate_)
});

You can try validating your code with JS syntax validator esprima. Although alot of IDE's now support validation.

Sign up to request clarification or add additional context in comments.

4 Comments

Now it justs says 'SuiteScript 2.0 entry point scripts must implement one script type function.' but i guess its my code right?
right, if look in your code, beforeSubmit is commented at the bottom. Uncomment it and it should work
This also looks wrong: // Gets the Total Amount var amount = context.getValue.getValue({ fieldId: "amount" }); should be // Gets the Total Amount var amount = context.newRecord.getValue({ fieldId: "amount" });
@RustyShackles yes, but that might have already resulted in error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.