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

  • Author
    Posts
  • #5636 Score: 0

    Rafe
    • Contributions: 0
    • Level 1

    Hello and Happy New Year. I am hoping to fins some help on something where I cannot find much dodumentation on. I am trying to write a user event script with the following code. It is returning null in both before submit and after submit deployments. However it works perfectly fine on a client scripts. Can anybody offer an idea regarding what I am doing wrong?

    var pairedTrx = nlapiGetFieldValue(‘intercotransaction’);

    nlapiLogExecution(‘debug’,’pairedTrx’,pairedTrx);// returns null for user event scripts
    This is a cached copy. Click here to see the original post.

  • #5637 Score: 0

    erictgrubaugh
    • Contributions: 0
    • Level 1

    What record type is your script deployed on? On which event is this code running (Before Load, Before/After Submit)?


    Rafe replied on 01/04/2017, 09:30 AM: I have tried both before and after submit. I’m not sure that before submit would work for me on ‘Create’.

  • #5638 Score: 0

    Vesku1980
    • Contributions: 0
    • Level 1

    In user event script you have to use nlapiLoadRecord.

    var rec = nlapiLoadRecord(‘salesorder’,1); – loads sales order with internalid 1.

    Load wanted field :

    var dataInField = rec.getFieldValue(‘intercotransaction’);

    Vesku


    erictgrubaugh replied on 01/04/2017, 01:03 PM: This is true when you need to load data from a different record. When you are retrieving data from the record on which your User Event is deployed, you should not need to load the record.

  • #5639 Score: 0

    Rafe
    • Contributions: 0
    • Level 1

    Thanks for your responses! In addition to loading the sales order, which I will likely need to do in the end, I was able to use as well in my aftersubmit function:

    var pairedTrx = nlapiLookupField(‘salesorder’,soID,’intercotransac tion’);

  • #5640 Score: 0

    Olivier Gagnon NC
    • Contributions: 0
    • Level 1

    After Submit is not longer truly after submit. NetSuite made some changes (likely to optimize performance while sacrificing correctness). So you often have the case of values being returned incorrectly in after submit scripts when doing local getFieldValue type calls (both in SS1.0 and 2.0). The solution is typically to load the record you are on just to be able to see correct values.

You must be logged in to reply to this topic.