您可以在 Microsoft Dynamics Navision 中自动执行任务吗?像 Excel 一样编写 VBA 脚本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27116507/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can you automate tasks in Microsoft Dynamics Navision? Write VBA script like Excel?
提问by Methodician
It's pretty straight forward. I want to do something along the lines of writing VBA scripts for Excel, only for Navision. So far I can't even seem to find many shortcuts or set default options in Navision. Considering all the repetitive tasks my employer asks of me, this post could be seen as a rant.
这很直接。我想做一些类似于为 Excel 编写 VBA 脚本的事情,仅适用于 Navision。到目前为止,我什至无法在 Navision 中找到许多快捷方式或设置默认选项。考虑到我的雇主要求我执行的所有重复性任务,这篇文章可以被视为咆哮。
At my last job, we didn't have any fancy Navision. This was a blessing in disguise for a clever SOB like my self. I griped about their lack of technological implementation then grudgingly implemented the tools I needed myself, flying under the radar and looking like a speed demon and analytical wizard.
在我的上一份工作中,我们没有任何花哨的 Navision。对于像我这样聪明的 SOB 来说,这是因祸得福。我抱怨他们缺乏技术实施,然后勉强自己实施了我需要的工具,在雷达下飞行,看起来像一个速度恶魔和分析向导。
Now, everything is set out for me and I hate it. NAV is an extremely bloated, cumbersum program. How can I make repetitive tasks faster and easier? How can I make it better for MY tasks?
现在,一切都为我准备好了,我讨厌它。NAV 是一个极其臃肿、繁琐的程序。如何更快更轻松地完成重复性任务?我怎样才能让它更好地完成我的任务?
回答by Alexander Drogin
Well, there's good news and bad news, as always. The good news is that routine tasks can be automated, but the bad news is - it is not as simple and straightforward as writing Excel macros.
好吧,和往常一样,有好消息也有坏消息。好消息是日常任务可以自动化,但坏消息是——它不像编写 Excel 宏那么简单和直接。
First and most common option of extending functionality is to develop new application objects specifically for the customer. Nav application code is written in its internal language - C/AL, and it's fully extendable. But writing C/AL code requires a developer's license (which is quite expensive) and good understanding of the system's structure. Usually, customers prefer outsourcing these tasks to MS partners rather then buy a dev license and keep an on-site developer.
If the version you are using is 2009 and higher, there's a second option - probably the best for an experienced Excel user. You can publish any Nav page as a web service and read the data into Excel through the web service. Here is a short "walkthrough": Viewing page data in Excel. After publishing pages you need, you can apply your Excel tools to the data.
If the version is 2013 R2 or 2015, some Powershell extension cmdlets are available. These are mostly for administrative tasks, but some of them can be handy in making your job easier. In particular, Invoke-NAVCodeunitthat can run a codeunit or a codeunit method from outside the system.
扩展功能的第一个也是最常见的选择是专门为客户开发新的应用程序对象。导航应用程序代码是用它的内部语言 C/AL 编写的,并且是完全可扩展的。但是编写 C/AL 代码需要开发人员的许可证(这是相当昂贵的)和对系统结构的良好理解。通常,客户更喜欢将这些任务外包给 MS 合作伙伴,而不是购买开发许可证并保留现场开发人员。
如果您使用的版本是 2009 及更高版本,还有第二个选项 - 可能是有经验的 Excel 用户的最佳选择。您可以将任何导航页面发布为 Web 服务,并通过 Web 服务将数据读入 Excel。这是一个简短的“演练”:在 Excel 中查看页面数据。发布您需要的页面后,您可以将 Excel 工具应用于数据。
如果版本是 2013 R2 或 2015,则可以使用一些 Powershell 扩展 cmdlet。这些主要用于管理任务,但其中一些可以方便地使您的工作更轻松。特别是Invoke-NAVCodeunit可以从系统外部运行 codeunit 或 codeunit 方法。
回答by Asympt0te
It depends:
这取决于:
If the tasks you want to automate are transactional in nature (capturing stock movement, customer payments etc) then you need to look at the C/AL programming, or getting your MS partner to do the C/Al programming for you.
如果您想要自动化的任务本质上是事务性的(捕获库存变动、客户付款等),那么您需要查看 C/AL 编程,或者让您的 MS 合作伙伴为您进行 C/Al 编程。
If the tasks are updating master data (customer groups, item categories etc), then you could use SQL to do the updating. Again, as Alexander says this requires a good understanding of the underlying tables, and if you make a mistake with an SQL update you can really break the system.
如果任务正在更新主数据(客户组、项目类别等),那么您可以使用 SQL 进行更新。同样,正如 Alexander 所说,这需要对底层表有很好的理解,如果您在 SQL 更新中犯了错误,您可能真的会破坏系统。
If the tasks are admin related (updating which dates users can post to each morning etc) then an SQL stored procedure that runs on a schedule is the quickest and easiest solution.
如果任务与管理员相关(更新用户每天早上可以发布的日期等),那么按计划运行的 SQL 存储过程是最快和最简单的解决方案。