Submit Your Suggestions for Vista

Ideaspace topics with the most votes have been moved into the Suggestion Box. If there is a topic missing, please re-enter. Our product team reviews the Suggestion Box items regularly and will provide updates as to status and incorporation into upcoming releases.

Fix the logic in trigger btAPVMi so it correctly validates CM Accounts when importing multiple vendors

Problem

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.

Current logic

IF @nullcnt + @validcnt <> @numrows THROW ERROR

Example

Say you are inserting four vendors:

  • one with CMAcct = NULL
  • two with CMAcct = 20 (valid),
  • one with CMAcct = 50 (valid)

That would turn the variables into the following numbers:

  • @nullcnt = 1
  • @validcnt = 2 (two unique valid CMAccts)
  • @numrows = 4

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! 

Old code 😕

select @validcnt = count(distinct(c.CMAcct))from dbo.bCMAC c
join inserted i on c.CMAcct = i.CMAcct

new code (tested and working) 😀

select @validcnt = count(distinct(i.Vendor))from dbo.bCMAC c
join inserted i on c.CMAcct = i.CMAcct
  • Nathan Sutherland
  • Dec 5 2018
Company Cutting Edge Plumbing
Job Title / Role IT Admin
I need it... Yesterday...Come on already
  • Attach files

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.

1515 SE Water Avenue, Suite 300, Portland, OR 97214 |  800.333.3197  | Contact Us | Terms of Use | Privacy | Support Policies

© 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.