SQL Scripts for Microsoft Dynamics GP: Migrate Vendor Emails from Active Docs to Standard Email Fields

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posted the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script will copy vendor emails from the Active Documents table to the standard Dynamics GP email fields where they weren’t already present. This script was written for a client who was replacing the sending of remittances using Active Docs to using the standard functionality.

The script returns mutiple emai address from the Active Docs tables as a semi-colon delimited ist to insert into one field in the standard tables.

/*
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). */
INSERT INTO SY01200 --Internet Addresses (SY01200) ( Master_Type,Master_ID,ADRSCODE,INET1,INET2,INET3,INET4,INET5,INET6,INET7,INET8,Messenger_Address,INETINFO,EmailToAddress,EmailCcAddress,EmailBccAddress ) SELECT DISTINCT 'VEN' as Master_Type ,['Active Docs'].VENDORID AS Master_ID ,['PM Creditor Master'].VADCDTRO AS ADRSCODE ,'' AS INET1 ,'' AS INET2 ,'' AS INET3 ,'' AS INET4 ,'' AS INET5 ,'' AS INET6 ,'' AS INET7 ,'' AS INET8 ,'' AS Messenger_Address ,'' AS INETINFO ,ISNULL((STUFF(( SELECT '; ' + RTRIM(EMail) FROM EMA00101 AS ['INNER'] WHERE ['INNER'].Email_Type = 1 AND ['INNER'].VENDORID = ['Active Docs'].VENDORID ORDER BY VENDORID ,IntegerValue FOR XML PATH('') ), 1, 2, '') ),'') AS EmailToAddress ,ISNULL((STUFF(( SELECT '; ' + RTRIM(EMail) FROM EMA00101 AS ['INNER'] WHERE ['INNER'].Email_Type = 2 AND ['INNER'].VENDORID = ['Active Docs'].VENDORID ORDER BY VENDORID ,IntegerValue FOR XML PATH('') ), 1, 2, '') ), '') AS EmailCcAddress ,'' AS EmailBccAddress FROM EMA00101 AS ['Active Docs'] INNER JOIN PM00200 AS ['PM Creditor Master'] --PM Vendor Master File (PM00200) ON ['PM Creditor Master'].VENDORID = ['Active Docs'].VENDORID WHERE ( SELECT COUNT(*) FROM SY01200 AS ['Internet Addresses'] --Internet Addresses (SY01200) WHERE ['Internet Addresses'].Master_Type = 'VEN' AND ['Internet Addresses'].Master_ID = ['PM Creditor Master'].VENDORID AND ['Internet Addresses'].ADRSCODE = ['PM Creditor Master'].VADCDTRO ) = 0

Click to show/hide the SQL Scripts for Microsoft Dynamics GP Series Index

Enable Email Conversations in the Outlook Desktop Client

Microsoft OfficeI hated threaded email when it first came out, but I’m now used to it and as it turns out prefer it to non-threaded. I discovered this after changing jobs; my old work laptop had threaded emails enabled and the one at the new job didn’t.

I worked that way for a few weeks and it was fine as I was doing a lot of learning and not involved in many projects. As soon as that changed and I started getting lots of emails I wanted to enable threaded emails, but had some trouble finding the option.

I eventually found it and there were two reasons why I was having problems finding the setting; the first was that I was looking in the Options and the second was that I was looking for something which included the word “thread”.

It turns out the setting in the Outlook desktop client is on the View tab and is called Show as Conversations:

View tab in Microsoft Outlook

Continue reading “Enable Email Conversations in the Outlook Desktop Client”

SQL Scripts for Microsoft Dynamics GP: Vendor Emil Addresses from Standard Fields and Active Docs

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posted the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script returns a list of email addresses for vendors from both the standard Dynamics GP fields as well as Active Docs. The email addresses from Active Docs are returned as a semi colon delimited list.

They were returned this way to allow users to check the returned email addresses and correct any incorrect ones, through the Active Docs window, before another script (which I’ll post soon) was run to migrate the emails from the Active Docs fields to the standard ones.

/*
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 ['PM Creditor Master'].VENDORID AS 'Creditor ID' ,['PM Creditor Master'].VENDNAME AS 'Creditor Name' ,['PM Creditor Master'].VADCDTRO AS 'Address Code' ,['Internet Addresses'].EmailToAddress AS 'GP Email To Address' ,['Internet Addresses'].EmailCcAddress AS 'GP Email Cc Address' ,['Internet Addresses'].EmailBccAddress AS 'GP Email Bcc Address' ,ISNULL((STUFF(( SELECT '; ' + RTRIM(EMail) FROM EMA00101 AS ['INNER'] WHERE ['INNER'].Email_Type = 1 AND ['INNER'].VENDORID = ['PM Creditor Master'].VENDORID ORDER BY VENDORID ,IntegerValue FOR XML PATH('') ), 1, 2, '') ),'') AS 'Active Docs Email To Address' ,ISNULL((STUFF(( SELECT '; ' + RTRIM(EMail) FROM EMA00101 AS ['INNER'] WHERE ['INNER'].Email_Type = 2 AND ['INNER'].VENDORID = ['PM Creditor Master'].VENDORID ORDER BY VENDORID ,IntegerValue FOR XML PATH('') ), 1, 2, '') ), '') AS 'Active Docs Email Cc Address' FROM PM00200 AS ['PM Creditor Master'] LEFT JOIN SY01200 AS ['Internet Addresses'] ON ['Internet Addresses'].Master_Type = 'VEN' AND ['Internet Addresses'].Master_ID = ['PM Creditor Master'].VENDORID AND ['Internet Addresses'].ADRSCODE = ['PM Creditor Master'].VADCDTRO

In Microsoft Dynamics 365 Business Central (Customisation), how do I… Personalize the FactBox

Microsoft Dynamics 365 Business CentralThis post is part of the In Microsoft Dynamics 365 Business Central (Customisation), how do I… series and of the wider In Microsoft Dynamics 365 Business Central, how do I… series which I am posting as I familiarise myself with Microsoft Dynamics 365 Business Central.

As with pages, the FactBox can also be personalized. Whether the FactBox is on a list page or a card card, or any other type of page, the process of personalizing the FactBox is the same.

There are a few actions you can take to personalize the FactBox:

  • Show or hide sections.
  • Move sections.
  • Add or remove fields from sections.
  • Move fields.

To personalize the FactBox you need to click on the Settings cog button and then on Personalize:

Settings menu showing Personalize option

Continue reading “In Microsoft Dynamics 365 Business Central (Customisation), how do I… Personalize the FactBox”

SQL Scripts for Microsoft Dynamics GP: Select Workflow Comments for Work Status Batches

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posted the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script will return all unposted batches and the workflow approval comments which have been entered; it was used within a customisation of workflow in Dynamics GP which allowed the returned comment to be added to the workflow approval notification emails.

/*
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). */
WITH COMMENTS AS ( SELECT ['Posting Definitions Master'].BACHNUMB ,['Posting Definitions Master'].BCHSOURC ,CASE WHEN LEFT(CAST(['Workflow History'].Workflow_Comments AS VARCHAR(2000)), 54) = 'The workflow was automatically rejected by the system.' THEN 'SYSTEM' ELSE LTRIM(RTRIM(SUBSTRING(REPLACE(['Workflow History'].Workflow_History_User, '\', REPLICATE(' ', LEN(['Workflow History'].Workflow_History_User))), (1) * LEN(['Workflow History'].Workflow_History_User)+1, LEN(['Workflow History'].Workflow_History_User)))) END + ', ' + FORMAT(['Workflow History'].Workflow_Completion_Date, 'dd/MM/yyyy') + ' ' + FORMAT(['Workflow History'].Workflow_Completion_Time, 'T', 'en-US') + ': ' + CASE ['Workflow History'].Workflow_Action WHEN 1 THEN 'SUBMITTED' WHEN 2 THEN 'RESUBMITTED' WHEN 3 THEN 'APPROVED' WHEN 4 THEN 'TASK COMPLETED' WHEN 5 THEN 'REJECTED' WHEN 6 THEN 'DELEGATED' WHEN 7 THEN 'RECALLED' WHEN 8 THEN 'ESCALATED' WHEN 9 THEN 'EDITED' WHEN 10 THEN 'FINAL APPROVED' END + ' ' + RTRIM(['Workflow Instance Master'].WfBusObjKey) + '. ' + RTRIM(CAST(ISNULL(['Workflow History'].Workflow_Comments,'') AS VARCHAR(8000))) AS Comment ,ROW_NUMBER() OVER (PARTITION BY ['Posting Definitions Master'].BACHNUMB, ['Posting Definitions Master'].BCHSOURC ORDER BY Workflow_Completion_Date DESC,Workflow_Completion_Time DESC) AS RowNumber FROM SY00500 AS ['Posting Definitions Master'] INNER JOIN WFI10002 AS ['Workflow Instance Master'] ON ['Workflow Instance Master'].WfBusObjKey = RTRIM(['Posting Definitions Master'].BACHNUMB) + '~' + RTRIM(['Posting Definitions Master'].BCHSOURC) + '~' + FORMAT(['Posting Definitions Master'].CREATDDT, 'yyyy/M/dd') + '~' + FORMAT(['Posting Definitions Master'].TIME1, 'HH:mm:ss') LEFT JOIN WF30100 AS ['Workflow History'] ON ['Workflow History'].WorkflowInstanceID = ['Workflow Instance Master'].WorkflowInstanceID WHERE ['Workflow Instance Master'].WfBusObjKey = RTRIM(BACHNUMB) + '~' + RTRIM(BCHSOURC) + '~' + FORMAT(CREATDDT, 'yyyy/M/dd') + '~' + FORMAT(TIME1, 'HH:mm:ss') AND CAST(['Workflow History'].Workflow_Comments AS VARCHAR(2000)) <> 'No approval is required for this step.' AND CAST(['Workflow History'].Workflow_Comments AS VARCHAR(2000)) <> 'No action is required for this step.' AND CAST(['Workflow History'].Workflow_Comments AS VARCHAR(2000)) <> '' ) SELECT ['Posting Definitions Master'].BCHSOURC ,['Posting Definitions Master'].BACHNUMB ,(STUFF(( SELECT CHAR(10) + COMMENTS.Comment FROM COMMENTS WHERE COMMENTS.BACHNUMB = ['Posting Definitions Master'].BACHNUMB AND COMMENTS.BCHSOURC = ['Posting Definitions Master'].BCHSOURC ORDER BY COMMENTS.RowNumber DESC FOR XML PATH('') ), 1, 1, '') ) AS Comments ,'' AS CMMTTEXT FROM SY00500 AS ['Posting Definitions Master']

In Microsoft Dynamics 365 Business Central (Administration), how do I… Understand the FactBox

Microsoft Dynamics 365 Business CentralThis post is part of the In Microsoft Dynamics 365 Business Central (Administration), how do I… series and of the wider In Microsoft Dynamics 365 Business Central, how do I… series which I am posting as I familiarise myself with Microsoft Dynamics 365 Business Central.

On list and card pages there is a FactBox which displays at the side of the page; by default the FactBox is usually visible, but can be hidden by clicking the i circle to the top right. FactBoxes are available on the following types of page:

  • List
  • Card
  • Document
  • Worksheet

A FactBox is divided into sections and is used to display content including other pages, charts, and system parts such as Notes, and Links. Typically, a FactBox is used to display information that is related to an item on the main content page. For example, on a page that shows a vendor card, the FactBox shows a picture, some statistics and interactive tiles showing the Buy–from Vendor History.

There may also be a second tab on the FactBox; on the vendor card this is for attachments; you can see existing ones and add new ones.

Vendor card page FactBox

FactBoxes are unique to each page, but will often have a similar structure.

Continue reading “In Microsoft Dynamics 365 Business Central (Administration), how do I… Understand the FactBox”

SQL Scripts for Microsoft Dynamics GP: Remaining Budget By Year Using PO Commitment Budget

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posted the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script was created for a client who wanted to be able to see how much of the annual PO commitment budget was remaining. It takes into account postings to the GL, PO commitments and entered purchase requisitions. This particular client wasn;t interested in seeing having a period check, just a check against the overall annual budget amount.

/*
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 ACTINDX ,SUM(VALUE) AS VALUE ,YEAR1 FROM (SELECT GLB.ACTINDX AS ACTINDX ,SUM(GLB.BUDGETAMT) AS VALUE ,GLB.YEAR1 AS YEAR1 FROM GL00201 AS GLB --[gpt=GL00201] INNER JOIN CPO40002 AS CPOS --[gpt=CPO40002] ON CPOS.BUDGETID = GLB.BUDGETID WHERE PERIODID NOT IN (0,13) GROUP BY GLB.ACTINDX ,GLB.YEAR1 UNION ALL SELECT GLPB.ACTINDX AS ACTINDX ,SUM(ISNULL(GLPB.PERDBLNC,0)) * -1 AS VALUE ,GLPB.YEAR1 AS YEAR1 FROM GL10110 AS GLPB --[gpt=GL10110] WHERE GLPB.PERIODID NOT IN (0,13) GROUP BY GLPB.ACTINDX ,GLPB.YEAR1 UNION ALL SELECT CPO.ACTINDX AS ACTINDX ,SUM(ISNULL(CPO.Committed_Amount,0)) * -1 AS VALUE ,SYY.YEAR1 AS YEAR1 FROM CPO10110 AS CPO --[gpt=CPO10110] INNER JOIN SY40100 AS SYY --[gpt=SY40100] ON SYY.ODESCTN = 'Budget Transaction Entry' AND PERIODDT <= CPO.REQDATE AND PERDENDT >= CPO.REQDATE AND PERIODID NOT IN (0,13) GROUP BY CPO.ACTINDX ,SYY.YEAR1 UNION ALL SELECT POP.INVINDX AS ACTINDX ,SUM(ISNULL(POP.EXTDCOST,0)) * -1 AS VALUE ,SYY.YEAR1 AS YEAR1 FROM POP10210 AS POP --[gpt=POP10210] INNER JOIN SY40100 AS SYY --[gpt=SY40100] ON SYY.ODESCTN = 'Budget Transaction Entry' AND PERIODDT <= POP.REQDATE AND PERDENDT >= POP.REQDATE AND PERIODID NOT IN (0,13) GROUP BY POP.INVINDX ,SYY.YEAR1 ) AS REMBUDGT GROUP BY ACTINDX ,YEAR1

Excel Snippets: Formula to Calculate Monthly Value of a Mortgage with Monthly Interest

MicrosoftI might not post many Excel snippets, but I’m collecting them into a small Excel Snippets series to make them easy to find.

I’ve been using this formula for quite a while now, but have to admit that I did not create it and no longer remember from where I got it.

The basic use is that you would have the starting amount in cell C2 and then use this formula in the next cell down and replicate down the page and it will calculate interest on a monthly basis.

The first highlighted section is the % rate being charged on the mortgage and the second is the amount you’re paying each month.

=IF(C3<=0,0,ROUND((((1+({% rate}/100)/12)^(12/12))-1)*C3,2)+C3-({mortgage payment amount}))

I’ve used this formula for a while to calculate an estimate of my mortgage it calculates to within a reasonably close amount (usually within a handful of pounds) as my mortgage interest is calculated daily, not monthly, but I’ve not been able to work out/find a formula for daily interest.

SQL Scripts for Microsoft Dynamics GP: Get Items Showing Quantities By Type

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posted the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script returns a list of items at each location and the different quantities on each quantity type (such as on hold, allocation and on different types of open transactions).

/*
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 ['Item Quantity Master'].ITEMNMBR ,['Item Quantity Master'].LOCNCODE ,SUM(['Item Quantity Master'].QTYONHND - ['Item Quantity Master'].ATYALLOC - ISNULL(['Sales Transaction Amounts Work'].QTYALLOC,0)) AS 'QTYAVAIL' ,SUM(['Item Quantity Master'].QTYONHND) AS QTYONHND ,SUM(['Item Quantity Master'].ATYALLOC) AS 'QTYALLOC' ,SUM(['Sales Transaction Amounts Work'].ORDQTYALLOC) AS 'OPENORDERS' ,SUM(['Item Quantity Master'].QTYBKORD) AS 'OPENBACKORDERS' ,SUM(['Sales Transaction Amounts Work'].RTNQTYALLOC) AS 'OPENRETURNS' ,SUM(['Sales Transaction Amounts Work'].INVQTYALLOC) AS 'OPENINVOICES' ,SUM(['Sales Transaction Amounts Work'].QTYONPO) AS 'QTYONORD' ,SUM(['Purchase Order Line'].QTYONPO) AS QTYONPO ,SUM(['Item Quantity Master'].QTYDMGED) AS QTYDAMAGED ,['Item Quantity Master'].RCRDTYPE AS RCRDTYPE FROM IV00102 AS ['Item Quantity Master'] --Item Quantity Master (IV00102) LEFT JOIN ( SELECT ITEMNMBR ,LOCNCODE ,SUM(CASE WHEN SOPTYPE NOT IN (1,4,5) THEN (QTYREMAI - ATYALLOC) * QTYBSUOM ELSE 0 END) AS QTYALLOC ,SUM(CASE WHEN SOPTYPE = 2 THEN (QTYREMAI - ATYALLOC) * QTYBSUOM ELSE 0 END) AS ORDQTYALLOC ,SUM(CASE WHEN SOPTYPE = 4 THEN (ATYALLOC) * QTYBSUOM ELSE 0 END) AS RTNQTYALLOC ,SUM(CASE WHEN SOPTYPE = 3 THEN (ATYALLOC) * QTYBSUOM ELSE 0 END) AS INVQTYALLOC ,SUM(CASE WHEN SOPTYPE = 5 THEN QTYONPO ELSE 0 END) AS QTYONPO FROM SOP10200 AS ['Sales Transaction Amounts Work'] --Sales Transaction Amounts Work (SOP10200) GROUP BY ITEMNMBR ,LOCNCODE ) AS ['Sales Transaction Amounts Work'] ON ['Sales Transaction Amounts Work'].ITEMNMBR = ['Item Quantity Master'].ITEMNMBR AND ['Sales Transaction Amounts Work'].LOCNCODE = ['Item Quantity Master'].LOCNCODE LEFT JOIN ( SELECT (['Purchase Order Line'].QTYORDER - ['Purchase Order Line'].QTYCANCE) - ISNULL(['Purchasing Receipt Line Quantities'].QTYSHPPD, 0) AS QTYONPO ,['Purchase Order Line'].ITEMNMBR ,['Purchase Order Line'].LOCNCODE FROM POP10110 AS ['Purchase Order Line'] --Purchase Order Line (POP10110) LEFT JOIN POP10500 AS ['Purchasing Receipt Line Quantities'] --Purchasing Receipt Line Quantities (POP10500) ON ['Purchasing Receipt Line Quantities'].PONUMBER = ['Purchase Order Line'].PONUMBER AND ['Purchasing Receipt Line Quantities'].POLNENUM = ['Purchase Order Line'].ORD ) AS ['Purchase Order Line'] ON ['Purchase Order Line'].ITEMNMBR = ['Item Quantity Master'].ITEMNMBR AND ['Purchase Order Line'].LOCNCODE = ['Item Quantity Master'].LOCNCODE WHERE ['Item Quantity Master'].RCRDTYPE = 2 GROUP BY ['Item Quantity Master'].ITEMNMBR ,['Item Quantity Master'].LOCNCODE ,['Item Quantity Master'].RCRDTYPE

In Microsoft Dynamics 365 Business Central (Customisation), how do I… Understand the Best Way of Customising a Card Page

Microsoft Dynamics 365 Business CentralThis post is part of the In Microsoft Dynamics 365 Business Central (Customisation), how do I… series and of the wider In Microsoft Dynamics 365 Business Central, how do I… series which I am posting as I familiarise myself with Microsoft Dynamics 365 Business Central.

As I covered in the previous article, it is possible to personalize a card page by adding, moving or removing fields, adding or removing fields from quick entry and also changing when they are visible.

Personalizing a page can allow you to work quicker and more efficiently. The general rules I recommend to clients when personalizing a card page are:

  • Move fields into the logical order for entry.
  • Set all fields which you will always enter data into to “Show always”.
  • Set fields which you may, or may not, enter data into as show under “Show more”.
  • Consider removing fields set as show under “Show more” from quick entry.
  • Hide fields into which you will never enter information.

There may be some trial and error on getting the personalizations right for the role you’re in. It is also worth bearing in mind that someone else may ask you about a value in a field you can’t see, or to enter information into one of these fields, and this is because you have either removed the field through personalization or they have added one which is not visible by default.

In Microsoft Dynamics 365 Business Central, how do I…

In Microsoft Dynamics 365 Business Central (Customisation), how do I…
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Personalize a Page
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Remove Personalization from a Page
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Personalize Card Pages
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Understand the Best Way of Customising a Card Page
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Personalize the FactBox
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Personalize the Action Bar
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Understand the Best Way of Personalizing the Action Bar
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Create Customizations for Other Users Using Profiles
In Microsoft Dynamics 365 Business Central (Customisation), how do I… Copy Profile Personalizations to Another Environment