Suggest value

Suggest value

colbycolby Posts: 10Questions: 5Answers: 0

Hi,

I'm trying to suggest a value when a user inline edits a field. The function I have at the moment is this:

editor.field( 'finalOrder' ).input().on( 'focus', function (e, d) {
            if ( ! d || ! d.editor ) {
                caseQty = editor.field( 'caseQty' ).val() ;
                defaultInputValue = editor.field( 'finalOrder' ).val() ;
                if (defaultInputValue == "0") {
                    irisOrder = parseInt(editor.field( 'irisOrder' ).val()) ;
                    colbyOrder = parseInt(editor.field( 'colbyOrder' ).val());
                    finalOrder = irisOrder+colbyOrder;
                    while (finalOrder % caseQty != 0) {
                        finalOrder = finalOrder+1;
                    }
                    editor.field( 'finalOrder' ).set(finalOrder);
                }
            }
        } );

it comes back with an error that caseQty isn't defined. Basically what I want from it is this:
If the finalOrder fields is 0 (which it is by default), give me the sum of two other fields in the row (important to only include the current row) and check if it is divisable by another field...

Any help?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    it comes back with an error that caseQty isn't defined.

    Is the error from line 3? Is caseQty defined as a field?

    Colin

  • colbycolby Posts: 10Questions: 5Answers: 0

    Yes, it's from that line but caseQty is defined...part of the definition below:

    fields: [ {
                        label: "EAN:",
                        name: "EAN"
                    }, 
                    {
                        label: "SKU:",
                        name: "SKU"
                    },
                    {
                        label: "Image:",
                        name: "localImage"
                    },
                    {
                        label: "Franchise:",
                        name: "IP"
                    },
                    {
                        label: "Title:",
                        name: "title"
                    },
                    {
                        label: "Available:",
                        name: "available"
                    },
                    {
                        label: "Case Qty:",
                        name: "caseQty"
                    },
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    If you are running your JS in strict mode you'll need to define caseQty as a variable - e.g.:

    var caseQty = editor.field( 'caseQty' ).val() ;
    

    If its not that, can you link to a page showing the issue please?

    Allan

  • colbycolby Posts: 10Questions: 5Answers: 0

    That was it Allan...I can't believe I missed that. Thank you for having the insight to even think of that :)

This discussion has been closed.