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

Cld 1835 netsuite null fields #481

Closed

Conversation

gmike11
Copy link

@gmike11 gmike11 commented Jul 13, 2021

No description provided.

WHY: previously could not utilize soap action attach
This adds the attach basic reference functionality into the gem
Why:

When adding a file from a workflow, even though it will sometimes be 'succuessful' it was still returning a 500 to the platform
This change addresses the need by:

made an update to the gem to return true/200 if a file is created and to return the file name if it is successfully created so we can query file by that attribute to create attachment
Ticket

[CLOUD-737]
Why:

* no nested if else statements!

This change addresses the need by:

* learned about try

Ticket

* [CLOUD-]
[HOTFIX-CLOUD-737-add-action-for-file]
*WHY

The sales order record did not have the intercompany transaction field or the intercompany status field

*This addresses the need by

Adding those fields to the sales order record
-caveat: I tried to test this with multiple payloads provided by the automation engineer but have yet to get a successful post.  I have communicated the two errors we are getting, either a permission error or wrong enity for record depending on how the payload is formatted.  The automation engineer is checking with customer, so I'm not sure if we want to wait to merge this in until the errors have been confirmed or not.
[CLD-597]
    Why:

    *The expense report object did not exist in the netsuite ruby gem or in our connector

    This change addresses the need by:

    *updating the gem and connector to include the expense report object.  This ticket is dependent on the pr for branch cld-571 in the netsuite ruby connector

    Ticket

    * [CLD-571]
*Why:

Inventory subsidiary and inventory location were not present fields on the sales order line item

*This change addresses the need by:

Added those two fields
*Why:

The vendor credit object in the gem previously had record reference fields defined differently than the majority of the other objects in the gem.  Because of this, when we call '.record_refs' in the connector, it was erroring

*This addresses the change by:

Adding in the record ref support and redefined how the record reference fields are defined.

[CLD-669]
Why:

*The purchase order expenses were not supported within the gem, so they were being returned in the soap response but not in the json response returned by the gem.  With this object missing, it would not have allowed posting a purchase order with an expense list either.

This change addresses the need by:

*Added the purchase order expense list record and the purchase order expense record

Ticket

* [CLD-725]
Why:

*There was not support for expense lines to show up on item receipts in Netsuite

This change addresses the need by:

*added in the item receipt expense list and item receipt expense models to the gem

Ticket

* [CLD-737]
Why:

*expense categories were needed for posting an expense report

This change addresses the need by:

*adding in the expense category record to support searching for expense category

Ticket

* [CLD-756]
*Why:

We were experiencing 500s when making certain requests to netsuite and needed to accomodate them

*How:
Increased the timeout when configuring the savon client

[CLD-882]
*Why:
 The gem previously supported versions up to 2018 but later versions were not supported

*How:
 Updated the netsuite savon config to set the wsdl and the endpoint level

[CLD-878]
*Why:
  Earlier versions of netsuite did not have the field class on the vendor credit expense line level or the vendor credit item line level

*This addresses the need by:
  Added the class field to both the vendor credit expense record class and the vendor credit item record class.  Added the methods to those classes required for setting the record references appropriately

[CLD-917]
reginad1 and others added 11 commits January 22, 2021 11:49
update readme to include Cloudsnap additions
added default address field on employee class
* netsuite gem lacked support for null_field_list

This change addresses the need by:
* Added null_field_lest record
* added nullFieldList fields to applicable objects
* Added check for nullFieldList element and code to swap namespace

Ticket
* [CLD-1835]
@gmike11 gmike11 closed this Jul 13, 2021
@iloveitaly
Copy link
Member

@gmike11 there are some great changes here, mind submitting another PR?

@gmike11
Copy link
Author

gmike11 commented Jul 19, 2021 via email

@gmike11 gmike11 reopened this Jul 21, 2021
Copy link
Member

@iloveitaly iloveitaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! This is a huge number of awesome changes. Thank you!

I'd love to get this merged, but I'd like to investigate some of the changes a bit more:

  • The regex logic on the update call
  • The errors returned on get
  • Modified logic on add
  • Configuration changes

Could you extract those changes into a separate PR and update this one?

Also, there are some merge conflicts in this branch—could you fix those as well?

@errors = response.errors

if response.success?
@internal_id = response.body[:@internal_id]
@internal_id = response.body.dig(:@internal_id) unless response.body.class == Nori::StringIOFile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is response.body.class == Nori::StringIOFile protecting against?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#495 likely adds some more context around where Nori::StringIOFile is coming from and attempts to address it in a way that still ensures the internal_id is extracted.

if inner.keys.grep(/(.*):nullFieldList?/).any?
null_field_key = inner.keys.grep(/(.*):nullFieldList?/)
hash["platformMsgs:record"][:content!]["platformCore:nullFieldList"] = hash["platformMsgs:record"][:content!].delete null_field_key[0]
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what's going on here? Could you pull this into a separate PR?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to extract the NullFieldList stuff and this part makes sure the updated_record.record_type isn't used for the nullFieldList

if attrs[:value].is_a?(Array)
attrs[:value] = custom_field_data[:value].map { |entry| CustomRecordRef.new(entry) }
else
attrs[:value] = CustomRecordRef.new(custom_field_data[:value])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was recently fixed: 3377c97

Can you remove this change from your PR?

@@ -17,12 +17,14 @@ class Employee
:bill_pay, :comments, :date_created, :direct_deposit, :entity_id, :password, :password2,
:expense_limit, :fax, :is_job_resource, :job_description, :labor_cost, :last_modified_date, :mobile_phone, :pay_frequency,
:phonetic_name, :purchase_order_approval_limit, :purchase_order_approver, :purchase_order_limit, :release_date,
:resident_status, :salutation, :social_security_number, :visa_exp_date, :visa_type
:resident_status, :salutation, :social_security_number, :visa_exp_date, :visa_type, :default_address
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on all of these missing fields!

@@ -5,6 +5,7 @@ gem 'simplecov', :require => false

gem 'pry-nav'
gem 'pry-rescue'
gem 'pry'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you need to include this directly?

If you see the record in the netsuite schema browser, you can easily add it to the records in this gem. Use the fields and sub lists mentioned in the Netsuite schema browser to build out the record file following the same format as the other record files.

### Other Cloudsnap Changes
We made a few changes to the configuration.rb file. The check credentials method and set attributes methods were added to support the updated way of passing credentials. In the connection method, we also added the ability to set the wsdl and the endpoint level for the Savon client that is configured. This was required to connect to Netsuite api versions 2020+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this is merged, I'll go ahead and edit these readme changes a bit to fit within the existing readme structure.

def errors
error_obj = response_hash.dig(:status,:status_detail)
OpenStruct.new(status: 404, status_detail: error_obj)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pull this logic into a separate PR?

@@ -15,6 +15,8 @@ def attributes
end

def connection(params={}, credentials={})
check_credentials(credentials)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these changes required in your case? This smells like something specific to your application and not something we'd want to include in the netsuite gem.

@@ -27,10 +29,28 @@ def connection(params={}, credentials={})
log_level: log_level,
log: !silent, # turn off logging entirely if configured
}.update(params))
client.wsdl.endpoint = client.wsdl.endpoint.to_s.sub('//webservices.netsuite.com/', "//#{wsdl_domain}/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed by this PR #473

@iloveitaly
Copy link
Member

@gmike11 friendly reminder on this one! Would be great to handle some of my comments and get this merged.

cgunther added a commit to cgunther/netsuite that referenced this pull request Oct 19, 2021
When calling `File#add`, the response XML sets a `type="file"` attribute
on the `baseRef` element, where "file" corresponds to the NetSuite
record. This then causes Nori (the XML parser used by Savon, the SOAP
client) to interpret that element as representing a base64 encoded file,
so it tries to get fancy about how it parses that element into a hash by
returning an instance of it's `StringIOFile` class:
https://github.com/savonrb/nori/blob/f59f8e18b0e53285c87d75a635058745e66b0bfb/lib/nori/xml_utility_node.rb#L131-L136

Either NetSuite's doing something non-standard with it's use of the
`type` attribute that Nori is trying to enforce, or Nori is
over-aggressive in trying to typecast to aid the developer.

The end result was that when we tried to extract the `internal_id` from
the response, the `body` was actually an instance of `StringIOFile`, not
a hash:
https://github.com/NetSweet/netsuite/blob/f0e46a076d0e7cb2abd5e9001ccbfd4bbb3d35c3/lib/netsuite/actions/add.rb#L80

To work around this, as I don't see a way to disable such behavior in
Savon/Nori, if we detect the `baseRef` element was parsed to
`StringIOFile`, we'll then take the raw XML and parse out the `baseRef`
ourselves, returning a hash with the `internal_id` as we'd exect from
non-`File` responses.

I'm not thrilled with this solution. If we ever needed something else
from the `baseRef` element, this effectively drops all other attributes
for file records. It also introduces explicit references to `Nori` and
`Nokogiri`, both of which are dependencies of Savon, but I'm not sure if
that means this gem should list them as explicit dependencies to guard
against Savon replacing them in a future update. Listing them as
dependencies would then require keeping their version constraints in
sync with Savon most likely.

I believe this answers a question from NetSweet#481:
NetSweet#481 (comment)

However the fix in NetSweet#481 solves it by not trying to extract the
`internal_id`, which would create a problem if someone wanted to add a
file then save the ID in their own database for future use.
cgunther added a commit to cgunther/netsuite that referenced this pull request Oct 20, 2021
When calling `File#add`, the response XML sets a `type="file"` attribute
on the `baseRef` element, where "file" corresponds to the NetSuite
record. This then causes Nori (the XML parser used by Savon, the SOAP
client) to interpret that element as representing a base64 encoded file,
so it tries to get fancy about how it parses that element into a hash by
returning an instance of it's `StringIOFile` class:
https://github.com/savonrb/nori/blob/f59f8e18b0e53285c87d75a635058745e66b0bfb/lib/nori/xml_utility_node.rb#L131-L136

Either NetSuite's doing something non-standard with it's use of the
`type` attribute that Nori is trying to enforce, or Nori is
over-aggressive in trying to typecast to aid the developer.

The end result was that when we tried to extract the `internal_id` from
the response, the `body` was actually an instance of `StringIOFile`, not
a hash:
https://github.com/NetSweet/netsuite/blob/f0e46a076d0e7cb2abd5e9001ccbfd4bbb3d35c3/lib/netsuite/actions/add.rb#L80

To work around this, as I don't see a way to disable such behavior in
Savon/Nori, if we detect the `baseRef` element was parsed to
`StringIOFile`, we'll then take the raw XML and parse out the `baseRef`
ourselves, returning a hash with the `internal_id` as we'd exect from
non-`File` responses.

I'm not thrilled with this solution. If we ever needed something else
from the `baseRef` element, this effectively drops all other attributes
for file records. It also introduces explicit references to `Nori` and
`Nokogiri`, both of which are dependencies of Savon, but I'm not sure if
that means this gem should list them as explicit dependencies to guard
against Savon replacing them in a future update. Listing them as
dependencies would then require keeping their version constraints in
sync with Savon most likely.

I believe this answers a question from NetSweet#481:
NetSweet#481 (comment)

However the fix in NetSweet#481 solves it by not trying to extract the
`internal_id`, which would create a problem if someone wanted to add a
file then save the ID in their own database for future use.
cgunther added a commit to cgunther/netsuite that referenced this pull request Oct 21, 2021
When calling `File#add`, the response XML sets a `type="file"` attribute
on the `baseRef` element, where "file" corresponds to the NetSuite
record. This then causes Nori (the XML parser used by Savon, the SOAP
client) to interpret that element as representing a base64 encoded file,
so it tries to get fancy about how it parses that element into a hash by
returning an instance of it's `StringIOFile` class:
https://github.com/savonrb/nori/blob/f59f8e18b0e53285c87d75a635058745e66b0bfb/lib/nori/xml_utility_node.rb#L131-L136

Either NetSuite's doing something non-standard with it's use of the
`type` attribute that Nori is trying to enforce, or Nori is
over-aggressive in trying to typecast to aid the developer.

The end result was that when we tried to extract the `internal_id` from
the response, the `body` was actually an instance of `StringIOFile`, not
a hash:
https://github.com/NetSweet/netsuite/blob/f0e46a076d0e7cb2abd5e9001ccbfd4bbb3d35c3/lib/netsuite/actions/add.rb#L80

To work around this, as I don't see a way to disable such behavior in
Savon/Nori, if we detect the `baseRef` element was parsed to
`StringIOFile`, we'll then take the raw XML and parse out the `baseRef`
ourselves, returning a hash with the `internal_id` as we'd exect from
non-`File` responses.

I'm not thrilled with this solution. If we ever needed something else
from the `baseRef` element, this effectively drops all other attributes
for file records. It also introduces explicit references to `Nori` and
`Nokogiri`, both of which are dependencies of Savon, but I'm not sure if
that means this gem should list them as explicit dependencies to guard
against Savon replacing them in a future update. Listing them as
dependencies would then require keeping their version constraints in
sync with Savon most likely.

I believe this answers a question from NetSweet#481:
NetSweet#481 (comment)

However the fix in NetSweet#481 solves it by not trying to extract the
`internal_id`, which would create a problem if someone wanted to add a
file then save the ID in their own database for future use.
cgunther added a commit to cgunther/netsuite that referenced this pull request Dec 6, 2021
When calling `File#add`, the response XML sets a `type="file"` attribute
on the `baseRef` element, where "file" corresponds to the NetSuite
record. This then causes Nori (the XML parser used by Savon, the SOAP
client) to interpret that element as representing a base64 encoded file,
so it tries to get fancy about how it parses that element into a hash by
returning an instance of it's `StringIOFile` class:
https://github.com/savonrb/nori/blob/f59f8e18b0e53285c87d75a635058745e66b0bfb/lib/nori/xml_utility_node.rb#L131-L136

Either NetSuite's doing something non-standard with it's use of the
`type` attribute that Nori is trying to enforce, or Nori is
over-aggressive in trying to typecast to aid the developer.

The end result was that when we tried to extract the `internal_id` from
the response, the `body` was actually an instance of `StringIOFile`, not
a hash:
https://github.com/NetSweet/netsuite/blob/f0e46a076d0e7cb2abd5e9001ccbfd4bbb3d35c3/lib/netsuite/actions/add.rb#L80

To work around this, as I don't see a way to disable such behavior in
Savon/Nori, if we detect the `baseRef` element was parsed to
`StringIOFile`, we'll then take the raw XML and parse out the `baseRef`
ourselves, returning a hash with the `internal_id` as we'd exect from
non-`File` responses.

I'm not thrilled with this solution. If we ever needed something else
from the `baseRef` element, this effectively drops all other attributes
for file records. It also introduces explicit references to `Nori` and
`Nokogiri`, both of which are dependencies of Savon, but I'm not sure if
that means this gem should list them as explicit dependencies to guard
against Savon replacing them in a future update. Listing them as
dependencies would then require keeping their version constraints in
sync with Savon most likely.

I believe this answers a question from NetSweet#481:
NetSweet#481 (comment)

However the fix in NetSweet#481 solves it by not trying to extract the
`internal_id`, which would create a problem if someone wanted to add a
file then save the ID in their own database for future use.
iloveitaly pushed a commit that referenced this pull request Dec 14, 2021
#495)

When calling `File#add`, the response XML sets a `type="file"` attribute
on the `baseRef` element, where "file" corresponds to the NetSuite
record. This then causes Nori (the XML parser used by Savon, the SOAP
client) to interpret that element as representing a base64 encoded file,
so it tries to get fancy about how it parses that element into a hash by
returning an instance of it's `StringIOFile` class:
https://github.com/savonrb/nori/blob/f59f8e18b0e53285c87d75a635058745e66b0bfb/lib/nori/xml_utility_node.rb#L131-L136

Either NetSuite's doing something non-standard with it's use of the
`type` attribute that Nori is trying to enforce, or Nori is
over-aggressive in trying to typecast to aid the developer.

The end result was that when we tried to extract the `internal_id` from
the response, the `body` was actually an instance of `StringIOFile`, not
a hash:
https://github.com/NetSweet/netsuite/blob/f0e46a076d0e7cb2abd5e9001ccbfd4bbb3d35c3/lib/netsuite/actions/add.rb#L80

To work around this, as I don't see a way to disable such behavior in
Savon/Nori, if we detect the `baseRef` element was parsed to
`StringIOFile`, we'll then take the raw XML and parse out the `baseRef`
ourselves, returning a hash with the `internal_id` as we'd exect from
non-`File` responses.

I'm not thrilled with this solution. If we ever needed something else
from the `baseRef` element, this effectively drops all other attributes
for file records. It also introduces explicit references to `Nori` and
`Nokogiri`, both of which are dependencies of Savon, but I'm not sure if
that means this gem should list them as explicit dependencies to guard
against Savon replacing them in a future update. Listing them as
dependencies would then require keeping their version constraints in
sync with Savon most likely.

I believe this answers a question from #481:
#481 (comment)

However the fix in #481 solves it by not trying to extract the
`internal_id`, which would create a problem if someone wanted to add a
file then save the ID in their own database for future use.
cgunther added a commit to cgunther/netsuite that referenced this pull request Feb 24, 2022
NullFieldList is used to either clear an existing value on update, or
avoid a default being applied on adding a record.

My use case only required support for invoices, so I started there, but
this could likely be added to most records.

This was heavily inspired by @gmike11's work in NetSweet#481, but that seems to
lump a bunch of changes together. This also solves NetSweet#398.

Where NetSweet#481 manipulated the XML request body to address that the
`<platformCore:nullFieldList>` needs to always use the `platformCore`
namespace, as opposed to the records normal namespace (ie `transSale`
for invoice) as happens for any other field, I tried to address that on
the `#to_record` side.
cgunther added a commit to cgunther/netsuite that referenced this pull request Feb 24, 2022
NullFieldList is used to either clear an existing value on update, or
avoid a default being applied on adding a record.

My use case only required support for invoices, so I started there, but
this could likely be added to most records.

This was heavily inspired by @gmike11's work in NetSweet#481, but that seems to
lump a bunch of changes together. This also solves NetSweet#398.

Where NetSweet#481 manipulated the XML request body to address that the
`<platformCore:nullFieldList>` needs to always use the `platformCore`
namespace, as opposed to the records normal namespace (ie `transSale`
for invoice) as happens for any other field, I tried to address that on
the `#to_record` side.
cgunther added a commit to cgunther/netsuite that referenced this pull request Mar 31, 2022
NullFieldList is used to either clear an existing value on update, or
avoid a default being applied on adding a record.

My use case only required support for credit memos and invoices, so I
started there, but this could likely be added to most records.

This was heavily inspired by @gmike11's work in NetSweet#481, but that seems to
lump a bunch of changes together. This also solves NetSweet#398.

Where NetSweet#481 manipulated the XML request body to address that the
`<platformCore:nullFieldList>` needs to always use the `platformCore`
namespace, as opposed to the record's normal namespace (ie `transSale`
for invoice) as happens for any other field, I tried to address that on
the `#to_record` side.
cgunther added a commit to cgunther/netsuite that referenced this pull request Apr 6, 2022
NullFieldList is used to either clear an existing value on update, or
avoid a default being applied on adding a record.

My use case only required support for credit memos and invoices, so I
started there, but this could likely be added to most records.

This was heavily inspired by @gmike11's work in NetSweet#481, but that seems to
lump a bunch of changes together. This also solves NetSweet#398.

Where NetSweet#481 manipulated the XML request body to address that the
`<platformCore:nullFieldList>` needs to always use the `platformCore`
namespace, as opposed to the record's normal namespace (ie `transSale`
for invoice) as happens for any other field, I tried to address that on
the `#to_record` side.
iloveitaly pushed a commit that referenced this pull request Apr 7, 2022
…s) (#529)

NullFieldList is used to either clear an existing value on update, or
avoid a default being applied on adding a record.

My use case only required support for credit memos and invoices, so I
started there, but this could likely be added to most records.

This was heavily inspired by @gmike11's work in #481, but that seems to
lump a bunch of changes together. This also solves #398.

Where #481 manipulated the XML request body to address that the
`<platformCore:nullFieldList>` needs to always use the `platformCore`
namespace, as opposed to the record's normal namespace (ie `transSale`
for invoice) as happens for any other field, I tried to address that on
the `#to_record` side.
@gmike11 gmike11 closed this Apr 5, 2024
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

Successfully merging this pull request may close these issues.

8 participants