Posts

Showing posts from 2013

Ajax Control Toolkit with SharePoint 2013 - How to make this work

Image
Hi all, Trying to use AjaxControlToolkit with SharePoint 2013, I managed to make this work using the following steps: 1. Download latest (.NET 4.5) version from  http://ajaxcontroltoolkit.codeplex.com/releases/view/112805 2. Add Reference in your VS solution (both AjaxControlToolkit and AjaxMin dlls) 3. In Package designer, create safe control entries for both: 4. SP Web.config needs to have the AjaxControlToolkit assembly in compilation/assemblies node. I use SPWebConfigModification in feature receiver (web application scope) to do this. 5. Replace the default ScriptManager in your masterpage with the ToolkitScriptManager 6. Important: Move this section from the head tag to the body tag in your master page after the ToolkitScriptManager to avoid databind issue That's all I had to do. I used the Ajax Combobox and bind my datasource in code behind and it is working fine. HTH, Andreas

CRM 2011 - Add many to many relationship + checking if relationship exists between entities (N:N)

Hi all, Using service context AddLink, you can create N:N relationship in CRM. However you still need to check if the relationship has already been created between the two entities, otherwise you would get 'Insert duplicate key' error. Thanks to this blog  I don't have to create helper functions to check the existing relationship. Rather than using AddLink method that is tied to a service context, I just use the normal Associate method of the IOrganisationService: HTH, Andreas

SharePoint GlobalNavSiteMapProvider get visible items - hidden page issue

Hi all, If you happen to grab structured navigation items from GlobalNavSiteMapProvider in the code when it has 'show all pages' enabled, you would find that it will return all pages including the ones that are hidden. I debugged the code and interestingly the IsVisible property of the PortalSiteMapNode always returns true.  One workaround is to not show pages in the global navigation, and manually add/remove links in the navigation. The other workaround (easier) is to check if the page description has 'hidden' in it, if so then you exclude it: HTH, Andreas

SharePoint 2013 Add an app Loading forever - Master page issue

Hi all, If you build your custom master page and use it in System pages, you might find that you will get the Loading message forever when you do Site Contents - Add an App. Reading Randy's blog  some tags are required. In the end I just copy pasted the required tags from his Starter master page   to include them in my master page: Make sure you put it inside the SharePointForm tag. HTH, Andreas

Google Geocode JavaScript Address Validation

Image
I got a chance to play around with address validation using Google geocode API v3. In my case I use the client side geocoding technique to submit full address (street address + suburb + state + postcode) to find out whether the results returned. The suburb, state and postcode is coming from a proper list. What I found out with Google geocode is that when you submit full address, it also returns result with partial_match and they don't give an easy filter to exclude these results. Since I will always submit a full string address, I will just get the address when there is no partial_match property in the returned results. So far it works quite well for my situation. HTH, Andreas

SharePoint 2013 list form headings using JSLink and jQuery

Image
In SharePoint, when you want to modify the list forms, there are couple of ways that you can go about it such as modifying the form or creating custom form using SP Designer or Infopath, or creating custom aspx using Visual Studio. All those approaches can take a while to implement. With SP2013 with the JSLink functionality, we can quickly inject the headings using jQuery if you just need simple headings or HTML like this: In this case, I have a solution created in my VS2012 to create the site columns, content type and then the list itself for easy deployment. I then created a JavaScript file to be deployed to my Style Library (or you can choose other location) that contains the jQuery code: In the schema.xml of my list, inside the Forms tag you just have to add your JSLink attributes pointing to your jQuery file and the JSLink file: And there you go :) HTH, Andreas

CRM 2011 SharePoint 2013 integration ADFS setup for Single Sign On (SSO)

Hi All, After several hours trying to make this work with the help from technet articles, forums and the help from my colleagues, I managed to get this working. My configuration: 1. CRM 2011 has been configured as IFD using ADFS  (see here ) 2. My original site is in Default zone (can be either http/https) with Windows Auth 3. I configured ADFS + map LDAP attributes 4. Web application is extended to other zone (in my case Intranet) to be the ADFS site The reason we can't have 1 site for both Default and ADFS is because the CRM List component does not like the Sign In page when hitting 'Documents' section inside CRM. The reason we want Windows Auth as well is to be able to crawl the site as well as for admin purposes. -------------------------------------------------------------------------------------------------------------------- SETTING UP ADFS: Go to your ADFS Server, open your ADFS management: 1. Add relying Party Trusts with this configuration • En

SharePoint Event Receiver ItemAdded assign permission

Hi, Sometimes we want to remove permissions and only assign permission to the user who uploaded the document in the document library. Here is the snippet: HTH, Andreas

SharePoint Copy permission, create group and assign permission to document library or list programmatically

This is an example to do stuff as written in the post title :) HTH, Andreas

SharePoint Add Datasheet View Programmatically

Hi, Just a quick function to add Datasheet View when you're creating a document library or list programmatically: HTH, Andreas

SharePoint Client Object Model Upload Metadata and Check In File

When you enable versioning on a document library and want to use client object model upload method (in my case SaveBinaryDirect), you will find that your new uploaded file is not available in the view straightaway. It resides in List Settings --> Manage files which have no checked in version (under Permissions and Management section) and you have to take ownership manually. If you want to check in the file automatically (along with filling out metadata) you would need to do extra steps: NOTE: I found that with .docx extension, even though the SaveBinaryDirect increments the minor version (debugging), when calling OverwriteCheckIn it does not increment the file minor version. Not sure if this is a bug :) You must also fill out all required fields before being able to check the file in. HTH, Andreas

Sharepoint Client Object Model (CSOM) Get Choice Field Values

HTH, Andreas

Sharepoint Client Object Model (CSOM) Get Files from Document Library Folder

Hi all, Just want to share a function that shows how to get the files from a specific folder using CSOM: HTH, Andreas

Sharepoint 2013 CRM2011 Document Upload and Document Location Helper (CSOM and OM)

Hi all, Playing around with SharePoint CRM 2011 integration, I managed to construct a helper function that would be useful for future projects. This is when you want to upload document to SharePoint as well as creating document location in CRM 2011. There are several ways of uploading documents to SharePoint. 1. Object Model 2. Client Object Model 3. Rest API In this post, I will show you the first two. If your code is sitting in SP server, you can use the traditional object model. Here you go: You might want to impersonate credentials when uploading to a different SP site. With Firefox, when I try to upload to secured SP site (https) I got prompted login box which is annoying (as opposed to single sign on with IE/Chrome). So as a workaround we can use the Client Object Model way to upload to SharePoint in order to specify the credentials: Here I also ensure that the folder exists before we upload document (otherwise create them!). Lastly, the CRM 2011 documen

CRM 2011 Linq Retrieve Many to Many N:N Records

Hiya, As you all know, you can use Query Expressions or FetchXML to retrieve N:N records. Good news, we can also use LINQ if you wish to. Let's say we have a portal account (for website login) that has N:N to organisation and we want to grab all portal accounts for a given organisation (in my case I have early bound entities): Easy? :) HTH, Andreas

CRM 2011 Early Bound Entities Serialization / Deserialization

Hi all, Just want to tell my experience regarding this topic - maybe it will save your time. Crmsvcutil gives you generated entities file which can be a time saver. This is all good until you want to use those entities on client side (in my case I want to bring them to my knockout JS functionality combined with AJAX and web services to provide better user experience) Serialization = works fine (when I retrieve the records). The trick is to use JSON .NET  , and with the help of Partial class you can extend the generated entity class from crmsvcutil. To get all properties serialized you need to use the [JsonObject(MemberSerialization.OptOut)] attribute on that partial class as well. Deserialization  = The problem appears when you try to deserialize (when I try to save the records). The AttributeCollection class becomes the culprit in this, complaining that it Cannot create and populate list type of AttributeCollection . Looking at the JSON Stringify ajax data that get passed

Sharepoint 2013 SSL Certificate for Development - Self Signed

We are looking to implement CRM 2011 - SharePoint 2013 integration to leverage document management functionality in SharePoint. The recommended way is to enable SSL on both sites so I want to enable SSL on my development box SP site. There are useful and working steps on how to enable SSL on SharePoint 2013: http://blogs.msdn.com/b/fabdulwahab/archive/2013/01/21/configure-ssl-for-sharepoint-2013.aspx http://griffindocs.wordpress.com/2013/03/20/sharepoint-2013-how-to-add-ssl-to-a-web-application/ However after installing certificates (also on my testing machine) I got the SSL Certificate Name Mismatch Error .  This turns out that when you create Self Signed SSL Certificate, it defaults to your machine name and you don't have the option to change the host header. The solution is to use the SelfSSL program that will allow you to create certificate that points to your site host header as mentioned in this post: http://www.robbagby.com/iis/self-signed-certificates

jQuery chart or graph printing cross browser

Image
Hi all, sometimes we want to produce a fancy graph or charts on our client side code. There are numerous libraries out there to assist with this requirement.  Having used jQuery, when searching for a plugin you will first notice the free jqPlot . In fact this is what has been used in the website I work with. The graph looks fine when generated. When the users asked for a printing functionality - this is where all the fun begins, the graphs screw up (either not showing or position has shifted) in certain browsers. There are three factors to look at when you encounter this issue: 1. Your print.css file 2. Whether you show your graph in a modal window (such as jQuery UI dialog) 3. Cross-browser issue Normally what we want is to just use window.print instead of specific print functionality provided by the 3rd party library if they exist. This is because we want to print other content as well and not just the chart. After searching for alternative library, I came ac

Sharepoint 2013 - Export Import Term Set Navigation

Hi All, Update on TermSet import/export script, thumbs up to my colleague Mark Spurling in creating the PS script. This script handles all nodes along with the TargetUrl. HTH, Andreas

SharePoint 2013 - Read web part properties with client side JavaScript.

Hello, Sometimes we want to be able to read web part properties on our client side code, e.g. when we want to use jQuery functionality to implement certain requirements. Easiest way to achieve this is just use the asp:HiddenField control to store the value of the property, then get the value using jQuery. So on your html: Then on the JavaScript section: On your ascx code behind file, just store the value during page load: Hope this helps, Andreas

SharePoint 2013 The name 'InitializeControl' does not exist in the current context

The storyline: I created a visual web part inside my VS2012 solution. Every time I saved the ascx file I had to wait for a few seconds as my VS was 'Communicating with SharePoint'. If you are the type of person who has an addiction of hitting 'Ctrl + S' after modifying a few lines of code then you will find this annoying. Then I tried to switch my solution to 'Offline' to avoid this. I wrote my code and when I did a build it throws me this error. After further investigation it seems that my ascx.g.cs file disappeared. Now I know why it was 'Communicating with SharePoint' every time I saved the file. It's generating the g.cs file that has the InitializeControl function.  So to get it back working, I just switched to online mode, then re-saved my ascx file and voila! my g.cs shows up again.  Interested to see if other people have any ideas to make this faster process. HTH, Andreas

SharePoint 2013 Rest API and Knockout JS

Image
Hi all, Most of the times in public facing websites you want to have a nice fast interaction for users to be able to get the information and we want to display it in a nice looking way. For example a simple question with responses like this: where user can click Yes or No and the response will show and they can go to the next question.  To achieve this we can easily leverage SharePoint capabilities for storing the questions in the list and access them through the REST API. For rendering and interaction we will use the mighty Knockout JS making it all nice and easy. First step is to create your SharePoint list to store your questions: Then you can create a web part to host this little wizard. In your visual web part ascx file, the first thing we want to do is to create a viewmodel and get the data from our list. Using the REST api and with the help of knockout mapping (or wrap) we can get our observables easily. Below is the complete js on my page Then in

CRM 4.0 Useful FetchXML Javascript Helper

Hi again, Although most of you would say CRM 4.0 is outdated, but unfortunately some companies are still using them :) (I know we are in the process of migrating). However just want to let you know I found a post here  that provides useful javascript function to retrieve record through fetchXml. It is useful for let's say based on the lookup id you want to get all the attributes and populate other fields in the form. I have extended that function so you will be able to get attribute lookup name as well (if you want to populate a lookup field). To use it you can do something like this: Hope this helps, Andreas

Mixing User Controls with Knockout JS - How to make it work

Hi all, Just want to let you know quite an awesome way of building your web form or application using by mixing server side and client side technologies. The trick of using knockout js wrapped in separate user controls is very simple: use native binding ! Then you will be able to use normal controls like this: You can grab all the benefits of fast asynchronous client side script. All server side logic can be implemented using web services. Just keep in mind that it is always better to do validation on both ends (i.e. form validation and saved object validation) Other tip: Sometimes when object is too large IE will complain about slow running script. This occurs especially when you are using mapping plugin. Good workaround is to separate your bindings into chunks or just map your properties manually but sometimes using the setTimeout trick works. Hope this helps, Andreas
Image
It's been a while since I posted the last item. Just to cheer you up this is the newest song I created On the development side, I have been busy developing application form using ASP.NET controls, Knockout and jQuery. It has been fun leveraging both client and server side technologies so feel free to ask any questions in relation to those areas. Regards, Andreas