ExploreConsulting / netsuite-fasttrack-toolkit-ss2

NFT for SuiteScript 2.X
75 stars 20 forks source link

Trouble setting Customer Field isPerson to boolean values. #14

Closed donblackowiak closed 5 years ago

donblackowiak commented 5 years ago

Hi Shawn. It seems that the isperson field is not really boolean. But the taxable field is. I didn't find code that distinguishes between them, but there must be a difference??

This works if I use "F" instead of false.

   const customerTest1 = new CustomerBase(88095);
        // @ts-ignore
        customerTest1.isperson = "F";   // works
        log.debug("customerTest1.isperson:", customerTest1.isperson); // "F"  // NOT FALSE
        log.debug("customerTest1.save:",  (customerTest1.save() > 0)); // true save works

Taxable field works as expected.

// trying another boolean field
        const customerTest3 = new CustomerBase(88095);
        log.debug("customerTest3.taxable:", customerTest3.taxable);  // false
        customerTest3.taxable = true;  // works
        log.debug("customerTest3.taxable:", customerTest3.taxable);  // true
        log.debug("customerTest3.save:",  (customerTest3.save() > 0));  // true

But treat isperson as a boolean and it fails.

        const customerTest2 = new CustomerBase(88095);
        customerTest2.isperson = false;  // fails
        log.debug("customerTest2.isperson:", customerTest2.isperson);  // false // note changed
        // next line causes error
        log.debug("customerTest2.save:",  (customerTest2.save() > 0));

{"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value false for the following field: isperson","stack":["anonymous(N/serverRecordService)","(/SuiteScripts/NFT-SS2-4.3.0/DataAccess/Record.js:102)","(/SuiteScripts/xx/tests/xx_tests_customer.js:28)"],"cause":{"type":"internal error","code":"INVALID_FLD_VALUE","details":"You have entered an Invalid Field Value false for the following field: isperson","userEvent":null,"stackTrace":["anonymous(N/serverRecordService)","(/SuiteScripts/NFT-SS2-4.3.0/DataAccess/Record.js:102)","(/SuiteScripts/xx/tests/xx_tests_customer.js:28)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}

ShawnTalbert commented 5 years ago

TL;DR; Good catch - we need to either update CustomerBase.isperson to 'freeformtext' (easiest solution) or put in the logic for T/F translation to boolean (like NFT-SS1 did). Do you have a preference?

It looks like you caught a legitimate field type mismatch in CustomerBase. While isperson sounds like a boolean it apparently is not (why not, NetSuite!?). The 2018.2 records browser shows the isperson field type radio, which isn't even a field type in the NS UI.

I presume as radio button in the UI it actually has text values T and F and NS doesn't bother translating that to a boolean.

FYI, NFT for SuiteScript 1 converted 'T'/'F' to booleans across the board. Since SuiteScript 2 started implementing native booleans we happily dropped that for NFT-SS2.

The only argument I can think of against coercing this to a boolean would be if Netsuite introduces values other than T and F for this field. The safest and easiest thing is to just switch this to freeformtext. We could perhaps type it to explicitly 'T' | 'F'?

donblackowiak commented 5 years ago

Hi Shawn

Freeformtext is fine with me, as is sticking to Netsuite’s logic (whatever that is). I previously worked with ‘T’ / ‘F’ values so I am used to that.

Thank you!

Don Blackowiak don@lucuma.com Lucuma Designs www.lucuma.comhttp://lucuma.com/ 877-858-2862 Fax 1-941-203-1013 Creating Together a Beautiful World!

From: Shawn Talbert notifications@github.com Reply-To: ExploreConsulting/netsuite-fasttrack-toolkit-ss2 reply@reply.github.com Date: Monday, March 18, 2019 at 12:12 PM To: ExploreConsulting/netsuite-fasttrack-toolkit-ss2 netsuite-fasttrack-toolkit-ss2@noreply.github.com Cc: "don@lucuma.com" don@lucuma.com, Author author@noreply.github.com Subject: Re: [ExploreConsulting/netsuite-fasttrack-toolkit-ss2] Trouble setting Customer Field isPerson to boolean values. (#14)

TL;DR; Good catch - we need to either update CustomerBase.isperson to 'freeformtext' (easiest solution) or put in the logic for T/F translation to boolean (like NFT-SS1 did). Do you have a preference?

It looks like you caught a legitimate field type mismatch in CustomerBase. While isperson sounds like a boolean it apparently is not (why not, NetSuite!?). The 2018.2 records browser shows the isperson field type radio, which isn't even a field type in the NS UI.

I presume as radio button in the UI it actually has text values T and F and NS doesn't bother translating that to a boolean.

FYI, NFT for SuiteScript 1 converted 'T'/'F' to booleans across the board. Since SuiteScript 2 started implementing native booleans we happily dropped that for NFT-SS2.

The only argument I can think of against coercing this to a boolean would be if netsuite introduces values other than T and F for this field. The safest and easiest thing is to just switch this to freeformtext.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ExploreConsulting/netsuite-fasttrack-toolkit-ss2/issues/14#issuecomment-473982543, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEa4s3CjbdIZ-EkB6g_T2ozD7zLDUxDRks5vX7rwgaJpZM4b4OSu.

ShawnTalbert commented 5 years ago

should be fixed in release 4.3.1