When validating CMAccts while inserting rows into the Vendor Master table, the CMAcct field is incorrectly validated.
Existing logic does a DISTINCT count of valid CMAccts plus unspecified CMAcct lines, then compares that with the total inserted rows. This gives a false positive as in the example below.
IF @nullcnt + @validcnt <> @numrows THROW ERROR
Say you are inserting four vendors:
That would turn the variables into the following numbers:
So the formula would look like
IF 1 + 2 <> 4 THROW ERROR
Which would throw the error, even though everything is perfectly valid (NULL is allowed, and the accounts are valid).
I realize the UNIQUE constraint on @validcnt is so that if you share the same CMAcct across companies it removes duplicates. But in doing so it also combines vendors with the same CMAcct without accounting for them.
Doing a distinct count of a unique value in the inserted table, such as [Vendor] or [KeyID], fixes this nicely!
select @validcnt = count(distinct(c.CMAcct))from dbo.bCMAC c
join inserted i on c.CMAcct = i.CMAcct
select @validcnt = count(distinct(i.Vendor))from dbo.bCMAC c
join inserted i on c.CMAcct = i.CMAcct
Company | Cutting Edge Plumbing |
Job Title / Role | IT Admin |
I need it... | Yesterday...Come on already |
Dear Viewpoint Suggestion Box contributor;
We at Viewpoint sincerely thank you for your contribution to Suggestion Box on how we can improve Viewpoint products. While we can’t do everything at once, we rely upon your feedback to help guide the prioritization of our product improvements, and Suggestion Box is a critical tool for us to understand and prioritize our customers’ needs.
Viewpoint reviews Suggestion Box regularly for all of our products and updates statuses, adds comments, and performs various house-keeping (including deleting) as needed to ensure that Suggestion Box is maintained as a productive environment for product enhancements requests.
© 2023 Trimble Inc. All Rights Reserved. Viewpoint®, Vista™, Spectrum®, ProContractor™, Jobpac Connect™, Viewpoint Team™, Viewpoint Analytics™, Viewpoint Field View™, Viewpoint Estimating™, Viewpoint For Projects™, Viewpoint HR Management™, Viewpoint Field Management™, Viewpoint Financial Controls™, Vista Field Service™, Spectrum Service Tech™, ViewpointOne™, ProjectSight® and Trimble Construction One™ are trademarks or registered trademarks of Trimble Inc. or its affiliates in the United States and other countries. Other names and brands may be claimed as the property of others.