Wednesday, April 12, 2017

How to auto document SSRS reports

Creating adequate documentation for any IT project is a challenge, particularly with SSRS where an organization can have literally hundreds or thousands of reports in production. Writing the documentation alone can be a formidable task, not to mention keeping it up-to-date when changes are made.

Fortunately, the SQL Server ReportServer.dbo.Catalog table contains data that can be used to create a documentation system that is automatically updated as report changes are made.
Microsoft does not document or support querying the ReportServer.dbo.Catalog table.

















...but it contains a lot of useful information. The Content field, for instance, contains the entire RDL file that defines each report. The following query...
SELECT        Name as ReportName
,CONVERT(Varchar(Max),CONVERT(VARBINARY(MAX),Content)) AS ReportContent
FROM 
ReportServer.dbo.Catalog Where Content is NOT NULL

...extracts the Content field to reveal the RDL XML code.


This query...

WITH XMLNAMESPACES ( DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition',
'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' AS rd )
SELECT DISTINCT ReportName            = name
,CommandText         = x.value('(Query/CommandText)[1]','VARCHAR(250)')
FROM ( SELECT C.Name,CONVERT(XML,CONVERT(VARBINARY(MAX),C.Content)) AS reportXML
      FROM ReportServer.dbo.Catalog C
     WHERE C.Content is not null
      AND C.Type = 2
          ) a
CROSS APPLY reportXML.nodes('/Report/DataSets/DataSet') r ( x )
CROSS APPLY x.nodes('Fields/Field') f(df)
ORDER BY name 
...extracts the SQL commands embedded in the RDL code.

If you cannot get the above two queries to work, you probably need to change the schema in the queries to the schema being used by SQL Server on your SQL Server installation.
Open an SSRS report in Visual Studio and select View-Code from the main menu.
Change the schema in the queries to the one in the SSRS code.

The following query is used in the zipped  "SSRS Dynamic Documentation" SSRS report RDL resource file attached to this article.

BEGIN TRY
DROP TABLE #ReportList
END TRY

BEGIN CATCH
END CATCH

BEGIN TRY
DROP TABLE #ReportParameters
END TRY

BEGIN CATCH
END CATCH

BEGIN TRY
DROP TABLE #ReportFields
END TRY

BEGIN CATCH
END CATCH

SELECT
Name,Path
INTO #ReportList
FROM ReportServer.dbo.Catalog
WHERE Content IS NOT NULL
ORDER BY Name;

SELECT DISTINCT Name as ReportName
,ParameterName = Paravalue.value('Name[1]', 'VARCHAR(250)')
,ParameterType = Paravalue.value('Type[1]', 'VARCHAR(250)')
,ISNullable = Paravalue.value('Nullable[1]', 'VARCHAR(250)')
,ISAllowBlank = Paravalue.value('AllowBlank[1]', 'VARCHAR(250)')
,ISMultiValue = Paravalue.value('MultiValue[1]', 'VARCHAR(250)')
,ISUsedInQuery = Paravalue.value('UsedInQuery[1]', 'VARCHAR(250)')
,ParameterPrompt = Paravalue.value('Prompt[1]', 'VARCHAR(250)')
,DynamicPrompt = Paravalue.value('DynamicPrompt[1]', 'VARCHAR(250)')
,PromptUser = Paravalue.value('PromptUser[1]', 'VARCHAR(250)')
,State = Paravalue.value('State[1]', 'VARCHAR(250)')


INTO #ReportParameters
FROM ( 
SELECT top 1000 C.Name,CONVERT(XML,C.Parameter) AS ParameterXML
FROM  ReportServer.dbo.Catalog C
WHERE  C.Content is not null
AND  C.Type  = 2
) a


CROSS APPLY ParameterXML.nodes('//Parameters/Parameter') p ( Paravalue )
ORDER BY ReportName,ParameterName;
WITH XMLNAMESPACES ( DEFAULT 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition', 'http://schemas.microsoft.com/SQLServer/reporting/reportdesigner' AS rd )

SELECT DISTINCT ReportName = name ,DataSetName = x.value('(@Name)[1]', 'VARCHAR(250)')
,DataSourceName = x.value('(Query/DataSourceName)[1]','VARCHAR(250)')
,CommandText = x.value('(Query/CommandText)[1]','VARCHAR(250)')
,Fields = df.value('(@Name)[1]','VARCHAR(250)')
,DataField = df.value('(DataField)[1]','VARCHAR(250)')
,DataType = df.value('(rd:TypeName)[1]','VARCHAR(250)')
,ConnectionString = x.value('(ConnectionProperties/ConnectString)[1]','VARCHAR(250)')

INTO #ReportFields
FROM ( SELECT C.Name,CONVERT(XML,CONVERT(VARBINARY(MAX),C.Content)) AS reportXML


FROM ReportServer.dbo.Catalog C
WHERE C.Content is not null
AND C.Type = 2
) a

CROSS APPLY reportXML.nodes('/Report/DataSets/DataSet') r ( x )
CROSS APPLY x.nodes('Fields/Field') f(df)
ORDER BY name

SELECT
a.Name AS ReportName
,a.Path
,SUBSTRING(a.Path,1,LEN(a.Path)-LEN(a.Name)) AS ReportFolder
,'http://msl-db12/Reports/Pages/Report.aspx?ItemPath='+REPLACE(SUBSTRING(a.Path,1,LEN(a.Path)-LEN(a.Name)),'/','%2f')+REPLACE(a.Name,' ','+') AS ReportLink
,'User Input' AS FieldType
,b.ParameterPrompt AS DataSetOrPromptName
,b.ParameterName AS FieldOrParameterName

FROM #ReportList a
LEFT OUTER JOIN #ReportParameters b ON a.Name = b.ReportName
WHERE b.ParameterName IS NOT NULL
UNION
SELECT
a.Name AS ReportName
,a.Path
,SUBSTRING(a.Path,1,LEN(a.Path)-LEN(a.Name)) AS ReportFolder
,'http://msl-db12/Reports/Pages/Report.aspx?ItemPath='+REPLACE(SUBSTRING(a.Path,1,LEN(a.Path)-LEN(a.Name)),'/','%2f')+REPLACE(a.Name,' ','+') AS ReportLink
,'Data Point' AS FieldType
,b.DataSetName AS DataSetOrPromptName
,b.Fields AS FieldOrParameterName

FROM #ReportList a
LEFT OUTER JOIN #ReportFields b ON a.Name = b.ReportName
WHERE b.Fields IS NOT NULL
ORDER BY Name,Path,FieldType,ParameterPrompt,ParameterName

Deploy this SSRS report to your report server with a user that has read privileges on the ReportServer databse after changing the schema referenced by the DataSet1 query, if necessary.
When you run the report, it will display the name of each report, the report server folder in which it resides, a link to the report and a listing of all the datasets,fields and parameters used by the report.

When you click the report link, you will be taken to that report.

Sunday, April 9, 2017

Microsoft teams chat app


Microsoft Teams—is a  new chat-based workspace in Office 365.

Microsoft Teams is a new experience that brings together people, conversations and content—along with the tools that teams need—so they can easily collaborate to achieve more. It’s naturally integrated with the familiar Office applications and is built from the ground up on the Office 365 global, secure cloud.

Starting today, Microsoft Teams is available in preview in 181 countries and in 18 languages to commercial customers with Office 365 Enterprise or Business plans, with general availability expected in the first quarter of 2017.

Teams are now more agile and organizational structures more flat to keep communications and information flowing. A more open, digital environment that makes work visible, integrated and accessible—across the team—so everyone can stay in the know.

Create a digital workspace for high performing teams.

Chat for today’s teams

Microsoft Teams supports not only persistent but also threaded chats to keep everyone engaged. Team conversations are, by default, visible to the entire team, but there is of course the ability for private discussions. Skype is deeply integrated, so teams can participate in voice and video conferences.

Everyone can add personality to their digital workspace with emoji’s, stickers, GIFs and custom memes to make it their own.

A hub for teamwork

Microsoft Teams brings together the full breadth and depth of Office 365 to provide a true hub for teamwork.

Word, Excel, PowerPoint, SharePoint, OneNote, Planner, Power BI and Delve are all built into Microsoft Teams so people have all the information and tools they need at their fingertips.

Backed by the Microsoft Graph, intelligent services are surfaced throughout the workspace to help with information relevancy, discovery and sharing.

Microsoft Teams is also built on Office 365 Groups—the  cross-application membership service that makes it easy for people to move naturally from one collaboration tool to another, preserve their sense of context and share with others.

Customizable for each team

All teams are unique, and  people can customize their workspace, with rich extensibility and open APIs available at general availability. For example, Tabs provides quick access to frequently used documents and cloud services.

Microsoft Teams shares the same Connector model as Exchange, to provide notifications and updates from third-party services like Twitter or GitHub.
There is  full support for the Microsoft Bot Framework to bring intelligent first- and third-party services into a team environment.
The Microsoft Teams Developer Preview program, is now open and allows developers to extend Microsoft Teams.
Security teams trust
Finally, Microsoft Teams provides the advanced security and compliance capabilities of  Office 365 customers expect.
Data is encrypted in transit and at rest. A transparent operational model with no standing access to customer data. Microsoft Teams will support key compliance standards including EU Model Clauses, ISO 27001, SOC 2, HIPAA and more., Microsoft Teams is served out of Microsoft’s  hyper-scale global network of data centers, automatically provisioned within Office 365 and managed centrally, just as any other Office 365 service.
Microsoft Teams joins the Office 365 universal toolkit
Microsoft Teams joins the broadest and deepest portfolio of collaboration applications and services to help solve the diverse needs of people and organizations globally.
Among the 85 million active monthly users, all groups have a diverse set of needs
·         Exchange is the undisputed leader in corporate email and according to Gartner has “80 percent share of companies using cloud email with revenue above $10 billion.”
  • SharePoint provides intranets and content management solutions to more than 200,000 organizations and 190 million people.
  • Yammer is the social network for work, enabling cross-company discussions for 85 percent of the Fortune 500.
  • Skype for Business provides real-time voice, video and conferencing and hosts more than 100 million meetings a month.
  • Office 365 Groups is our cross-application membership service that makes it easy for people to move naturally from one collaboration tool to another.
Frequently asked questions
Q. Which Office 365 plans will include Microsoft Teams?
A. Microsoft Teams is available to Office 365 commercial customers with one of the following plans: Business Essentials, Business Premium, and Enterprise E1, E3 and E5. Microsoft Teams will also be available to customers who purchased E4 prior to its retirement.
Q. What action do Office 365 IT admins need to take to access the preview of Microsoft Teams?
A. To turn on Microsoft Teams, IT admins should go to their Office 365 admin center, click Settings > Services & Add Ins > Microsoft Teams.
Q. When will Microsoft Teams roll out broadly to all eligible Office 365 customers?
A. Microsoft Teams is available in preview to eligible Office 365 commercial customers beginning November 2, 2016. We expect the service to become generally available in the first quarter of calendar year 2017.
Q. What platforms does Microsoft Teams support?
A. Microsoft Teams runs on Windows, Mac, Android, iOS and web platforms.
Q. What level of security and compliance does Microsoft Teams support?
A. Microsoft Teams is expected to be Office 365 Tier C compliant at launch. This broad set of global compliance and data protection requirements includes ISO 27001, ISO 27018, EUMC, SOC 1 Type I & II, SOC 2 Type I and II, HIPAA and FERPA. Microsoft Teams also enforces two-factor authentication, single sign on through Active Directory and encryption of data in transit and at rest.
Q. What trainings are available to help Office 365 admins learn about Microsoft Teams?
A. We have two different trainings currently available for our IT admins. To view the trainings, visit the Microsoft Virtual Academy website. We have a video on Microsoft Mechanics and more information on the Microsoft Teams


Thursday, April 6, 2017

What is Microsoft Graph


Overview of Microsoft Graph

Allows applications to access digital work and digital life data across the intelligent Microsoft cloud. This represents three big advantages for developers not available before:

  • Unified Microsoft API endpoint for accessing the capabilities of the Microsoft cloud.
  • Unified access to data living in the Microsoft cloud.
  • Unified access to intelligence and insights coming from the Microsoft cloud.

In other words, the Microsoft Graph surfaces intelligent insights by bringing together smart machine learning algorithms with a wealth of data and user behavior—all with just a single authorization token.

Unified Microsoft API endpoint for accessing the capabilities of the Microsoft cloud

The Microsoft Graph today exposes APIs, data and intelligence across Office 365 and Azure AD. That is building toward a near future where multiple graphs and all APIs throughout Microsoft contribute to, and are accessible through, a single unified gateway to the power of the Microsoft cloud. Any developer capable of making an HTTP request can call the API, from any platform, and once-siloed Office 365 services can now be directly navigated via Microsoft Graph. For developers, what used to be 50+ lines of code are now cut to five.

SDKs for  .Net, iOS and Android and will expand to other platforms like Node.js, Python, Java and Ruby. Code samples for a variety of platforms are available on GitHub.

Unified access to rich data living in the Microsoft cloud

Think of the Microsoft Graph as the gateway for developers to access the rich data living in the Microsoft cloud.

The opportunities for developers to shape the way the world works are endless. Within the Office 365 surface area alone, consider the amount of data we have with:

  • More than 18 million consumer Office 365 subscribers.
  • 60 million commercial Office 365 monthly active users.
  • More than half a billion people managing their documents and photos in OneDrive.
  • Over 200 million downloads of Office mobile (WXP, Outlook, OneNote on iOS and Android mobile devices).

Unified access to intelligence and insight coming from the Microsoft cloud

The Microsoft Graph is the consistent endpoint for developers to access intelligent insights that Microsoft builds in the cloud.

And because the Microsoft Graph has access to your activities (e.g. documents, calendars, meetings), it can be used to address a ton of critical work and productivity questions, such as:

  • Who does the user work closely with?
  • What documents and topics are important to my colleagues right now?
  • What matters the most to my boss?

With the Microsoft Graph, developers are empowered to build smart, people-centric applications that can easily interact with data from all touchpoints of modern work.

Microsoft Graph—what’s available today?

Below are details of what’s generally available and what’s on preview,:

  • General availability (ready for production)—Users, Files, Messages, Groups, Events, Contacts (personal), Mail, Calendar, Devices and other directory objects and docs.
  • Preview (available to explore)—Notifications, SDKs, People, Organizational contacts, Office Graph, Planner, OneNote, Converged Auth. flow support, OneDrive Files and Outlook.

Developers can get started immediately and build Microsoft Graph-based solutions for free using an Office 365 developer tenant. Access to the Office 365 APIs and data through the Microsoft Graph is included in the customer’s Office 365 license. This includes all the APIs that are available with the general release today. Access to intelligence is paid—with some intelligence features explicitly included in the Office 365 license and some licensed separately. Over time, we plan on adding additional capabilities to the Microsoft Graph that may be licensed separately.

A huge opportunity for developers to reach the 1.2 billion Office users worldwide,




Microsoft Graph exposes multiple APIs from Office 365 and other Microsoft cloud services through a single endpoint: https://graph.microsoft.com. Microsoft Graph simplifies queries that would otherwise be more complex.  Note it’s still not fully production ready.
You can use Microsoft Graph to:
1.     Access data from multiple Microsoft cloud services, including Azure Active Directory, Exchange Online as part of Office 365, SharePoint, OneDrive, OneNote, and Planner.
2.     Navigate between entities and relationships.
3.     Access intelligence and insights from the Microsoft cloud (for commercial users).
Microsoft Graph development stack


Common Microsoft Graph queries
Microsoft Graph exposes two endpoints: /v1.0 and /beta. The /v1.0 endpoint includes the resources that you can access in your production app. The /beta endpoint includes APIs that are currently in preview. The following table lists some common queries that you can use to access the Microsoft Graph API.
Operation
Service endpoint
GET my profile
GET my files
GET my photo
GET my mail
GET my high importance email
GET my calendar
GET my manager
GET last user to modify file foo.txt
GET unified groups I’m member of
GET users in my organization
GET group conversations
GET people related to me
GET files trending around me
GET people I am working with
GET my tasks
GET my notes
Note: The APIs in the beta endpoint are subject to change. We don't recommend that you use them in your production apps.

More Than One Form Was Opened at Once for the Lookup Control

In Dynamics 365 for Finance and Operations, when subscribing to a lookup event to modify an existing lookup on a form control, you must...