Use PowerShell utilities in your Windows CMD scripts

Want a random number in your Windows command file? This little trick works wonders and uses PowerShell to generate the number, mapping the returned value to a script variable.

for /f “usebackq” %%i in (`PowerShell $randomNumber ^= Get-Random^; $randomNumber;^`) do set VALUE=%%i
echo Value is %VALUE%

Use the same pattern to enrich your CMD scripts with other PowerShell utilities and code, for example…

for /f “usebackq” %%i in (`PowerShell $date ^= Get-Date^; $date.ToString^(‘yyyy-MM-ddThh:mm:ss’^)`) do set LOGDATE=%%i
echo Date is %LOGDATE%

just remember to escape any script special characters (< > | etc) using a caret (^)

Maintaining CRM 2011 Job Schedules

The CRM 2011 background job schedule can be changed with this tool from CodePlex.

http://crmjobeditor.codeplex.com/

The MSDN blog gives a good overview

http://blogs.msdn.com/b/crminthefield/archive/2012/04/26/avoid-performance-issues-by-re-scheduling-crm-2011-maintenance-jobs.aspx

List out jobs and last run times on SQL 2013

Generate a table of jobs and their last run times on SQL Server 2013.

use msdb
;WITH jobhistory as (
SELECT job_id,
run_status,
last_run_time = max(dbo.agent_datetime(run_date, run_time))
FROM msdb.dbo.sysjobhistory
WHERE step_id = 0
AND run_status = 1
GROUP BY job_id, run_status)

SELECT … Continue Reading

List SQL 2013 Table Sizes and Row Counts

Tabulate the table sizes and row counts in a SQL 2013 DB

SELECT
s.name + ‘.’ + t.Name AS [Table Name],
t.object_id as [Object Id],
part.rows AS [Total Rows In Table – Modified],
CAST((SUM( DISTINCT au.Total_pages) * 8 ) / 1024.000 / 1024.000 AS NUMERIC(18, 3))
AS [Table’s Total Space In GB]
FROM
SYS.Tables t INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
INNER JOIN SYS.Indexes idx ON t.Object_id = idx.Object_id
INNER JOIN SYS.Partitions part ON idx.Object_id = part.Object_id
AND idx.Index_id = part.Index_id
INNER JOIN SYS.Allocation_units au ON part.Partition_id = au.Container_id
INNER JOIN SYS.Filegroups fGrp ON idx.Data_space_id = fGrp.Data_space_id
INNER JOIN SYS.Database_files Df ON Df.Data_space_id = fGrp.Data_space_id
WHERE t.Is_ms_shipped = 0 AND idx.Object_id > 255
GROUP … Continue Reading

Multi Select options updated for Dynamics CRM 2011 Rollup 14

Multi-select options in Dynamics CRM 2011 (and 4.0) have been solved in a number of ways, many being based on Jim Wang’s excellent solution. With the introduction of cross-browser support and the XRM client API, there are a number of tweaks to make to Jim’s solution making it cross browser compatible and supporting CRM 2011 Rollup 14.

Initially, dependency on a cross-browser script library should be used. In this instance im using jQuery (HREF).  The remaining changes include the use of the XRM.Page functions rather than getElementById througout the script.

The script is called with the function DisplayMultiSelectPickList(“new_CustomOptionsField”, “new_CustomOptionsValue”);
where new_CustomOptionsField … Continue Reading

CRM 2013 – Update the Business Process and Stage dynamically

If you wish to update the Business Process Flow stage of any entity in a workflow, its not immediately obvious how to do it. Develop1 have a fantastic Custom Workflow Activity that does the job.

With a few tweaks, a similar activity can update the BPF stage of an entity ‘created’ during the workflow process.

Add an InArgument of type EntityReference to the Activity, you need to specify what type of entity the reference will refer to.

[RequiredArgument]
[Input(“Related Opportunity”)]
[ReferenceTarget(“opportunity”)]
public InArgument RelatedOpportunity { get; set; }

Then use it in the activity like any other EntityReference type.

Continue Reading

Palazzetti Ecofire Stove “Extraordinary Maintenance” Message

The Palazzetti Ecofire range of pellet stoves have an in-built maintenance warning that pops-up after a configured number of hours (usually 2000 hours).  The warning is nothing more than an annoying tone during startup, shutdown and at regular intervals.  The “Extraordinary Maintenance” warning can be cleared by the owner by following the steps below. This is particularly useful when access to an engineer is not immediately available.  It is important to ensure that a qualified engineer performs regular maintenance on the stove and avoiding maintenance will only reduce the lifespan and efficiency of the stove.

Accessing the Installation menu

The … Continue Reading

Use LINQ to “Zip” collections together

The Zip method pairs together the items in 2 Enumerable collections into 1 single  collection that can be used to enumerate through the paired items .  Each pair of items can then be operated on to produce a final collection. Put simply, the item at index 1 in my “Zipped” collection contains the items at index 1 from the original 2 collections. The Zip stops when one of the source collections runs out of items (since Zip cant make any more pairs of items).

Zip takes the two collections to index through and a function to apply on each index … Continue Reading

CRM Notes can update the Regarding Record ModifiedOn Date

Changes in CRM record data is a common part of business process, and clients often use the “ModifiedOn” field in views as an indication of new information in a recordset. However, adding text in an entity “notes” field does not update the “ModifiedOn” date. A client using this pattern were looking for a simple configuration-only solution using Workflows. The following example describes how to implement the solution for the Opportunity entity.

Continue Reading

CRM 2011 Online integrated with TASGroup Dealmaker

Integrated servicesChannel 9 feature Dynamics CRM 2011 integrated with the Dealmaker sales management tool. This CRM online solution demonstrates many of the data and event integration points available in CRM 2011.

In this video Wendy Reed from The TAS Group showcases Dealmaker in Microsoft Dynamics CRM 2011 Online.  Dealmaker helps sales people to sell smarter and manage better by embedding intelligent deal coaching, social networking, configurable sales process, and proven sales methodology.