How to resend SSRS subscription emails? - ssrs-2016

If our report email subscriptions fail to get sent due to an issue like the SMTP server fails we have to manually re-send the report emails. Is there any way we can automatically re-fire the subscription emails and re-send them?

There's not an automatic way to do it.
You can get a list of the reports along with the Subscription IDs that failed by querying the Subscriptions table in the ReportServer database. Then JOIN it to the Catalog table to show the report details.
SELECT Sub.SubscriptionID,
Sub.InactiveFlags,
Sub.ExtensionSettings,
Sub.Description,
Sub.LastStatus,
Sub.EventType,
Sub.MatchData,
Sub.LastRunTime,
Sub.Parameters,
Sub.DeliveryExtension,
Cat.Path,
Cat.Name,
Cat.Description,
Cat.Hidden,
Cat.Parameter,
Cat.ExecutionFlag,
Cat.ExecutionTime
FROM [ReportServer].[dbo].[Subscriptions] as Sub
LEFT OUTER JOIN [ReportServer].[dbo].[Catalog] as Cat on
Sub.Report_OID = ItemID
WHERE LastStatus LIKE 'Failure%'
You could then use the Subscription ID to fire off the subscription for each report using the AddEvent function.
EXEC dbo.AddEvent #EventType = 'TimedSubscription', #EventData = #SUBSCRIPTION_ID;
You could create a stored procedure to loop through the table and fire off the subscriptions.

I've used a similar approach to what Hannover Fist posted, but with a different approach to re-firing the subscriptions:
SELECT
S.ScheduleID AS SQLAgent_Job_Name,
SUB.Description AS Sub_Desc,
SUB.DeliveryExtension AS Sub_Del_Extension,
C.Name AS ReportName,
C.Path AS ReportPath,SUB.LastStatus
FROM ReportSchedule RS
INNER JOIN Schedule S ON (RS.ScheduleID = S.ScheduleID)
INNER JOIN Subscriptions SUB ON (RS.SubscriptionID = SUB.SubscriptionID)
INNER JOIN [Catalog] C ON (RS.ReportID = C.ItemID AND SUB.Report_OID = C.ItemID)
WHERE LEFT (SUB.LastStatus, 12) Like 'Failure%' or LEFT (SUB.LastStatus, 12) Like 'Error%'
order by reportname
USE msdb
EXEC sp_start_job #job_name = <SQLAgent_Job_Name>
One of the big differences is that mine captures both "Failure" and "Error" statuses.
I wish that I could remember where I found this so that I could give proper credit for it, since it's been a life-saver on a couple of occasions.

Related

NetSuite Search formula for items that have no open transactions

I am trying to create a formula to obtain a list of items that have no open transactions.
I cant just filter out by status as this filters out transactions that are open, as opposed to showing me only items with nothing open.
So basically if an item has anything open then i dont want it on the search. I do need it on the search if it has all closed or it has no transactions at all.
Hoping someone can help put me in the right direction.
I am a little bit stuck at where to start with the formulas and tried a case formula.
You can use item saved search adding under criteria as "Transaction Fields-status-anyOf-select all closed/rejected/declined statuses" not in filter reason of saved search.
Thanks.
To get the value of non transaction items as well, You need to check the check box use expression under criteria in standard subtab use parens() with OR expression.
And add one more condition as "Transaction Fields-Internal Id-anyOf-none with
"Transaction Fields-status-anyOf-select all closed/rejected/declined statuses".
Add both condition with OR logic.
It will work for both items condition if it has transaction status with closed or with none of transaction internal ids.
Thanks.
I think this is possible in a saved search, and requires a change in the way the filtering is done. Rather than filtering on the "Filters", using grouping and summary calculations to determine if an item qualifies, basically :
Create the item saved search as you would normally, but don't include a "Standard" filter for the openness of the transaction.
In the results, group by item name (or internalid), and another fields you want to include in the top-level results.
In the Criteria - Summary list, add a Formula (Number) condition :
Summary Type= Sum (Count won't work here)
Formula = case when {transaction.status} = 'Open' then 1 else 0 end
Equal to 0
Whether this is more or less elegant than bknight's answer is debatable.
I don't think this is the sort of thing you can do with a single saved search.
It would be fairly easy to do with SuiteQL though.
The script below runs in the console and finds items that are not on any Pending Billing Sales Orders. It's adapted from a script with a different purpose but illustrates the concept.
You can get a list of the status values to use by creating a saved search that finds all the transactions with open statuses you want to exclude , take note of that saved search's id and running the second script in the console
require(['N/query'], query => {
const sqlStr = `
select item.id, itemid, count(po.tranid) as po, count(bill.tranId) as bill, max(bill.tranDate) as lastBilled, count(sale.tranId) as sales, count(tran.tranId) as trans
from item
left outer join transactionLine as line
on line.item = item.id
left outer join transaction as tran on line.transaction = tran.id
left outer join transaction as po on line.transaction = po.id and po.type = 'PurchOrd'
left outer join transaction as bill on line.transaction = bill.id and bill.type = 'VendBill'
left outer join transaction as sale on line.transaction = sale.id and sale.type in ('CustInvc', 'CashSale')
where item.id not in (select otl.item from transactionLine otl, transaction ot where
otl.transaction = ot.id and ot.status in ('SalesOrd:F'))
group by item.id, item.itemid
`;
console.log(sqlStr);
console.log(query.runSuiteQL({
query: sqlStr
}).asMappedResults().map((r, idx)=>{
if(!idx) console.log(JSON.stringify(r));
return `${r.id}\t${r.itemid}\t${r.po}\t${r.bill}\t${r.lastBilled}\t${r.sales}\t${r.trans}`;
}).join('\n'));
});
require(['N/search'], search=>{
const filters = search.load({id:304}).filters;
console.log(JSON.stringify(filters.find(f=>f.name == 'status'), null, ' '));
});
In terms of doing something with this you could run this in a saved search and email someone the results, show the results in a workbook in SuiteAnalytics or build a portlet to display the results - for this last Tim Dietrich has a nice write up on portlets and SuiteQL

Excel removes my query connection on it's own and gives me several error messages

I know that this is a really long post but I'm not sure of what part of my process is making my file crash, so I tried to detail everything about what I did to get to the error messages.
So, first of all, I created a query on Kusto, which looks something similar to this but in reality is 160 lines of code, this is just a summarized version of what my code might do just to show my working process.
First, what I do in Session_Id_List is create a list of all distinct Session Id's from the past day.
Then on treatment_alarms1 I count the amount of alarms for each type of alarm that was active during each session.
Then, on treatment_alarms2 I create a list which might look something like this
1x Alarm_Type_Number1
30x Alarm_Type_Number2
7x Alarm_Type_Number3
and like that for each treatment, so I have a list of all alarms that were active for that treatment.
Lastly, I create a left outer join with Session_Id_List and treatment_alarms2. This means that I will get shown all of the treatment ID's, even the ones that did not have any active alarms.
let _StartTime = ago(1d);
let _EndTime = ago(0d);
let Session_Id_List = Database1
| where StartTime >= _StartTime and StartTime <= _EndTime
| summarize by SessionId, SerialNumber, StartTime
| distinct SessionId, StartTime, SerialNumber;
let treatment_alarms1 = Database1
| where StartTime >= _StartTime and StartTime <= _EndTime and TranslatedData_Status == "ALARM_ACTIVE"
| summarize number_alarms = count() by TranslatedData_Value, SessionId
| project final_Value = strcat(number_alarms, "x ", TranslatedData_Value), SessionId;
let treatment_alarms2 = Database1
| where StartTime >= _StartTime and StartTime <= _EndTime and TranslatedData_Status == "ALARM_ACTIVE"
| join kind=inner treatment_alarms1 on SessionId
| summarize list_of_alarms_all = make_set(final_Value) by SessionId
| project SessionId, list_of_alarms_all;
let final_join = Session_Id_List
| join kind=leftouter treatment_alarms2 on SessionId;
final_join
| project SessionId, list_of_alarms_all
Then I put this query into Excel, by using the following method
I go to Tools -> Query to Power BI on Kusto Explorer
I go to Data -> Get Data -> From Other Sources -> Blank Query
I go to advanced editor
I copy and paste my query and press "Done" at the bottom
If you see now, the preview of my data will show "List" on the list_of_alarms_all column, rather than showing me the actual values of the list.
To fix this issue I first press the arrows on the header of the column
I press on "Extract Values"
I select Custom -> Concatenate using special characters -> Line Feed -> Press OK
That works fine for all of the ID's that do have alarms on them, it shows them as a list and tells me how many there are, the issue is with the ID's that did not have any treatments where I get "Error" on the Excel preview. Once I press "Close & Load" the data is put on the worksheet and it looks fine, the "Error" are all gone and instead I get empty cells where the "Error" would be at.
The problem now starts when I close the file and try to open it again.
First I get this message. So I press yes to try and enter the file.
Then I get this other message. The problem with this message is that it says that I have the file open when that is not true. I even tried to restart my laptop and open the file again and I would still get the message when in reality I don't have that file open.
Then I get this message, telling me that the connection to the query was removed.
So my problem here is that 1) I can't edit the file anymore unless I make a copy because I keep getting the message saying that I already have the file opened and it is locked for editing and 2) I would like to refresh this query with VBA maybe once a week from now on but I can't because when I save the file the connection to the query is deleted by excel itself.
I'm not sure of why this is happening, I'm guessing it's because of the "Error" I get on the empty cells when I try to extract the values from the lists. If anybody has any information on how I can fix this so I don't get these error messages please let me know.
I was not able to reproduce your issue, however there are some things you might want to try.
Within ADX, you could wrap you query with a function, so you won't have to copy a large piece of code into your Excel.
You could deal with null values (this is what gives you the Error values) already in your query. Note the use of coalesce.
// I used datatable to mimic your query results
.create-or-alter function SessionAlarms()
{
datatable (SessionId:int,list_of_alarms_all:dynamic)
[
1, dynamic([10,20,30])
,2, dynamic([])
,3, dynamic(null)
]
| extend list_of_alarms_all = coalesce(list_of_alarms_all, dynamic([]))
}
You can use Power Query ADX connector and copy your query/function As Is
If you haven't dealt with null values in you KQL you can take care of the error in Excel by using Replace Errors

Populating custom table on Shipment release

I have created a custom table and made it available on the Customers screen called 'Serial Tracking'. The purpose of this screen is to track serialised items that each customer is in possession of (regardless of who the item was purchased from).
I would like a record automatically added to the table on shipment release. I have attempted to customise the Release method of SoShipmentEntry but am having trouble getting all the required data together as well as the best way to structure the code.
The custom table DAC is
AUSerialTrack
Not necessarily the answer to your question but to long for a comment.
As an alternative, what if you set your Serials tab view to the Ship Line Split table without dealing with a custom table. You could get the information you needed with something like this: (need to convert to your BQL view for your serials tab)
SELECT [ship].[CustomerID],
[ship].[ShipmentNbr],
[split].[InventoryID],
[split].[LotSerialNbr]
FROM [dbo].[SOShipLineSplit] split
INNER JOIN [dbo].[SOShipLine] line
ON [line].[CompanyID] = [split].[CompanyID]
AND [line].[ShipmentNbr] = [split].[ShipmentNbr]
AND [line].[LineNbr] = [split].[LineNbr]
INNER JOIN [dbo].[SOShipment] ship
ON [ship].[CompanyID] = [split].[CompanyID]
AND [ship].[ShipmentNbr] = [split].[ShipmentNbr]
INNER JOIN [dbo].[InventoryItem] i
ON [i].[CompanyID] = [split].[CompanyID]
AND [i].[InventoryID] = [split].[InventoryID]
INNER JOIN [dbo].[INLotSerClass] c
ON [c].[CompanyID] = [i].[CompanyID]
AND [c].[LotSerClassID] = [i].[LotSerClassID]
WHERE [c].[LotSerTrack] = 'S'
AND [ship].[Confirmed] = 1;
Then when the user goes to the tab its always the current results. No custom code to fill in a custom table so easier for upgrades/customization maintenance.

Query Trac for all tickets related to a user

How do I query for all trac tickets related to a user. i.e. all tickets for which the tickets were once assigned, assigned now, created , etc etc
Create custom queries to the ticket_change table. Some SQL required. For assigned once/now, look for rows where field='owner', newvalue column contains the user name the ticket was assigned to. For created tickets, just query by reporter in the ticket table.
Example:
SELECT p.value AS __color__,
id AS ticket, summary, component, version, milestone,
t.type AS type, priority, t.time AS created,
changetime AS _changetime, description AS _description,
reporter AS _reporter
FROM ticket t, enum p, ticket_change c
WHERE p.name = t.priority AND p.type = 'priority'
AND c.field = 'owner'
AND c.newvalue = '$USER'
AND c.ticket = t.id
ORDER BY p.value, milestone, t.type, t.time
You can express this with a TraqQuery expression. E.g. if you want the columns id, summary and status to show up and query all the tickets for the currently logged in user ($USER) then use the following query.
query:?col=id
&
col=summary
&
col=status
&
owner=$USER
However this query assumes that the owner hasn't been the same during the lifetime of a ticket (since ownership can be changed).
If you want a specific user then replace $USER with the actual username. Also if you're using the Agilo plugin you can easily create new queries on the fly via the web-UI. This is done by looking at a report and adding filters to the report.

How do I determine the disk size of a SharePoint list?

I have a list with roughly 5500 items, and I would like to find out the size on disk. Is there some way I can do this? I don't mind running a query in the database, if necessary.
Navigate to http://[myapplication]/[mySitecollection]/_layouts/storman.aspx
This will list the Storage Space Allocation for the site collection.
If you enable a site quota, an option under site settings appears called Storage Space Allocation. When you go to set a quota in the Central Administration, the page will tell you what the current storage used is so you can have an idea before there. Once you get to the Storage Space Allocation report, you can see the total size of a library.
Unfortunately, you can't get this report without turning on a site quota.
I could not get Tim Dobrinski's suggestion to work. This T-SQL query does not deal with everything, but gives a very good idea. Pop it into Excel, then add a column for "Size in MB" and add in a formula.
USE [WSS_Content]
GO
SELECT
[dbo].[Webs].[FullUrl]
,[dbo].[Lists].[tp_Title] AS "ListName"
,[dbo].[Docs].[DirName]
,[dbo].[Docs].[LeafName]
,[dbo].[Docs].[Size]
,[dbo].[Docs].[MetaInfoSize]
,[dbo].[Docs].[Version]
,[dbo].[Docs].[TimeCreated]
,[dbo].[Docs].[TimeLastModified]
,[dbo].[Docs].[MetaInfoTimeLastModified]
,[dbo].[Docs].[CheckoutUserId]
,[dbo].[Docs].[CheckoutDate]
,[dbo].[Docs].[ExtensionForFile]
FROM [WSS_Content].[dbo].[Docs]
INNER JOIN [WSS_Content].[dbo].[Webs] ON [dbo].[Webs].[Id] = [dbo].[Docs].[WebId]
INNER JOIN [WSS_Content].[dbo].[Lists] ON [dbo].[Lists].[tp_ID] = [dbo].[Docs].[ListId]
WHERE [dbo].[Docs].[Size] > 0
AND ([dbo].[Docs].[LeafName] NOT LIKE '%.stp')
AND ([dbo].[Docs].[LeafName] NOT LIKE '%.aspx')
AND ([dbo].[Docs].[LeafName] NOT LIKE '%.xfp')
AND ([dbo].[Docs].[LeafName] NOT LIKE '%.dwp')
AND ([dbo].[Docs].[LeafName] NOT LIKE '%template%')
AND ([dbo].[Docs].[LeafName] NOT LIKE '%.inf')
AND ([dbo].[Docs].[LeafName] NOT LIKE '%.css')
If you save the list in question as a template to the file system, this should give you a rough idea of its size. If you need to do this on a periodic basis this approach is not as useful.
Site Settings -> Storage Metrics
You can see how much each object is consuming, click on Lists to see each individual list
You don't have to set a site quota
Sharepoint 2013
This is taken from SharePoint 2013:
USE [WSS_Content_Intranet]
GO
SELECT
(ISNULL(DocSizes,0) + ISNULL(UserDataSize,0)) As TotalSize,
nLists.tp_ID,
nLists.tp_Title,
nLists.tp_ItemCount,
Webs.FullUrl
FROM
Webs
INNER JOIN
(
SELECT
ALAux.ItemCount as tp_ItemCount,
Lists.tp_Title,
Lists.tp_ID,
Lists.tp_WebID,
ALAux.Modified as tp_Modified,
Lists.tp_ServerTemplate,
Docs.DirName,
Docs.LeafName,
Lists.tp_ImageUrl
FROM
Lists
CROSS APPLY
TVF_AllListsAux_NoLock_ListId(Lists.tp_SiteId, Lists.tp_ID) AS ALAux
INNER JOIN
Docs
ON
Lists.tp_RootFolder = Docs.Id AND
Lists.tp_WebId = Docs.WebId
WHERE
tp_BaseType <> 1 AND
Lists.tp_SiteId = YOUR_SITE_ID
) As nLists
ON
Webs.Id = nLists.tp_WebId
LEFT OUTER JOIN
(
SELECT
(SUM(CAST((ISNULL(Docs.Size,0)) AS BIGINT))) As DocSizes,
Docs.ListId,
Docs.SiteId
FROM
Docs
WHERE
Docs.Type = 0 AND SiteId = YOUR_SITE_ID
GROUP BY
Docs.ListId,Docs.SiteId
) As DocsInList
ON
DocsInList.ListId = nLists.tp_ID
LEFT OUTER JOIN
(
SELECT
(SUM(CAST((ISNULL(tp_Size,0)) AS BIGINT))) As UserDataSize,
tp_ListId
FROM
UserData
GROUP BY
UserData.tp_ListId
) AS UserDataInList
ON
UserDataInList.tp_ListId = DocsInList.ListId
ORDER BY TotalSize DESC
It returns all lists of all webs, summing the size of the items and the attached documents. Document libraries are not included, use this:
SELECT
Lists.tp_Title,
Lists.tp_ID as Id,
SUM(Docs.Size/1024 + Docs.MetaInfoSize/1024)/1024 AS SizeMB,
COUNT(*) as NumberOfFiles
FROM dbo.Docs
INNER JOIN Webs ON Webs.Id = Docs.WebId
INNER JOIN Lists ON Lists.tp_ID = Docs.ListId
WHERE Docs.Size > 0
GROUP BY Lists.tp_Title,Lists.tp_ID

Resources