SQL Scripts for Microsoft Dynamics GP: SQL Function To Return Approver

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

This script will return the approver of a workflow. It complements two other functions which I have previously posted:

IF OBJECT_ID (N'uf_AZRCRV_GetWorkflowApprover', N'FN') IS NOT NULL
    DROP FUNCTION uf_AZRCRV_GetWorkflowApprover
GO
CREATE FUNCTION [dbo].[uf_AZRCRV_GetWorkflowApprover](@WorkflowTypeName CHAR(50),@WfBusObjKey CHAR(20))
	RETURNS VARCHAR(50)
AS
/*
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). */
/* Author: Ian Grieve Version: 1.0 Date: 1/3/2017 Returns Workflow Approval status of a specified workflow item. Requires parameters of WorkflowTypeName and WfBusObjKey Valid Workflow Type Names are (as of Microsoft Dynamics GP 2016 R2): General Ledger Batch Approval Receivables Batch Approval Payables Batch Approval Payables Transaction Approval Purchase Order Approval Purchase Requisition Approval Vendor Approval Employee Profile Approval Employee Skills Approval Payroll Direct Deposit Approval Payroll Timecard Approval Payroll W4 Approval Expense Report Approval Timesheet Approval Smartlist Designer View Approval */ BEGIN RETURN ISNULL(( SELECT TOP 1 WFU.ADDisplayName FROM WF30100 AS WF --Workflow History (WF30100) INNER JOIN WFI10002 AS WFI --Workflow Instance Master (WFI10002) ON WFI.WorkflowInstanceID = WF.WorkflowInstanceID INNER JOIN WF40200 WFU --Workflow Users (WF40200) ON WFU.ADLogin = WF.Workflow_History_User WHERE WFI.Workflow_Type_Name = @WorkflowTypeName AND WFI.WfBusObjKey = @WfBusObjKey AND WF.Workflow_Action IN (3) --APPROVED ORDER BY WF.DEX_ROW_ID DESC) ,'') END GO GRANT SELECT ON uf_AZRCRV_GetWorkflowApprover TO DYNGRP GO

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

SQL Scripts for Microsoft Dynamics GP
Verify PM Batches Exist
Update Accrued Purchases Distribution on History Receipts from Posting Account Setup
Insert Mfg BOMs from Text File
SQL Function To Return Approver
List of Active Fixed Assets
Insert Manufacturing Routings from Text File
Table Function to Split String on Delimiter
List of Open Payables Transactions
Insert Creditor Item Numbers
Return Top Level BOM for Manufacturing Orders
Custom Purchase Order Email Notification to Originator on Workflow Final Approval
list of Open Payables Distributions
Set New Vendor On Hold if EFT Exists
Set New Vendor On Hold if EFT Exists
Payment Run Apply Query
List GL Transactions
Simple RMA Audit
Change Vendor Change Approvals Joins and Fields
Insert National Accounts from CSV
List GL Accounts With Notes
Import Site Bins From CSV
Remove Multicurrency from Sales Transactions
Change Email Notification Assignment
List General Ledger Transactions (Excluding Year End Journals)
List Taxes Linked to GL Accounts
Allow Workflow Originator to be an Approver
Add Joins and Fields to PM Document Approval Notification Emails
Update Accounts and Distributions on Work Status Sales Transactions from Item Card, Tax Details or Posting Account Setup
Upload and Verify Tax Commodity Codes
Delete Corrupt Extended Pricing Data
Assign All Items to All Site Bins
Sales Transactions (Work) Against a Specific Site
Change Web Service URi
SQL View to Return Quantity Available
Verify Tax Detail Assigned to Vendor
Insert Extended Pricing Price Sheet Header
Prefix Companies Names with System Designator
SQL View to Return Category Linked to Segment 3 in COA
Update Site Descriptions From CSV
Copy Workflow from Source to Destination Database
Extract GL Period Balances
Sales by Customer By Year
Purchased Items With Serial Numbers and Linked Sales Transactions
SQL View to Return Purchase Orders
Select All Primary Keys and Generate ALTER Script
Copy Workflow Calendar from Source to Destination Database
SQL Trigger on PO invoice Insert to Change GL posted Date
Sales by Salesperson By Year
Script to Set Transactions as Included on VAT Daybook Return
SQL Script to Return PO Receipts
Insert Extended Pricing Price Sheet UofM Work
View for Payables Transactions Extract
Export Open/History PM Transactions After a Specified Date
Copy Email Messages from a Source to Destination Database
PO Receipt History View
Insert Extended Pricing Price Sheet Assignments
Extract Payables Transactions from All Companies
List Open Purchase Orders
SQL View to Create Division Tree for Management Reporter
Select Chart of Accounts
Activate Horizontal Scroll Bars for All Existing Users
Workflow Assignment Review
Update Item Replenishment Method for Manufacturing
Get Alpha Characters from an Alphanumeric String
Set Vendor On Hold If EFT Details Changed
List Open Purchase Order Lines
SQL View to Create Division, including UDF 3 and 4, Tree for Management Reporter
Delete Orphaned Vendor EFT Details
Sales Invoice Query
Round Extended Pricing Price Sheet Item Value
Get Numeric Characters from an Alphanumeric String
Trigger to Activate Horizontal Scroll Bars for New Users
View to Return List of Payments and Linked Invoices
Select Duplicate Extended Pricing Price Sheet Work Records
RM Aged Debt Report
Select Next Temporary Creditor ID
Select a List of Vendor Addresses
Set Vendor On Hold When Created
Assembly Transaction Quantities Required
Generate Standard Cost Update Macro from Text File Import
Check for Corrupt Extended Pricing Records
Sales Line Items
Compare Ship To Address on Work Sales Trx Against Customer
SQL View to Return PO Commitment Detail
List Bank Accounts with Linked GL Accounts
Validate and Insert/Update Vendor Emails from a Text File
Return Items with Incorrect Quantities
Set Account Categories To User-Defined Field 2
Check Posting Type for Account (Segment 2)/Account Category Combinations
Update Ship To Name on Work Sales Transactions to Match the Customer Name
List Tax Detail Transactions
Select Tax Details and Related G/L Accounts
Update Account Description by Adding 3rd Segment Description
Update Segment Descriptions from Other Database
Return Opening Balance for Period of Supplied Date
Update Min Order Qty and Average Lead Time on Vendor Item From Text File
List of PM Invoices for Vendors with POs
Select Debit, Credit and Net Change for All Accounts in Date Range
Select All Pending Prepayments
Available Stock for All Items
Item Report
Migrate Vendor Emails from Active Docs to Standard Email Fields
Update Mfg Cost Accounts from Mfg Item Class Setup
PO Commitment Detail
Update Inventory Accounts from Item Class
Create Macro to Delete Items
Update Accounts Payable Distribution on Work Status PM Transactions from Posting Account Setup
Update Item Resource Planning on Item Quantity Master from Text File
SQL View to Return List of Posted Vendor Document Numbers
Update Inventory Distribution on Work Status Purchase Orders from the Item Card
Update Item Engineering File from a Text File
List of Exchange Rates

New book on Jet Reports with Microsoft Dynamics 365 Business Central available

Microsoft Dynamics 365 Business CentralI have a new book available now called Jet Reports with Microsoft Dynamics 365 Business Central; this book is aimed at end-users or consultants looking to use Jet Reports with Microsoft Dynamics 365 Business Central for financial and/or operational reporting.

The book covers the basics of installing and configuring Jet Reports as well as how to design and build reports using the Excel Add-in, before moving on to step-by-step guides on creating six different types of report and closing with a look at the report building tools, Jet Hub and report distribution.

Jet Reports with Microsoft Dynamics 365 Business Central by Ian Grieve

The book is available as an eBook direct from my azurecurve Publishing site or from Amazon (for $5 more):

The book is structured into these chapters:

  • Chapter 1, Introduction to Jet Reports, introduces Jet Reports and explains what type of reporting for which it can be used.
  • Chapter 2, Implementing Jet Reports, covers the installation of Jet Reports including the Jet Service Tier and Jet Hub.
  • Chapter 3, Configuring Jet Reports, shows how to configure Jet Reports once it has been installed.
  • Chapter 4, Introducing the Excel Add-in, introduces the Excel Add-in and the features available.
  • Chapter 5, Report Structure, shows how reports can be structured to make maintaining them easier.
  • Chapter 6, Using the functions in the Excel Add-in, shows how each of the four Jet Functions can be used.
  • Chapter 7, Creating and using an Options page, covers the creation and use of an options page in reports.
  • Chapter 8, Create a Summary Trial Balance, steps through the creation of a Summary Trial Balance report.
  • Chapter 9, Create a Detailed Trial Balance, shows how to make the Summary TB from the previous chapter into a Detailed report.
  • Chapter 10, Create a Balance Sheet, covers the creation of a formatted Balance Sheet.
  • Chapter 11, Create an Income Statement, covers the creation of an Income Statement and how to make it an intercompany/consolidated version.
  • Chapter 12, Create a Summary Payables Aged Trial Balance, shows how to create a Summary Payables Trial Balance report.
  • Chapter 13, Create a Sales Invoice by Customer Report, covers the creation of an operational report on sales invoices.
  • Chapter 14, Report Creation Tools, introduces the tools which can be used to make creating reports easier.
  • Chapter 15, Using Jet Hub, shows how users can access Jet Reports via web access and without a local install of Jet Reports.
  • Chapter 16, Report Distribution, shows how users can schedule or generate reports into Microsoft Word.

If you buy the ebook from me directly, the coupon code JetWithBCLaunch will get you 20% off the price of this book (offer available until the end of June 2023).