ExploreConsulting / netsuite-fasttrack-toolkit-ss2

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

country on Address subrecord requires the abbreviation string rather than the IID of the Country record #49

Closed steveklett closed 3 years ago

steveklett commented 3 years ago

When setting the country property on an Address subrecord I'm getting error:

You have entered an Invalid Field Value 227 for the following field: country

I've verified that it's the abbreviation value (e.g., 'US') that is required. The NetSuite record browser states this field is a select, and it is, but why it won't take an IID I cannot say. The workaround is to hit the underlying ns record instance like so:

newRec.nsrecord.getSubrecord({fieldId: 'shippingaddress'}).setValue({
    fieldId: `country`,
    value: getCountryById(230).abbrev
})
ShawnTalbert commented 3 years ago

Yes, another NetSuite-ism. The easiest solution here it to make that a string or perhaps string | number in case NS silently changes how that select works...

Another temporary workaround would be

newRec.shippingaddress.country = getCountryById(230)!.abbrev as any
steveklett commented 3 years ago

I plan to make the change and submit a PR, operative word is 'plan' I didn't realize you could cast to any like that, much cleaner, thanks for the tip. Hope all is well with you. :)

ShawnTalbert commented 3 years ago

Aye, use any as a last resort, but once in a while you have no other great choice. You could probably also cast to unknown then to number but that's even more confusing.

On Sun, Feb 28, 2021 at 12:33 PM Steve Klett notifications@github.com wrote:

I plan to make the change and submit a PR, operative word is 'plan' I didn't realize you could cast to any like that, much clean, thanks for the tip. Hope all is well with you. :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ExploreConsulting/netsuite-fasttrack-toolkit-ss2/issues/49#issuecomment-787518075, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKFNA3DTQYP4VUAGBBIDRDTBKSADANCNFSM4YLMDOOQ .

ShawnTalbert commented 3 years ago

should be resolved in 6.0.0, reopen if needed