ClassicPress Plugin Development: Best Practice for Loading Styles and Scripts

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

Over the last few posts, I have covered how to register and enqueue scripts and styles. In the posts on loading the admin styles and scripts I mentioned a check to only load the styles and scripts when the loaded page was the settings page for the plugin.

This is the best practice approach for developing plugins for ClassicPress; only load a script or style when it is needed. This is best practice for both scripts and styles on the front-end as well as the back-end admin dashboard.

Click to show/hide the ClassicPress Plugin Development Series Index

SQL Query to get First Level Items from Microsoft Dynamics GP Manufacturing BOM

Microsoft Dynamics GPWe’re currently doing some work for a client using the Manufacturing module of Microsoft Dynamics GP and I’ve been involved in the periphery of the manufacturing element while focusing on the financial and distribution parts, but have been assisting with some reporting items. One of them was to help create a report on the Mfg BOM showing only the first level items.

The below script, against the client data, gave the result which was required:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
SELECT ['Mfg Order Master'].MANUFACTUREORDER_I ,['Mfg Order Master'].ITEMNMBR ,['Item Master'].ITEMDESC ,['Mfg Order Master'].ENDQTY_I ,['Inventory U of M Schedule Setup'].BASEUOFM ,['Bill Of Material Line File'].CPN_I FROM WO010032 AS ['Mfg Order Master'] --WO010032 INNER JOIN IV00101 AS ['Item Master'] --Item Master (IV00101) ON ['Item Master'].ITEMNMBR = ['Mfg Order Master'].ITEMNMBR INNER JOIN IV40201 AS ['Inventory U of M Schedule Setup'] --Inventory U of M Schedule Setup (IV40201) ON ['Inventory U of M Schedule Setup'].UOMSCHDL = ['Item Master'].UOMSCHDL INNER JOIN BM010115 AS ['Bill Of Material Line File'] --BM010115 ON ['Bill Of Material Line File'].PPN_I = ['Mfg Order Master'].ITEMNMBR

Find All Microsoft Dynamics GP Companies With Web Services Enabled

Microsoft Dynamics GPI’ve recently been doing some work with a client which necessitated the backup of all databases using the Web Services for Microsoft Dynamics GP. The easiest way to determine which databases had the web services enabled, was to run a script checking the Workflow Setup (WF00100) table.

I took a copy of my return functional currency for all companies script and amended it to look at the web services.

If the web services has never been enabled, a company won’t be returned at all other wise a 1 for active or 0 for inactive will be returned.

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
CREATE TABLE #Workflow( INTERID VARCHAR(5) ,CMPNYNAM VARCHAR(200) ,WEBSERVICESACTIVE VARCHAR(20) ) GO DECLARE @SQL NVARCHAR(MAX) SELECT @SQL = STUFF(( SELECT CHAR(13) + 'SELECT ''' + INTERID + ''' ,''' + CMPNYNAM + ''' ,EnableWFNotifService FROM ' + INTERID + '.dbo.WF00100' FROM DYNAMICS.dbo.SY01500 FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') INSERT INTO #Workflow EXEC sys.sp_executesql @SQL GO SELECT * FROM #Workflow ORDER BY INTERID GO DROP TABLE #Workflow GO

ClassicPress Plugin Development: Loading Back-End Scripts

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

jQuery itself is automatically loaded by ClassicPress so we don’t need to do anything to load this ourselves in a plugin; it is just our own jQuery script which we need to register and enqueue. There is two ways in which scripts can be loaded in a plugin; I will cover them both, but will note first of all that I typically use the second approach; there is an argument that the first approach is the “correct” one.

The first thing to do when you are loading a script is to register it. This is done using the wp_register_script function which ClassicPress provides.

Continue reading “ClassicPress Plugin Development: Loading Back-End Scripts”

ClassicPress Plugin Development: Loading Front-End Scripts

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

jQuery itself is automatically loaded by ClassicPress so we don’t need to do anything to load this ourselves in a plugin; it is just our own jQuery script which we need to register and enqueue. There is two ways in which scripts can be loaded in a plugin; I will cover them both, but will note first of all that I typically use the second approach; there is an argument that the first approach is the “correct” one.

The first thing to do when you are loading a script is to register it. This is done using the wp_register_script function which ClassicPress provides.

Continue reading “ClassicPress Plugin Development: Loading Front-End Scripts”

SQL View to Return Microsoft Dynamics GP Item Number Split by Hyphens

Microsoft Dynamics GPAs with most of the other views I have posted, this is one I have written a few times over the years and am now posting it to make it easy to find next time I need it.

This view returns the Item Number from the Item Master (IV00101) table split into sections by hyphens. It assumes the item number has up to three sections, but can easily be extended.

With the view deployed, it can easily be included in any reporting tool, such as SmartList Designer/Builder or a refreshable Excel Report.

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
-- drop view if it exists IF OBJECT_ID(N'uv_AZRCRV_ItemNumberSplitByHyphens', N'V') IS NOT NULL DROP VIEW uv_AZRCRV_ItemNumberSplitByHyphens GO -- create view CREATE VIEW uv_AZRCRV_ItemNumberSplitByHyphens AS SELECT DISTINCT ITEMNMBR ,RTRIM(SUBSTRING(REPLACE(ITEMNMBR, '-', REPLICATE(' ', LEN(ITEMNMBR))), (0) * LEN(ITEMNMBR)+1, LEN(ITEMNMBR))) AS SECTION_1 ,RTRIM(SUBSTRING(REPLACE(ITEMNMBR, '-', REPLICATE(' ', LEN(ITEMNMBR))), (1) * LEN(ITEMNMBR)+1, LEN(ITEMNMBR))) AS SECTION_2 ,RTRIM(SUBSTRING(REPLACE(ITEMNMBR, '-', REPLICATE(' ', LEN(ITEMNMBR))), (2) * LEN(ITEMNMBR)+1, LEN(ITEMNMBR))) AS SECTION_3 FROM IV00101 AS ['Item Master'] WITH (NOLOCK) --Item Master (IV00101) GO GRANT SELECT ON uv_AZRCRV_ItemNumberSplitByHyphens TO DYNGRP GO

It would also be quite easy to amend the view to split out other strings based on a character using a variation of the above SQL script.

Microsoft Dynamics GP Purchasing All-In-One View Product 258 Error

Microsoft Dynamics GPI’m working on an implementation project at the moment to migrate a company from an older ERP into Microsoft Dynamics GP for an existing client using Dynamics GP and have been doing a lot of training. One area I covered was the All-in-One View enquiries in Purchasing, Inventory and Sales. After the training one of the users have exploring the system and found that the drilldown from an invoice on the Purchasing All-in-One View (Purchasing area page » Inquiries » Purchasing All-in-One View) wasn’t working.

We hadn’t noticed this in training as I had used a payment and purchase order as examples of the drill down. The error the client was seeing was this:

Error Message

Unhandled script exception:
Invalid Product ID 258.

EXCEPTION_CLASS_SCRIPT_OUT_OF_RANGE
SCRIPT_CMD_CALL

It rang a bell and when I checked found a post by Mariano Gomez in 2017 where he found this error in Dynamics GP 2015 R2 and 2016 RTM; I tested and it is also in 2018 and 2018 R2, but not in 2019 or 2020.

In the comments of Mariano’s blog, someone commented that marking and unmarking the Project Accounting entry ()Project Accounting is product 258) in the Registration window (Administration area page » Setup » System » ). I tested this on my system and it did remove the error so can discuss this workaround with the client.

Upcoming Microsoft Dynamics GP Webinars from ISC Software

ISC Software SolutionsEvery month at ISC Software I present a webinar on Microsoft Dynamics GP and related products. We typically have the next three upcoming monthly webinars I’ll be delivering scheduled.

We run these webinars on a monthly basis, with occasional extra webinars added to the schedule so it is worth checking the Webinar Schedule page every so often.

The upcoming webinars are:

Business Intelligence with Microsoft Dynamics GP
In May is Controls and Security in Microsoft Dynamics GP; Discover how Business Intelligence can improve visibility and help you make better, more timely, decisions.

Tue, May 18th, 2021 4:00 PM – 4:45 PM BST

Use Jet Analytics to harness multiple data sources for fast, reliable reporting and analytics. Through OLAP cubes and tabular models, you can easily report inside Excel or Power BI, with no coding and without requiring technical expertise.

Use PowerBI to create interactive, immersive dashboards and reports that provide actionable insights and drive business results.

Register Here

Personalising  Microsoft Dynamics GP
In June is Personalising Microsoft Dynamics GP; Learn how users can personalise their Dynamics GP experience.

Tue, June 15th, 2021 4:00 PM – 4:45 PM BST

In this webinar we’ll take a look at the standard functionality in Dynamics GP which allows users to tailor their homepage to fit their needs and ways they can use this to work smarter, not harder

Register Here

Lesser Used Modules in Dynamics GP
In July is Lesser Used Modules in Dynamics GP; Explore some of the lesser used modules of Microsoft Dynamics GP and how they can improve processes.

Tue, July 20th, 2021 4:00 PM – 4:45 PM BST

This webinar will look at the modules included in the Microsoft Dynamics GP Starter and Extended Packs, picking out some of the modules which can save time but which aren’t as commonly used.

Register Here

ClassicPress Plugin Development: Loading Back-End Stylesheets

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

All of the plugins I have written have a settings page in the admin dashboard, either for settings to be configured or for instructions on how to use the plugin. I often have an admin stylesheet which needs to be loaded on the settings page. There is two ways in which stylesheets can be loaded in a plugin; I will cover them both, but will note first of all that I typically use the second approach. There is an argument that the first approach is the “correct” one.

The first thing to do when you are loading a stylesheet is to register it. This is done using the wp_register_style function which ClassicPress provides.

Continue reading “ClassicPress Plugin Development: Loading Back-End Stylesheets”

ClassicPress Plugin Development: Loading Front-End Stylesheets

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series in which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

Virtually all of the plugins I have written have output to the front end of a site, usually through use of shortcodes. As there is front end output, I have needed to create a stylesheet which means the plugin needs to load it. There is two ways in which stylesheets can be loaded in a plugin; I will cover them both, but will note first of all that I typically use the second approach. There is an argument that the first approach is the “correct” one.

The first thing to do when you are loading a stylesheet is to register it. This is done using the wp_register_style function which ClassicPress provides.

Continue reading “ClassicPress Plugin Development: Loading Front-End Stylesheets”