This topic contains 9 replies, has 0 voices, and was last updated by Olivier Gagnon NC 7 years, 7 months ago.
-
AuthorPosts
-
April 14, 2017 at 5:53 am #5802
CCroxtonGood 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.
-
April 14, 2017 at 6:55 am #5803
Olivier Gagnon NCEDI 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.
-
April 14, 2017 at 7:01 am #5804
CCroxtonOliver, 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.
-
April 14, 2017 at 7:36 am #5805
david.smithWhat 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.
-
April 14, 2017 at 8:17 am #5806
CCroxtonThe 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.
-
April 14, 2017 at 8:41 am #5807
erictgrubaughWhich event did you associate your `saveRecord` function with? Before Submit or After Submit?
-
April 14, 2017 at 8:48 am #5808
CCroxtonbefore submit. I was going to try to use after submit but then I read that nlapiSetFieldValue doesn’t work with that event type.
-
April 17, 2017 at 5:36 am #5809
Olivier Gagnon NCDid 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?
-
April 18, 2017 at 11:10 am #5810
CCroxtonOkay, 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.
-
April 19, 2017 at 9:17 am #5811
Olivier Gagnon NCThat’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.
-
AuthorPosts
You must be logged in to reply to this topic.