Latest Entries »

We are in the midst of building a custom portal for SCSM, contact us if you’d like to purchase it from us. Sales pitches aside Trying to get multiple pieces of information and sort it from SCSM isn’t easy. First of all you have to deal with the new Criteria garbage to query SCSM, as if LINQ or CAML wasn’t good enough, let’s create a brand new querying language that only product will use. Seriously Microsoft, get some unity already. I digress….

Getting incidents is pretty simple, however using that object isn’t. Rob Ford does a great job at trying to help understand it (http://scsmnz.net/c-code-snippets-for-service-manager-1/). That said, how do you “order by” or get more information like Status? It isn’t “easy peezie lemon squeezie” but you should be able to make sense of it. This took a few days to put together from a few different sources, so hopefully this will help somebody.

These code sample are in order, so copy each section and paste then your controller should work.

This should look familiar. We get our management packs and our user and build our first Criteria.

 var strSetting = ConfigurationManager.AppSettings["Group"];<br /> EnterpriseManagementGroup mg = new EnterpriseManagementGroup(strSetting);</p><p>//get our user<br /> var strUserName = GetIdentityUsername();<br /> //build criteria to get incidents where user is AffectedUser<br /> var strCriteria = String.Format(@"$Context/Path[Relationship='WorkItem!System.WorkItemAffectedUser' TypeConstraint='System!System.Domain.User']/Property[Type='System!System.Domain.User']/UserName$ Equal" + strUserName + @"");</p><p>//Get the management pack for Incident and projection<br /> ManagementPackClass mpcIncident = mg.EntityTypes.GetClass(new Guid("a604b942-4c7b-2fb2-28dc-61dc6f465c68"));<br /> ManagementPackTypeProjection mptpIncident = mg.EntityTypes.GetTypeProjection(new Guid("1862825e-21bc-3ab2-223e-2a7f2439ba75"));<br /> ManagementPack mpIncidentLibrary = mg.ManagementPacks.GetManagementPack(new Guid("DD26C521-7C2D-58C0-0980-DAC2DACB0900"));<br /> ObjectProjectionCriteria opcIncidents = new ObjectProjectionCriteria(strCriteria, mptpIncident, mpIncidentLibrary, mg);

The tricky part is order by. Well there is another new method call ObjectQueryOptions. It is some loose form of XML where you add some references to the management packs that you want to user to get data and how to setup the QueryOptions. the IObjectProjectionReader is the same but you add the new Query Options Object.

var strQuery = String.Format(@"&lt;Sorting xmlns=""http://Microsoft.EnterpriseManagement.Core.Sorting""&gt;<br /> &lt;Reference Id=""System.WorkItem.Incident.Library"" Version=""7.5.3079.0"" Alias=""WorkItem"" PublicKeyToken=""31bf3856ad364e35""/&gt;</p><p>&lt;Reference Id=""Microsoft.Windows.Library"" Version=""7.5.3079.0"" Alias=""WinLib"" PublicKeyToken=""31bf3856ad364e35""/&gt;<br /> &lt;SortProperty SortOrder=""Ascending""&gt;$Context/Property[Type='WorkItem!System.WorkItem.Incident']/Priority$&lt;/SortProperty&gt;<br /> &lt;SortProperty SortOrder=""Descending""&gt;$Context/Property[Type='WorkItem!System.WorkItem.Incident']/Id$&lt;/SortProperty&gt;<br /> &lt;/Sorting&gt;");<br /> ObjectQueryOptions orderedIncidents = new ObjectQueryOptions();<br /> orderedIncidents.AddSortProperty(strQuery, mptpIncident, mg);</p><p>IObjectProjectionReader&lt;EnterpriseManagementObject&gt; oprIncidents = mg.EntityObjects.GetObjectProjectionReader&lt;EnterpriseManagementObject&gt;(opcIncidents, orderedIncidents);

So now you have your data, but it’s all an object and you want to show the priority to the user. Well half of the fields in SCSM are relationships. So you have to setup a new Criteria and get a single workitem, for which you will need a foreach loop to get the status for each. Notice we are using a datatable which we will pass through to the View.

//create datatable to pass to view<br /> DataTable dt = new DataTable();<br /> DataRow dr = null;</p><p>dt.Columns.Add(new DataColumn("Incident", typeof(string)));<br /> dt.Columns.Add(new DataColumn("Status", typeof(string)));<br /> dt.Columns.Add(new DataColumn("Last Modified", typeof(string)));</p><p>foreach (EnterpriseManagementObjectProjection emopIncident in oprIncidents)<br /> {<br /> dr = dt.NewRow();<br /> dr["Incident"] = emopIncident.Object.DisplayName;</p><p>//This is the work item (such as a service request) ID that we're looking for<br /> String workItemId = emopIncident.Object.Name;</p><p>//Setup the criteria. This will instruct service manager to "Get me the incident request with Id: IR{0}"<br /> //Get the system.workitem class<br /> ManagementPackClass mpcWorkitem = mg.EntityTypes.GetClass(new Guid("f59821e2-0364-ed2c-19e3-752efbb1ece9"));</p><p>//Get system.workitem.library mp<br /> ManagementPack mpWorkitem = mg.ManagementPacks.GetManagementPack(new Guid("405d5590-b45f-1c97-024f-24338290453e"));</p><p>string strIncidentSearchCriteria = "";</p><p>//Attempt to get results for single workitem<br /> strIncidentSearchCriteria = String.Format(@"&lt;Criteria xmlns=""http://Microsoft.EnterpriseManagement.Core.Criteria/""&gt;" +<br /> "&lt;Expression&gt;" +<br /> "&lt;SimpleExpression&gt;" +<br /> "&lt;ValueExpressionLeft&gt;" +<br /> "&lt;Property&gt;$Context/Property[Type='System.WorkItem']/Id$&lt;/Property&gt;" +<br /> "&lt;/ValueExpressionLeft&gt;" +<br /> "&lt;Operator&gt;Equal&lt;/Operator&gt;" +<br /> "&lt;ValueExpressionRight&gt;" +<br /> "&lt;Value&gt;" + workItemId + "&lt;/Value&gt;" +<br /> "&lt;/ValueExpressionRight&gt;" +<br /> "&lt;/SimpleExpression&gt;" +<br /> "&lt;/Expression&gt;" +<br /> "&lt;/Criteria&gt;");</p><p>EnterpriseManagementObjectCriteria emocWorkitem = new EnterpriseManagementObjectCriteria((string)strIncidentSearchCriteria, mpcWorkitem, mpWorkitem, mg);<br /> IObjectReader&lt;EnterpriseManagementObject&gt; readerWorkitem = mg.EntityObjects.GetObjectReader&lt;EnterpriseManagementObject&gt;(emocWorkitem, ObjectQueryOptions.Default);<br /> EnterpriseManagementObject emoWorkItem = readerWorkitem.ElementAt(0);

Great I have my single workitem, now I need to get the status. Remember everything is a relationship. So you will have loop through the Status List until it matches and then output that. However if a status is empty it will throw an exception, so try catch to suppress errors. Then finish up the rest and add the row to the table.

String workItemStatus = "";</p><p>//you need a try catch for when the status is empty.<br /> try<br /> {<br /> //Get Status DisplayName for title<br /> Guid gStatusCategory = new Guid("5e2d3932-ca6d-1515-7310-6f58584df73e");</p><p>foreach (ManagementPackEnumeration mpeClass in mg.EntityTypes.GetChildEnumerations(gStatusCategory, TraversalDepth.Recursive))<br /> {<br /> if (mpeClass.Id.ToString() == emoWorkItem[mpcIncident, "Status"].Value.ToString()) ;<br /> {<br /> workItemStatus = mpeClass.DisplayName;<br /> break;<br /> }<br /> }<br /> }<br /> catch (Exception ex)<br /> {<br /> //workItemStatus = ex.Message + " | " + ex.Source;<br /> }</p><p>dr["Status"] = workItemStatus;<br /> dr["Last Modified"] = emopIncident.Object.LastModified.ToLocalTime();<br /> dt.Rows.Add(dr);<br /> }</p><p>return View(dt);

 

 

I might be late to the game, but I didn’t see this covered anywhere. When you are adding custom user controls in SharePoint make sure that it is wrapped in a div that has the class of “ms-core-overlay”, which ensures that the this control will have the branding, or CSS styling, correctly applied to the user control, otherwise it doesn’t have it and it look weird. For instance the background fade or darkening CSS would not be applied.

In my case I needed to add a root header menu for all masterpages that pulls from a list at the Root Web.


<!-- Root Header Menu -->
<div class="ms-core-overlay"> <!-- this ensures the branding options are correctly applied to the root header menu area, but under it -->
<div id="header" class="nav">
<!--SPM:<uc1:RootHeader runat="server" id="RootHeader"/>-->
</div>
</div>
<!-- End Root Header Menu -->

My wife came up with this, so all the credit goes to her. This was absolutely awesome and in my opinion a confidence boost rather than a “what’s wrong with me” moment. Our son has ADD, maybe even ADHD. He got it from me, I have ADHD. But instead of being told your too hyper and crazy and the negative remarks of 25 years ago this is what my wife told our six year old.

Son, you have a special kind of energy, a super power. And we must teach you how to use it. So me, daddy, aumma (aka grandma), your teacher and your doctor are going to help teach you how to control your super power.

We will be trying everything possible before medication, so behavior awareness and modification, as well as diet and sleep patterns. But even after two days and being “full of energy” at church he told me, “yes daddy, I know, I was a little crazy, but I have a special kind of energy and I don’t know how to control it yet.” He doesn’t feel bad about being different, he just has something that others don’t, and like Superman, or Ninjago, he must learn how to harness the power and use it for good.

Yes you read my title correctly, gift giving is fundamentally broken. There will be some exceptions, but for the most part the only time a person receives a gift is when they expect to receive a gift, i.e. birthday, Christmas, or hallmark holiday. I’m not saying that we need to get rid of gifts. I’m saying that we need to get rid of expected gifts. No one should for any reason expect a gift. Where’s the fun and joy in it, except maybe if you are five. Let’s consider the last time you bought Susie something because you had to, and you got her the dog thingy, and she opened it. What was her face? “Oh Yes!” or “Oh…. thanks, I think…?” And you felt how, when you saw that is wasn’t something she’d really like? So far gift giving seems to suck really badly. You have the same or better odds playing red\black on the roulette table, and at least that has a favorable return if you win.

Sure it’s fun to buy people gifts, except that it’s not when they are expecting a gift from you. When you know they are expecting something, there is this pressure that creates stress, “Oh I have to find a great gift they’ll really like and I only have 24 hours”, since let’s face it we hate buying people expected gifts so we put it off until the last possible second. Then we stressfully and quickly go through the isle looking for something that is just good enough, “Oh Susie likes dogs and this dog thingy is cute so I’ll get that.” What is the batting percentage on this, maybe 50%. So we are stuck buying something with a 50% likelihood they’ll like it because we have to, even though we don’t really want to. I know not in all cases, but think about buying a gift for your one of your in-laws or co-worker cause you got shamed into a secret santa ordeal, now I’ve just lowered the odds. This is even worse for kids who get unhappy because they didn’t get the gift they wanted most, or maybe it’s fair to say that everyone gets like this. Of course those with kids understand the tantrums and\or tears that will be had to be dealt with.

For adults, even teens, receiving a gift can be difficult as well. Think about the last time Grandma gave you a gift. Was it that sweater you have been dreaming of? Well it was a sweater, or dress shirt, but I’m going to guess you didn’t really want it. But then you have to show the fake smile of happiness, “Oh, thanks Grandma for the shirt.” Or maybe you get money from her, in a card that they put a lot of thought into to pick out just for you, “Oh, thanks Grandma for the card.”

Then there is the whole Christmas debacle of shopping through crowds and trying to find deals because you have to save money to buy everyone a gift and not everyone has money like Bill Gates. Holiday gift giving adds stress and undue financial burden into the mix. So we end up stressing about buying gifts with money we barely have or don’t have, then give someone something that with all honesty, probably gets put in the garage or attic. Maybe it’s clothing they’ll wear, or not and they donate it to Goodwill. Or they return it and get something they “want” or need. So we get pushed around in the store and buy something only to have a less than 50% chance they’ll like it and\or use it. So during Christmas everyone expects to receive gifts from family, and I would venture to guess that over 50% of the time they didn’t really want or need at least 50% of the gifts they received. So we are buying people stuff they don’t want and don’t really like because it’s a day where we are supposed to buy a gift.

My brother and sister-in-law for Christmas take blankets, sweaters and socks to homeless people. The day that most homeless people feel absolutely forgotten about, they actually receive a gift they want and need. And 95% of them are beyond grateful and joyful for the two gifts they just received. Yes two. One was the sweater, but more importantly, two was the fact that someone brought them something on a day they didn’t expect to get anything, and that is the most important part about giving and receiving gifts.

Here’s the joy of gift giving! Remember back to that one time when you bought someone something out of the blue, no special day, just you saw something that Susie would love and bought it for her and gave it to her for no reason, other than you care for Susie and really wanted her to have this thing. I’ll will to guess that Susie loved it and was completely shocked, and that little thing means more to her than the dog thingy you got her for her birthday. The joy in gift giving, and receiving, comes from the completely unexpected.

Maybe Christmas and birthday’s need to go the way of Thanksgiving, more about spending time with one another, having fun and eating. Rather than some stress filled, jacked up day that we are all glad when it is over and done. I know not everyone has a bad time, but if you read any of the holiday health articles, they’re all about managing stress and depression during the holidays. It is bad enough we stress about spending time with family, but to add in additional stress of gifts, expectations and finances is unneeded. So maybe we should start to consider a change to gift giving. Let’s move away from expected gifts and toward unexpected gifts. Plus if you need a holiday, be it hallmark or not, to remind you to give someone something as a gesture that you care about them, then you are doing it wrong. You shouldn’t need a “day” to tell someone you love them with flowers, a toy, jewelry, or anything else. If you care for someone, gift giving should come naturally, not be forced.

I discovered this while giving my $0.02 to Fabian Williams. This applies to the HTC 8x, not sure of any other Windows Phone 8 Phones (seems redundant to say that twice).

Reported Bug:
There is a bug where when using Bluetooth through my car then disconnect the headphone volume for music becomes fixed. I can adjust the volume for alerts and games; however music volume becomes fixed at whatever it was set at in the car.

Remedy:
1) Reboot your phone. 2) Ask Microsoft for patch.

Here is the latest site template I am working on. It uses the Site Theme to modify the CSS and the Site Logo so site admins can “Brand” it themselves without having to involve IT. The two images you see are libraries that the site admins can upload to which automatically insert into the respective area when the display date is hit and comes off with the Expires date passes. The Navigiation menu uses a list and will track which page you are on and change the active color as appropriate.

SharePoint doesnt have to be boring

The SharePoint search center is too corporate and boring. It makes me sad just looking at it. So I wanted to spruce it up and make it inviting and engaging to users. Well the daily Bing image is great so why not use that? Well okay let’s do it. So first is how do you get the image. Well Microsoft is nice enough to provide a XML page for the image http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US

Let’s understand it first. The variable “n” is how many days you want back, you can go back up to seven days. I only care about today’s so I use 1. The variable “mkt” is which geo-region you want, en-US is United States. There are regions for England, France, Japan and many others. I also wanted to be sure that the copyright information was included. So you will see the little (i) at the bottom. You’ll have to find your own and add it to your site.

So now we modify the search center and all of the modifications are in the default.aspx page, assuming you are using the minimal.master on your search center. You don’t need to modify the minimal.master so don’t touch it.

First let’s put the CSS and jQuery in. I’m modifing these pages in SharePoint designer. Navigate to line 21 which should be <asp:Content ContentPlaceHolderId=”PlaceHolderTitleAreaClass” runat=”server”>. In the style tag add the following styles.

#bingImage{height: 768px; width:  1366px; background-repeat:no-repeat; background-position:center; border: 1px #ccc solid; text-align:center; position:relative; min-height: 500px; min-width:  1000px; max-height: 768px; max-width:  1366px; margin:auto; top: -24px;}
#bottomControls{position:absolute; bottom: 0px; width:100%;}
#btmHolder{height: 55px; margin-bottom:4px;}
#btmPositioner{top: 20px; right:15px; position:absolute;}
#s4-mini-header{width:1366px; margin: 0 auto 0 auto; position:relative; z-index:50; top: 20px;}
.ms-sblink a:link, .ms-sblink a:visited{color:#fff;}
#s4-mini-titlearea h1{font-size:16px; position:relative; left: 35px; top: -28px; width: 100px;}
#s4-mini-titlearea .s4-mini-titlesep{display:none !important;}
#s4-mini-titlearea h2{display:none;}

Then under that add some javascript. Important note here, I am using John Chapman’s SharePoint proxy page solution to prevent the cross domain browser warning. http://sharepointproxypage.codeplex.com/. CORRECTION: Bing only proves a few different sizes and 1366×768 is one of them. It’s the size I like for my organization.

<script type="text/javascript">
    //BING URL for XML of current image
    //http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US
    $(document).ready(function(){
	var encodedURL = encodeURIComponent("http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US");
			$.ajax({
				type: "GET",
				url: "/_layouts/SharePointProxyPage/Proxy.aspx?u="+encodedURL,
				dataType: "xml",
				success: function(xml) {
					$(xml).find('image').each(function(){
			                   // current document tag
			                   var Document = $(this);
			                   var img = Document.find('urlBase').text();
			                   var copyright = Document.find('copyright').text();	
			            	//send it to the Div
			            	$("#bingImage").css("background-image","url('http://www.bing.com"+img+"_1366x768.jpg')");
			            	$("#bingCopyright").attr("title",copyright);
			        });
				},
                error: function(XMLHttpRequest, textStatus, errorThrown){alert("get image failure: " + textStatus +" | " + errorThrown);}
			});
	});
	</script>

Now go to <SharePoint:UIVersionedContent UIVersion=”4″ runat=”server”>, which should be line 200 or there abouts. Between <ContentTemplate> and <div class=”srch-sb-results7″> add <div id=”bingImage” align=”center”>. Then go to </SharePoint:UIVersionedContent> and directly under it paste the following:

</div>
	<div id="bottomControls">
		<div id="btmHolder">
			<div id="btmPositioner">
				<img id="bingCopyright" src="/Style Library/Intranet/images/intranet/header_info.png" alt="" title="">
			</div>
		</div>
	</div>

It should look something like this:

I wanted to add a small weather icon on our intranet that wasn’t branded with Weather.com or accuweather or any other weather site. Luckly NOAA, whose site is weather.gov, has a free XML source so I could use that to read the weather. Using jQuery I parsed their complicated file for the current conditions temperature and icon. Then I update my div and img src and it’s done. There doesn’t seem to be to many people using it as I couldn’t find any help parsing the NOAA file. So there was a lot of trial and error.

Update the url property and then call getWeather() and it will do the rest. Here’s the code. Enjoy!

function getWeather(){
    	$(document).ready(function(){
    		jQuery.support.cors = true; //enables cross domain support
			$.ajax({
				type: "GET",
				url: "http://forecast.weather.gov/MapClick.php?lat=32.82564&lon=-117.1558867&unit=0&lg=english&FcstType=dwml",
				dataType: "xml",
				success: function(xml) {
				  $(xml).find('data').each(function(){
			            // current document tag
			            var Document = $(this);
			            var temp;
			            
			            // make sure you have the correct data type.
			            var n1 = Document.attr('type');			            	
			            if(n1=='current observations'){
			            	//the correct icon-link
			            	var iconLink = Document.find('icon-link').text();

			            	var n2 = Document.find("temperature").attr("type");
			            	//finds the correct one and only retreives the first value.
			            	if(n2=='apparent'){temp = $(this).find('value').first().text();};
			            		
			            	//set it in the DOM
			            	$("#weather-icon").attr("src",iconLink );
			            	$("#weather").prepend("<span class='temp'>"+temp+"°</span>");
			            }
			        });
				}
			});
			//refresh weather every 30 minutes if page is refreshed by browse action.
			setInterval(function(){getWeather();},1800000);
		});
    }

I ran into this today. You are too probably because you have a Style Library Module that has somes folders. You deleted the file and the reference in Elements.xml but you can’t cause it’s still reference in the SharePointProjectItem.spdata file in the Style Library foler. You’ll have to navigate to the folder through explorer and delete the references.

Recently I had a page that had “Pages – ” in the Title. Couldn’t figure out where it was coming from until I follow the clue left for me in the masterpage by Randy Drisgill.

The Title is over written by the page layout page. You can get rid of the “Pages – ” in the title by editing the page layout of the page. In the offending page layout look for:

Then:

Set the ListProperty to Visible=”false” and delete the ” – ” before FieldValue on the next line.

Conversly you could add this code to a different page layout to ensure you have similiar page title across your entire site.

My offending page layout was BlankWebPartPage.

This is under Publishing Sites. I’m not sure if it is the same for Team Sites.

Hope this helps someone.

Follow

Get every new post delivered to your Inbox.