AugForums.com

An Acumatica User Group

  • Free
    • Start Here
    • Rolodex
    • Podcast
    • Blog
    • Forums
  • Paid
    • AugSQL
    • GI Course
    • GI Library
    • Consulting
  • Register
Acumatica Forums

By using this website, you agree to our Terms of Use (click here)

Forums
AUG Forums
Acumatica Generic I...
SQL View for Generi...
 
Notifications
Clear all

Questions SQL View for Generic Inquiry - Debtors Day KPI Widget

 
Acumatica Generic Inquiries & Pivot Tables
Last Post by Tim Rodman 7 years ago
13 Posts
5 Users
0 Reactions
6,717 Views
RSS
Grant Reid
Posts: 16
 Grant Reid
Topic starter
March 13, 2018 5:07 am
(@grant-reid)
Member
Joined: 8 years ago

I pretty new to this, but I’m attempting to create a SQL view on the table ARInvoice to use in a Generic Inquiry, which in turn will be used in a Scorecard KPI widget. I might be missing it, but I don’t see any Financial Period in the ARInvoice table which I presumed might provide a link to the FinPeriod table to furnish the required Financial period. Hoping you can point me in the right direction?

You might ask why I need to use a SQL View? My widget needs to display Debtors Days which I don’t think I can accomplish with a Generic Enquiry. The calculations are a bit too complex i.e. (Total Amount Owed by Debtors / Divided by a rolling 12 months Nett total sales) * 365. I’d be happy to have egg on my face if you can show otherwise.


12 Replies
Tim Rodman
Posts: 3193
 Tim Rodman
Admin
March 16, 2018 11:57 pm
(@timrodman)
Famed Member
Joined: 10 years ago

Hi Grant,

I agree. I think you'll probably need a SQL View for this. No egg needed though 😀

The financial period is actually stored in the ARRegister table: ARRegister.FinPeriodID.

The primary keys are the same on both ARInvoice and ARRegister: DocType and RefNbr.

Why do they put some fields in ARInvoice and others in ARRegister? I'm not really sure, but I think they tried to put fields that are common to every AR document in ARRegister, regardless of whether it's an invoice or a payment. That would make more efficient use of the database storage. But it makes it more of a headache for writing a report.


Reply
Grant Reid
 Grant Reid
(@grant-reid)
Joined: 8 years ago

Member
Posts: 16
March 23, 2018 8:18 am
Reply toTim RodmanTim Rodman

Hi Tim

Thanks for the pointer to ARRegister and confirmation for the need for a SQL view.

Kind Regards - Grant


Reply
Tim Rodman
Posts: 3193
 Tim Rodman
Admin
March 23, 2018 10:44 am
(@timrodman)
Famed Member
Joined: 10 years ago

Absolutely. I hope you were able to get everything working the way you wanted it.


Reply
Jerwin Alimuin
Posts: 17
 Jerwin Alimuin
March 25, 2018 11:56 pm
(@jalimuin)
Member
Joined: 8 years ago

Hi tim,

How am i going to create a SQL View in GI? i think that is the answer to my problem since my boss wanted a complicated GI and can only be achieved if i make it in plain sql, not in the table and relationship definition in GI Editor. But my problem is, i cant even create a customization project in acumatica, our provider here restricted us to create custom project.

Thanks in advance.


Reply
Tim Rodman
Posts: 3193
 Tim Rodman
Admin
March 26, 2018 10:55 am
(@timrodman)
Famed Member
Joined: 10 years ago

Hi Jerwin,

I just responded on your post about security permissions:
https://www.augforums.com/augforums/everything-else/editing-project-restriction

As for creating a GI on a SQL View, checkout this post from Doug Johnson:
https://www.acumatica.com/blog/technical-tuesday-report-from-sql-view/


Reply
Jerwin Alimuin
 Jerwin Alimuin
(@jalimuin)
Joined: 8 years ago

Member
Posts: 17
March 26, 2018 11:57 pm
Reply toTim RodmanTim Rodman

hi tim, 

i have seen that article regarding SQL view, but our subscription is SaaS, how i am going to access the SQL database from that perspective?


Reply
Kurt Bauer
Posts: 45
 Kurt Bauer
March 27, 2018 9:42 am
(@kurtybauer)
Trusted Member
Joined: 6 years ago

Jerwin,

You can use the Database Scripts section of a customization project to add a SQL view to a SaaS implementation.  The help information is outlined here:  https://help.acumatica.com/(W(1))/Main?ScreenId=ShowWiki&pageid=cb776a15-1661-48a4-994c-1e91412d2227

Basically you write your SQL view and decorate it with the [mssql] tag.  Once you build the project you can create the DAC.  


Reply
Tim Rodman
Posts: 3193
 Tim Rodman
Admin
March 29, 2018 9:42 pm
(@timrodman)
Famed Member
Joined: 10 years ago

Great article @kurtbauer

In addition, you can also look in the Query Quarry Customization Project (click here and scroll to bottom) for more examples of SQL Views that get pushed into the database via a Customization Project.


Reply
AhmedBahar
Posts: 29
 AhmedBahar
April 28, 2018 10:45 am
(@ahmedbahar)
Eminent Member
Joined: 6 years ago

Great way of creating a view! Although it seems like a journey to be able to finally see it in a GI.

I tried creating the DAC out of the view per the instructions:

https://www.acumatica.com/blog/technical-tuesday-report-from-sql-view/

DAC name same as view, but at the end it runs into validation isues.

Right-click to Download


Reply
Kurt Bauer
 Kurt Bauer
(@kurtybauer)
Joined: 6 years ago

Trusted Member
Posts: 45
April 30, 2018 8:19 am
Reply toAhmedBaharAhmedBahar

Try removing the spaces and any special characters like the parenthesis from your SQL view column names and Acumatica DAC.  For example, rename Inventory ID to InventoryID and Description (Short) to DescriptionShort.  You can use the display name attribute to add the spaces and special characters back to the columns.

-Kurt


Reply
AhmedBahar
 AhmedBahar
(@ahmedbahar)
Joined: 6 years ago

Eminent Member
Posts: 29
April 30, 2018 8:42 pm
Reply toKurt BauerKurt Bauer
AhmedBahar

Thanks Kurt that did it!


Reply
Tim Rodman
Posts: 3193
 Tim Rodman
Admin
May 4, 2018 5:08 am
(@timrodman)
Famed Member
Joined: 10 years ago

I've run into the same problem before. I wish the script would just take the column names from the SQL View and not try to be so smart.


Reply
Forum Jump:
  Previous Topic
Next Topic  
Forum Information
Recent Posts
Unread Posts
Tags
  • 12 Forums
  • 2,526 Topics
  • 10.9 K Posts
  • 21 Online
  • 2,389 Members
Our newest member: Dan Hunting
Latest Post: Generic Inquiry Screenid changes to ScreenId=00000000
Forum Icons: Forum contains no unread posts Forum contains unread posts
Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Online Members

  • Julie Baker
Acumatica Forums

Terms of Use & Disclaimers :: Privacy Policy

Copyright © 2025 · AUG Forums, LLC. All rights reserved. This website is not owned, affiliated with, or endorsed by Acumatica, Inc.

‹›×

    ‹›×