Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Record integer field will not accept StringCustomFieldRef at least as of 2015.1 #238

Closed
tatecarr opened this issue Jan 29, 2016 · 3 comments

Comments

@tatecarr
Copy link
Contributor

During some testing have found that 2015.1 will not coerce a StringCustomFieldRef value into an Integer field on a custom record. Before sending record to NS I update the type of the field to LongCustomFieldRef and that solves the issue. Question is how to handle, how do we infer which fields can remain string and which need to be long.

https://github.com/NetSweet/netsuite/blob/master/lib/netsuite/records/custom_field_list.rb#L107

@iloveitaly
Copy link
Member

Hmm, this is a bit tricky: ruby isn't strongly typed, and I don't think it would be ruby-like to infer field type off a specific lower-level variable class. Forcing users to to something like ns_record.custom_field_list.custfield_field = the_value.to_i would be error prone.

What do you think of adding this to netsuite_rails. We could add a :long field type to the field hints mapping:

netsuite_field_hints(
  :custom_field_list: {
    :the_field => :long
  }
)

This would:

  • Be more self-documenting. to_i is ambiguous.
  • Extensible: it would provide an easy way to add support for additional custom fields types

What do you think @tatecarr?

@tatecarr
Copy link
Contributor Author

@iloveitaly I like it. I think you're right and it's fairly common that you'd see both numeric & string values that end up going to a NS string field. So using the variables class on the ruby side would prove difficult and inconsistent. Adding to the field hints would work well and be a clean update removing the need to set the field type explicitly in the NetSuiteRails :before_netsuite_push for example.

@iloveitaly
Copy link
Member

Awesome, created an issue for this on netsuite_rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants