This topic contains 9 replies, has 0 voices, and was last updated by Olivier Gagnon NC 7 years, 7 months ago.

  • Author
    Posts
  • #5802

    CCroxton

    Good morning,

    I’ve created a basic script that totals up a column field from all lines on an order and populates a body field with that total. The script works great through the UI, but when an order comes through our EDI integration with SPS it always loads the field with a zero. The body field starts off blank so it appears that the script is triggering, but is not totaling. Any help you ladies and gents can offer would be greatly appreciated.

    Chris

    function saveRecord(type){ var lines = nlapiGetLineItemCount(‘item’); var totalFeet = 0 ; for(var i=1; iThis is a cached copy. Click here to see the original post.

  • #5803

    Olivier Gagnon NC

    EDI is not e-commerce. E-commerce would imply the NS web store functionality, either Sitebuilder or SCA, which is a totally different debug path.

    In any case, add a debug log in your code and check out the value of custcol_ltr_ite_cube_feet

    How is this field supposed to be set? I am pretty sure SPS isn’t setting it, so it’s probably blank and thus your total is 0.

  • #5804

    CCroxton

    Oliver, thank you for the reply. custcol_ltr_ite_cube_feet is a column field referenced from the item record. It is loaded on the line item of the sales record whether it was generated from EDI or the UI.

  • #5805

    david.smith

    What type of script did you create? Is this a client script or user event?

    Sorry, just read your title of the post. The reason for asking was the function name you gave suggested it was a client script.

  • #5806

    CCroxton

    The script started as a client script, but then after some insight from another user I converted it over to a user event script as I was told that client scripts would not trigger on EDI orders. I’m a novice with the scripting, but everything looked as though it would work correctly and it does if you create the order via the UI.

  • #5807

    erictgrubaugh

    Which event did you associate your `saveRecord` function with? Before Submit or After Submit?

  • #5808

    CCroxton

    before submit. I was going to try to use after submit but then I read that nlapiSetFieldValue doesn’t work with that event type.

  • #5809

    Olivier Gagnon NC

    Did you add a debug log to see what was in custcol_ltr_ite_cube_feet?

    And how is it sourced? Is it store value false?

  • #5810

    CCroxton

    Okay, for EDI orders the value being returned for custcol_ltr_ite_cube_feet is reporting as zero in the debug logs. That field is being sourced from the item record and it is set to be stored. It does correctly show for each line of the order and if I open and save the order it will correctly populate the body field. I also added a debug line for the number of lines and it does report the correct number of lines.

  • #5811

    Olivier Gagnon NC

    That’s your problem. Stored fields will not default properly when the order is not created via the UI. Go fetch it from its original source or change the field to store value false, which SHOULD work better.

You must be logged in to reply to this topic.