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

Consider externalId in search criteria when using RecordRef as value #517

Merged
merged 1 commit into from
Feb 9, 2022

Conversation

cgunther
Copy link
Contributor

@cgunther cgunther commented Feb 9, 2022

Given a criteria like:

{
  field: 'company',
  operator: 'anyOf',
  value: [
    NetSuite::Records::RecordRef.new(external_id: "abc"),
    NetSuite::Records::RecordRef.new(external_id: "xyz"),
  ],
}

The gem was never passing that external ID to NetSuite for the result,
so you'd get a INVALID_KEY_OR_REF error as the XML line ended up
looking like:

<platformCore:searchValue xsi:type="platformCore:RecordRef" type="account"/>

Compared to the same line if you defined your RecordRef with an
internal ID:

<platformCore:searchValue internalId="1" xsi:type="platformCore:RecordRef" type="account"/>

Now that we pass the external ID too, that same line looks like:

<platformCore:searchValue externalId="abc" xsi:type="platformCore:RecordRef" type="account"/>

If your RecordRef has both internal and external IDs, it seems safe to
pass both and NetSuite seems to treat the internal ID as superseding the
external ID.

Given a criteria like:
```ruby
{
  field: 'company',
  operator: 'anyOf',
  value: [
    NetSuite::Records::RecordRef.new(external_id: "abc"),
    NetSuite::Records::RecordRef.new(external_id: "xyz"),
  ],
}
```

The gem was never passing that external ID to NetSuite for the result,
so you'd get a `INVALID_KEY_OR_REF` error as the XML line ended up
looking like:
```xml
<platformCore:searchValue xsi:type="platformCore:RecordRef" type="account"/>
```

Compared to the same line if you defined your `RecordRef` with an
internal ID:
```xml
<platformCore:searchValue internalId="1" xsi:type="platformCore:RecordRef" type="account"/>
```

Now that we pass the external ID too, that same line looks like:
```xml
<platformCore:searchValue externalId="abc" xsi:type="platformCore:RecordRef" type="account"/>
```

If your `RecordRef` has both internal and external IDs, it seems safe to
pass both and NetSuite seems to treat the internal ID as superseding the
external ID.
@iloveitaly
Copy link
Member

As always, a great improvement! Thank you

@iloveitaly iloveitaly merged commit b866e73 into NetSweet:master Feb 9, 2022
@cgunther cgunther deleted the search-criteria-external-id branch February 9, 2022 21:12
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.

2 participants