Tag Archives: development

PowerShell isn’t just for Developers, IT Pros can rock the awesomeness in Office 365

I had the pleasure to co-present PowerShell and Office 365: ITPro #Awesomesauce with my friend and colleague Mike Dixon at the Boston Office 365 User Group yesterday. It was a great session with a lot of good questions. It was recorded so I’ll share the link to the video once it’s available. Big thanks to Hitachi Consulting for the sponsorship too!

I really enjoyed this talk because it kind of went against my natural thread. I’m a developer at heart, been a developer since graduating high school in 1997. I went from IT role to IT role but stuck with development. I’m an architect now (I feel all grown up), and I help teams design some pretty amazing solutions spanning technologies. However I won’t let go of the code. I support my team by pushing the best code practices, code reviews and writing my fair share of code. I like to learn new code in my spare time. I just love it.

This session was targeted to IT Pros: the non-developer type, “those guys” that used to make us developers’ lives harder with their governance policies and limitations on servers (I’m dating back to 2000’s, no one does that now, right? :| ). Given the huge push to cloud: SaaS, PaaS, IaaS, etc. the IT Pro’s role has increased dramatically in my eyes. In a lot of cases, when we come into a company to help create a solution on Office 365, it’s usually been lumped on top of the IT team, who already have their full time job. Going to the cloud is sold as easy and cost effective, but it does take dedication and training to do it right. Generally, new solutions are spun up in the cloud, but the legacy systems remain intact, full production ready with the same SLA for months after they’ve moved to the cloud. It’s not fair to IT.

This session helps bridge the gap a little between developer and IT Pro by providing some real value to IT. PowerShell doesn’t have to be scary or looked as a developer “thing”. It’s awesome, and can do some amazing things that once was only for development teams. Any IT Pro (admin, grunt, wire jockey) can type in commands and build something beautiful. That’s what it is, just commands. This is why I enjoyed this talk, enabling the IT Pros to do more and hopefully bolster them up to do their jobs in Office 365 more effectively and less tediously.

By the way, here’s the deck!

 

 

Advertisements

Embedding your JavaScript into a SharePoint page

A very typical approach for client side development in SharePoint is to throw the code onto the page where you need it. You can alternatively put into the master page, but generally speaking, most code doesn’t need to run on each and every page. The following describes my preferred, tried and true, method of handling this.

Upload the Assets

Say you have some great JavaScript code provided by a developer or blogger, and you want to now use it on your page. First things first, get the JavaScript into your SharePoint site!

Upload the JS file into a library. I generally use SiteAssets, with a small folder structure for organization, like SiteAssets\js, or if there is more, sometimes like SiteAssets\webparts\mywebpartname.

Once the JS is uploaded, we now need a HTML file to reference it. This can be pretty simple HTML file. You can create it on your desktop (create a new text file, and rename the extension to .html) or using SharePoint Designer, you can create it directly in SharePoint. Throw it in the same place as your JS file, or however you have your assets structured.

As an example, we’ll take a block of code from one of my blog posts, we’re going to throw the necessary HTML and JS into the HTML file you created, something like:


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="/SiteAssets/Lozzi.Fields.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function(){
ExecuteOrDelayUntilScriptLoaded(function(){
Lozzi.Fields.disableWithAllowance("Start Date", ["Project Managers"]);
Lozzi.Fields.disable("Task Status");
Lozzi.Fields.hide("% Complete");
},"sp.js");
});
</script>

This is all the HTML and code needed to run the JS I’m working with. Notice Line 2, the second <script tag. This is the path to the JS file you uploaded into SharePoint. Make sure the path is correct. This block of code above will differ for each and every JS example you work with.

Once the HTML file is saved, navigate to it through your browser and copy the link to the HTML file. You can do this simply by clicking on the file’s ellipses, the …, and copy the URL from there

copy file link

Embed in SharePoint

Ok, now that we have the JS file uploaded, and a HTML file created, let’s embed it in SharePoint! This is the easy part.

Navigate to the page you want to use this code on. Just use your browser and click to go to the page, pretty simple so far right?

Now edit the page: click the cog in the top right and select Edit Page

edit page

Once the page is in edit mode, click Add a Web Part button at the top of a zone, it doesn’t matter too much where. If you don’t have an Add a Web Part button, you’re probably using a wiki page, so click anywhere in the content area where you want add a web part, then click Insert Web Part.

add content editor web part

In the Add web part ribbon, select Media and Content on the left, and then select Content Editor. Click Add to add to your page. You should have something like:

added content editor web part

Notice the Content Editor web part added. Now click the web part, in the top right, and edit the web part.edit web part

In the tool pane on the right, paste in the URL to the HTML file. Click OK.

past html link in content editor

Afterwards, your content editor web part may look empty, or you may see some of your HTML, it depends on what you’re working with. My example, I’m just using JavaScript to hide fields on my page.

save content editor

Save the page and you should be good to go! Your code should fire off and you should see things happening. If not, if you question what’s going on, try using the developer tool bar in your browser, more on how here.

A couple of notes:

  • You may want to modify the Content Editor Web Part’s Chrome Type setting to hide the title from view
  • If you receive the error “Cannot retrieve the URL specified in the Content Link property. For more assistance, contact your site administrator.”, check the URL you’re pasting in. SharePoint can’t find it, make sure it’s valid. Paste it into a new browser window and see if downloads the file.
  • Make sure to structure your JS and HTML files well, you never know who’s going to look at it next.
  • Consider using the URL to the HTML file as a relative URL instead of a absolute URL. How? Consider the following URL is an absolute URL: https://sharepoint/sites/sitename/siteassets/myfile.js. Make it relative by dropping the first part: /sites/sitename/siteassets/myfile.js. This will keep it a wee bit more flexible and migrations in the future should be a little easier.

‘Til next time, Happy SharePointing!

Why you should keep your on premise SharePoint when developing for Office 365

Office 365

If you’re diving into the wonderful world of developing for Office 365, or SharePoint Online, don’t let go of your development environment just yet!

Keeping your on premise instance of SharePoint 2013 for development will make a few things much easier, and will alleviate headaches in the long run.

For starters, make sure to have your environment configured with host named site collection, not separate web apps. This closely mimics how Office 365 is configured, and will help down the road. See this TechNet article for more details.

Errors

You heard it here first, Office 365 will error on you!

If you kept your on premises SharePoint, you can try the same app there, and if it errors, look through the logs. If it does not error, wait out Office 365 (more below).

I ran into this exact issue when developing a provider hosted app. Just couldn’t get past the error on Office 365. I spun up my virtual environment, tried it there, and received the same error. Searched the logs and found that my client ID wasn’t correct. Oops, I fat fingered something. Fixed and reran on Office 365 and success!

This won’t always work, as Office 365 does get updated more frequently than your environment does, and some of those updates may cause issues. Test it on your on-prem and then Open an Issue with Microsoft (more below).

You can also check the error log with your app, if you’re lucky. More on that here.

Waiting for Office 365

Sadly, Office 365 isn’t the best thing since sliced bread. Sometimes, Microsoft and team will randomly perform maintenance, and it appears whenever they want. I was working through the aforementioned provider hosted app, when all of a sudden, everything went read-only:

Site is read only Office 365

Great, now what?! Nothing. I couldn’t do anything, but my deadline kept getting closer!

What is a SharePointer to do? Dive into your on premise environment which you were wise enough to save, and finish development there. This read-only status kept for about 6 hours this day. This can really hurt development progress when this happens.

Another fun thing is when services get degraded.

Office 365 degraded SharePoint Online

This issue came up, and hindered one specific piece of what we were developing, sorry I forget what it is exactly. Sure enough, moving to on-premises saved the day.

One more story: I was working happily in Office 365 all day, with a deadline the next day, things were going smoothly. I left work at 5p, knowing I’d sneak in a little more work that night to polish up the app. I get home, enjoy my family time, and jump online once my kids are in bed. Sure enough, Office 365 is experiencing an issue and wouldn’t let me continue… grrr… Got up early the next morning and things started working again (I was able to meet my deadline).

Open an Issue with Microsoft

I have to hand it to Microsoft, their support team for Office 365 is responsive! Submit a support request through your tenant. If you’re working on someone else’s tenant, it’s okay, submit the request using your details. Gone are the days of having to submit under an account user just to hand the ticket off to someone else.

Once submitted, they call me back within 4 hours most times. Not too shabby. They aren’t the brightest set of support techs, sometimes things get escalated, but they really try hard to fix your issues.

Again, if you have your on-prem environment, you can submit the support request, then continue working on-prem.

Less Important, Until You Lose it

Office 365 is on the cloud, and if you lose your internet, you’re down. This may go for your on premises SharePoint as well if it’s not running locally on your workstation. Nothing hinders work more than not being able to access anything! Keep it mind.

Keep Your On Premises SharePoint

Just do it.

24-Hour Devathon for a Cause

I am very proud to share that our team at Slalom is taking 24 hours out of this beautiful New England weekend for a SharePoint/Office 365 dev-a-thon to benefit local non profit Junior Achievement of Northern New England.

From www.janewengland.org:

The mission of Junior Achievement (JA) is to inspire and prepare young people to succeed in a global economy. Using hands-on experiences, JA helps to prepare young people for the real world by teaching skills in financial literacy, workforce readiness and entrepreneurship. Junior Achievement trains community volunteers to deliver curricula, and to incorporate the sharing of personal and professional experiences with students. The hallmark of Junior Achievement efforts, these mentors inspire students by transforming the JA lessons into relevant messages that connect what is learned in the classroom to real-world situations.

I am a big fan of this organization. Financial literacy and workforce readiness is very important, with the rise of debt from school loans and credit cards, we have to teach the younger generations more and more about how to best manage their money and be ready to get sustainable jobs. JA reaches 38,000 students in annually!

This weekend a small contingency from Slalom Consulting Boston is putting in 24 hours to create a portal for JA’s board of directors, hosted on Office 365. Some of the key requirements include:

  • Calendaring including RSVP.
  • Custom newsfeed on the homepage highlighting important details from the portal (not what is followed).
  • Branding to match the JA brand.
  • Mobile device friendly, with a heavy focus on the iPad.
  • And other portal stuff like document libraries,

We are employing our best SharePoint and User Experience architects and developers to accomplish something great. I am really looking forward to working with my team as a whole. As consultants we are all spanned across multiple projects and clients, it’ll be a blast to work with the team, together, busting out a sweet project.

Why do I share this with you? One, to show off how much I love my job. Slalom loves promoting community efforts among its employees, really helping us do what we’re passionate about. #SlalomProud. Secondly, to tell you a little about JA, and hopefully you’ll check them out. They are a great organization, one definitely worth the look.

Finally, I wanted to give you a heads up as we’ll be sharing some of the code we create and walk throughs on what we built. I’m excited to build something great and being able to share it with the SharePoint community.

‘Til then, Happy SharePointing!

We all know what IsDlg does… wait, what the…??

Here’s a little nugget I came across, on SharePoint 2010 and 2013 (including O365), and was exceptionally frustrated with. There’s a difference between IsDlg and isdlg. See it? Case sensitivity. Come to find out that means the world to SharePoint.

I was tasked to setup a basic Page Viewer web part to consume a page from another web. Simple enough. I threw the URL into the web part, including IsDlg=1, and blamo, I got my page. However, I couldn’t scroll the web part. The page I was using was longer than the web part, which would normally cause the page to scroll, but alas, not in this web part.

Enter the IsDlg parameter. Don’t know what IsDlg is? It’s a little query string parameter that SharePoint uses to hide elements on your page using CSS. Have you noticed that if you enable the dialog on a list, and the forms then appear in the dialog window, that the header is missing? The left nav too?

Dialog Window in Use

It’s the same page as if you didn’t use the dialog setting, Microsoft isn’t crazy enough to have two versions of a page that does the same thing. Instead when the IsDlg parameter is sent to the page as a parameter in the query string, it hides everything on the page with a CSS class of s4-notdlg.

Here’s what the URL may look like:


/sites/lozzi/Lists/Events/DispForm.aspx?ID=4&IsDlg=1

Note the IsDlg=1 at the end. I’m a big fan in questioning everything, so let’s try it out for ourselves.

Go to a display form of a list item, which is not in a dialog.

A Normal Display Form

and add &IsDlg=1 (case sensitive) to the end of the URL, hit enter.

Display Form with IsDlg=1

See how we lost the top header and left nav? Looks like the dialog up above, right? Pretty cool eh? So, as you may be thinking, “this is awesome, I can use this in the page viewer web part too”. You would be correct in your thinking! Here’s where things get a little fishy.

When you use IsDlg (again case sensitive), SharePoint does NOT scroll the window if the window requires it. Again, give it a whirl. Take your window you used above, and resize it so it’s nice and small, put the Close button below the bottom of the window.

IsDlg missing scroll bars

See? The close button is below the window, but there’s no scroll bars. If you change the IsDlg to isdlg, then you get a happier page.

Scroll bars come with isdlg

Whew, there’s our trusty little scroll bar, now I can press Close.

Let’s dig deeper: core.js

Why is this happening? Well I dove into the JavaScript that handles it, in the core.js file, there are several lines of code which look similar to:


isdlg = (ajaxNavigate.get_search()).match(new RegExp("[?&]IsDlg=1"));

JavaScript is very case sensitive, so it’s actually, and quite specifically, looking for IsDlg, not isdlg. Weird right? So if you send the page IsDlg, SharePoint forces the size of the window and disables the scrolling. If you send isdlg, SharePoint does nothing with it except for hiding the CSS elements (as we discussed earlier). Your browser’s native capabilities kick in and scrolling occurs.

This is great for the dialog interface SharePoint is use to as they will size with the page. Now the user is scrolling the entire page and not just the page within the dialog. This is annoying for us if we want to use IsDlg feature elsewhere and we want to scroll just inside the web part. We have to use the isdlg option instead.

Oh yeah, I confirmed this occurs in Internet Explorer, FireFox and Chrome too ;)

‘Til next time, Happy SharePointing!