Showing posts with label SharePoint Designer. Show all posts
Showing posts with label SharePoint Designer. Show all posts

Nov 3, 2017

We can't do that for you because the file is no longer checked out or has been deleted

This error is an interesting scenario but so weird one which I faced recently while migrating SharePoint 2010 designer workflows to SharePoint Online.
Post migration, when I try to edit the workflow in designer I got the below error:

It clearly shows some configuration files are missing.
Hence I have navigated to All Files (from SharePoint Designer 2013) -> Workflows folder -> Workflow -> noticed only one file is migrated but other configuration XOML, XSD or XML files are missing.Now, logged in to the designer with the account which I migrated and found all these required files are Checked Out. When I try to check in the file then I get this error:
It is so confusing that you are not able to Check In the file even when you are SCA or have full control over the site or even if you have created the workflow.
After hours of confusion, finally found the file has having wrong file name or characters which SharePoint Online(Office 365) does not support. But this name format is supported in SharePoint 2010 version. Screenshot for reference.
Issue Fix:

Navigate to Workflows folder -> select the workflow name -> Right Click on the file -> Properties -> Remove the forward slash '/' -> Save -> Check in the file :)
Now, you should be able to edit the workflow in designer, save / publish it with no issues.
Thought this is worth sharing so that it saves someone's time!

Dec 13, 2016

Character Limit using JQuery in SharePoint

In this post, we will learn how to implement Character Count (here in this example, maximum allowed 2000 characters) using JQuery in SharePoint.

Prerequisite:
1. Create a SharePoint List with a column named "Comments" - data type Multi line text with plain text as the option selected
2. SharePoint Designer 2013 for editing the SharePoint list with span and to identify the ID of the field created

Solution:
1. Open the SP site in SharePoint designer, navigate to the list -> Create a custom new form -> Edit it.
To know how to create a custom new form in SharePoint Designer, read this article.
2. Below is the HTML code for my "Comments field in SharePoint Designer:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<tr>
    <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
   <nobr>Enter your comment:</nobr>
  </H3>
    </td>
    <td valign="top" class="ms-formbody" style="background-color:#ffffff; width:400px;">
        <SharePoint:FormField runat="server" id="ff6{$Pos}" ControlMode="New" FieldName="Comments" __designer:bind="{ddwrt:DataBind('i',concat('ff6',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Comments')}" />
        <SharePoint:FieldDescription runat="server" id="ff6description{$Pos}" FieldName="Comments" ControlMode="New" />
        <span title="2000" id="commentsCount">2000</span><span> Characters Left</span>
    </td>
</tr>
Make a note that I have added a Span tag below the SharePoint control to display the Characters. Also, we have declared it as 2000 characters for this example.
Now, add a script tag or a separate file (then refer it inline) -> add the below code in it save it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
$(document).ready(function() {
 //Character count for comments text
 $("textarea[name*='ff6']").keyup(function () {
  characterCount('ff6', '#commentsCount');
 });
});

//Character count for multiline text 
function characterCount(controlID,spanId)
{
  var controlVal = $("textarea[name*='" + controlID + "']");
  var cmax = $(spanId).attr("title");
  if(controlVal.val().length >= cmax) {
      controlVal.val(controlVal.val().substr(0, cmax));
   }
  $(spanId).text(cmax - controlVal.val().length);            
}
In this above JS, "ff6" is the ID of the SharePoint control.
Save the form and JS, try typing inside the control you can see the characters been automatically counted and decreases as you type. Cool Isn't it? 😉
Please share this post by clicking the below social buttons if this helps you😎
Happy coding! 

Oct 17, 2016

Accessing Radio Buttons using JQuery in SharePoint Online

I couldn't find anything obvious for accessing SharePoint Radio Buttons so chucked this together, hopefully useful for someone else :)
Note: The below code/solution is applicable to accessing radio button in a custom SharePoint List forms. To know how to create a custom form in SharePoint Online, read this article 
Accessing Radio Button control in SharePoint is little tricky than accessing the radio buttons in HTML. The reason being, radio buttons are rendered as a table instead of a single control as shown below (radio button and it's preview in developer tools - Chrome):

So, each radio button is rendered inside SPAN tag in a table. To access the normal SharePoint controls, we will use either ID or title property but for Radio Buttons it is little complicated.
1. The actual radio button control is in "input" tag 
2. The values (Example here: Yes, No) are inside "label" tag 
3. But each control (Yes & No) are represented by ID which is generated by SharePoint 
4. If you keenly look at the ID, there is "ff41" which is the ID of the control generated randomly by SharePoint.

Now, open the designer, add an ID to the TD of the Radio button so that we can query it easily using JSOM as shown below:

1
2
3
4
//Radio button change event
$("td[id='tdApproved'] input:radio[name*='ff4']").change(function(){
     // do something
});

1
2
3
//Clear the values of radio button - reset the values of radio button
$("td[id='tdApproved'] input[name*='ff4']")[0].checked = false;
$("td[id='tdApproved'] input[name*='ff4']")[1].checked = false;

1
2
3
4
//Checking the value of radio button
if($("td[id='tdApproved'] input:radio[name*='ff4']:checked +  label").text() != 'Yes'){
    // do something
} 

1
2
//Focus Radio button 1st element in control
$("td[id='tdApproved'] input:radio[name*='ff4']:eq(0)").focus();

1
2
3
4
5
6
7
8
9
//Align all Radio Buttons in the page horizontally
function HorizontalAlignChoices() {
    var objSpans = $(".ms-RadioText");
    objSpans.each(function () {
        if ($(this).is("span")) {
            $(this).closest("tr").css({ "float": "left" });
        }
    });
}

*** "tdApproved" is the ID of the SharePoint Radio Button Control, "ff4" is the unique ID of the SharePoint Control in your List form. Change this ID according to your form to get the exact result.
Please share your valuable comments which will make me write more and also share this post using the below social buttons to others. 
Happy Share(ing)Point!   

Update: 21/06/2017
Read this article, to know how to access Checkbox in SharePoint using JQuery ðŸ˜Ž

Oct 13, 2016

Get Current Logged in User & Manager using REST API in SharePoint Online

Scenario: 
Environment: SharePoint Online 
Approach:      Populating Current logged in user in People Picker. Also populating user's Manager automatically using REST API and SP Services.
Solution:
1. Create an SharePoint custom list "Learning" (in my case).
2. Create two columns with the following names and data types shown below:
         Internal Name                      Title                                                   Type
CurrentLoggedinUser           Current Logged in User Person or Group (People Only)
Manager                              Manager Person or Group (People Only
3. When you try adding a new item in the list, it should look like:
Here the two people pickers are SP 2013 people picker type where it will show the matching users while typing few words automatically.
4. Now open the list in SharePoint Designer, Create a New Custom Form and make it as default as shown below in the screenshots:

Open the new custom form in Advanced Mode, where you can edit the List Form. Try viewing the page by clicking F5 or Preview in Browser icon in top left corner in the designer.
5. You can see the difference in People Picker. When you create a custom list form, the default forms are automatically changed to SharePoint old type. (for more details read this blog).
6. Now add the ID for both fields as shown below. Also, add the reference the JQuery in the form 
7. Now add the ID's for the two people picker values so that it will be useful for querying the SharePoint controls as shown below
 8. Add a JS file ("Learning.js") in the Site Assets Library and refer it in the new form. Add the below code in the newly created "Learning.js" file.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$(document).ready(function() {
 var userAccountName= $().SPServices.SPGetCurrentUser();
 //Set current logged in user and manager name in people picker
 LoadPeoplePickerDetails();
 //Show the form fields on document.ready()
 $("#onetIDListForm").show();
});
 
/****************** All function defintions starts here********************************/
//Function to set people picker values
function LoadPeoplePickerDetails()
{
 var url=_spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties"
 getReqData(url,function(data){    
 try 
 {
         //Get properties from user profile Json response  
         var userDisplayName = data.d.DisplayName;
         var AccountName = data.d.AccountName;
         $("#tdCurrentUser [id$='upLevelDiv']").html(AccountName);
         $("#tdCurrentUser [id$='checkNames']").click();
         var Manager = data.d.ExtendedManagers.results;
         $("#tdManager [id$='upLevelDiv']").html(Manager[Manager.length-1]);
         $("#tdManager [id$='checkNames']").click();             
 }
 catch(err){
   
  }               
     },
     function(data){
       //alert("some error occured in getting current User info");
     });
}

function getReqData(reqUrl,success, failure) {
 $.ajax({
  url: reqUrl, 
  method: "GET",
  headers: { "Accept": "application/json; odata=verbose" },
  success: function (data) {
   success(data);
  },
  error: function (data) {
   failure(data);
  }
 });
}
9. Save the JS and the custom new form as well.
10. Now, try adding a new item. The current logged in user and the current logged in user's manager name will be automatically set in the people picker as shown below.

11. It is basically, on document.ready(), REST API call is made and it populates the data on the form load.

Note: 
1. The people picker for Manager field is loaded after getting the value from current logged in user field. Hence if you have to change the user, the manager value is set during document.ready(). If you want to change the user and set the manager field, then write a method for setting value of manger and call it on value set in first people picker
2. I have implemented only in  Custom New Form only.

For ease of use, I have shared the js and the List Template. Please use this link to download.

In the above tutorial, you have learned how to create a Custom Form in SharePoint Online, make REST API calls and also set the values to the People Picker in the list form.

Please share your valuable comments which will make me write more and also share this post using the below social buttons to others. Happy Share(ing)Point!    

Oct 10, 2016

Deploying List Workflow in SharePoint Online

Recently, I had a query from one of my readers about migrating the Workflows from development to production and the environment is SharePoint Online.
Scenario:
Suppose that you have created a List Workflow in development site in SP Online and now it is ready to move to Production in SP Online, you can follow the following steps to deploy the workflow. This method is easy, cheaper since no third party tool (licensing cost) is used for migration/deployment.
Solution:
1. Take the backup of SP list with or with out content (depending upon the requirement). List backup will be in .stp format.
2. Download the List Template from List Templates (Site Settings -> Web Designer Galleries -> List Templates).
3. Upload the List Template in the PROD site in the same path (Site Settings -> Web Designer Galleries -> List Templates).
4. Create a new app from "Add an App" and create the list with the same Internal Name (impt: the internal name of the list created in the PROD should be the same as DEV environment)
5. Open the DEV site SP designer, point to the List Workflow -> Click save as template from ribbon (in Manage section) - This will save your WF as web part solution (.wsp) in the Site Assets Library. 
6. Download the WSP and upload it to the PROD site solutions: Site Settings ->  Web Designer Galleries -> Solutions -> Upload & Activate the solution
7. Now navigate to the Site Settings -> Site Actions -> Manage Site Features -> Activate the workflow (it should be in the name Workflow Template "name of the workflow" from web template "name of the site")
Note: If you do not the create the list with the same internal name in the PROD, you will get an error while activating the feature.
8. Now, navigate to the list -> list settings -> workflow settings -> you should see the Workflow associated with the list already. If you face any issues, remove the associated workflow, add it again either from SP designer or from SharePoint UI itself.
Hope this helps you in deploying the workflow from development site to production site in SharePoint Online.
If this useful to you, share this post using the buttons below / share your comments which will make me write more!  ðŸ˜Š

Oct 29, 2013

The Server could not complete your request SharePoint Designer 2013

Problem:
When I tried opening SharePoint 2013 site in SharePoint Designer, I got the following error:

When I clicked on Details, it opened another dialog and continuously pop up window is opening and not able to open the SharePoint site.

 Finally got an error message
Solution:
    1.   Go to Run -> type Inetmgr -> Open the IIS
    2.   In the Web Sites select “SharePoint Web Services” in the list


    3.   Click on the Authentication and Enable “Anonymous Authentication” as shown below:

   4.   After enabling this, I am able to open the SharePoint site in designer without any issues

Reason for the issue: Check this article http://support.microsoft.com/kb/2758431 

Aug 7, 2013

Create Custom Page Layouts in SharePoint 2013

In this article we will learn how to create Custom Page Layouts for SharePoint 2013. Like SP 2010, we can create Custom Page Layouts in SharePoint 2013 using Visual Studio 2012 and Microsoft SharePoint Designer 2013 either from the scratch or by using the existing Layouts.

New in SharePoint 2013:
In SharePoint Designer we have a new feature called “Design Manager” (under Look and Feel) where we can create a Custom Layout. Once created, it will be available in the Page Layouts Gallery.

Steps:
1.   Navigate to Site Settings -> Look and Feel -> Design Manager
   2.   Under Design Manager Click on 6. Edit Page Layouts -> you have an option to “Create a page Layout” and then create it.


  3.   When the Layout is created, it is available in Edit Page Layouts (under Look and Feel -> Design Manager) and in Master pages and page layouts (under Web Designer galleries)


  4. In the Master pages and page layouts section, you will see two files created for the layout created. .aspx and .html files”
  5.  For editing the layout page, either you can download the HTML page from the Layouts Gallery or edit the HTML files in the SharePoint Designer
    Note: No Changes should be made to .aspx file in the layouts gallery.
  6.  Once the changes are made in the HTML file, upload the updated HTML file to the gallery so that the .aspx file updated automatically.
  7.   Check in and Publish the created layouts 

  8. Now, create pages (Site Settings -> Pages -> Create Page using New Document -> Page and select the Custom Page Layout which is created) 
Hope this helps you!

Jul 22, 2013

Creating Master Page with HTML Templates in SharePoint 2013

SharePoint 2013 has many new and improved design features for designing and branding it. In SP 2013, a new concept called Design Manager has been introduced where all the site branding is managed. The following article explains the step by step process of converting HTML Master Pages for using Design Manager and using the converted Master Page for the site collections.

Steps:
     1.   Create a Site Collection using Central Administration
     2.   Go to the Site Settings -> Enable SharePoint Publishing Feature in Site Collection Feature (Site Collection Administration -> Site Features) and Site Features level (Site Actions -> Site Features) as shown below:


    3.   Go to Site Settings -> Web Designer Galleries -> Master Pages and Page Layouts
    4.   I have created a folder called Custom Master Page inside the Master Pages and Page Layouts Folder and uploaded the HTML, CSS, JS, Images in the folder
    5.   Now navigate to Site Settings -> Look and Feel -> Design Manager -> Edit Master Pages -> Click Convert an existing HTML to Master Page 
  6.   Once converted you will see the converted Master Page in the List with the status Conversion Successful and make sure it is approved and published.
    7.   Now navigate to Site Settings -> Look and Feel -> Page Layouts and Site Templates select the Custom master Page created and use it for the site collection.
For branding in SP 2010 we need good web designing skills (HTML, CSS and JS). But in SP 2013 it has made very simple and easy! 

May 6, 2012

Creating FAVICON for WSS 3.0 and MOSS 2007

In this article, we have learned how to Changing the FavIcon in SharePoint 2010.
But there is no favIcon for WSS 3.0 and MOSS 2007 by default. Then how to create favicon for the lower versions of the SharePoint. Here is the solution.
Steps:
1. Open the SharePoint site (WSS 3.0 or MOSS 2007) in SharePoint designer 2007
2. Edit the master page
3. Add the below tag before end of the HEAD tag in the master page
<link rel=”shortcut icon” href=”/SiteImages /favicon.ico” /> 
4. Now save the master page and Check in the page
5. Refresh the SharePoint page, you will see the FAVICON  in the address bar of the SharePoint site.
To know more about:
1. What is favicon ? 
2. Creating favicon
3. Use of favicon
Read this article.

May 3, 2012

Changing Favicon in SharePoint 2010

What is Favicon?
All the top websites in the internet will have their favicon in the address bar. Similarly SharePoint 2010 sites also have its favicon in the address bar as shown below:
What is the use of Favicon?
When we are saving a site as a favorite then this icon will be saved for the reference with the site name starting in the favorites bar in any web browser. For example: Take Google you will see the Google symbol in the address bar. 
How to create Favicon (.ico file)?
I have used this website http://www.coolutils.com/online/image-converter/ for converting the image to .ico file which is favicon file. You can upload your company’s logo and convert it into .ico file in the mentioned site and download it from the site. (You can use any free convertors site online to create the icon file) 
How to set Favicon in the SharePoint 2010 site?
SharePoint 2010 displays an orange Favicon and it is present in the following folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\favicon.ico 
It will look like as follows:
Now, navigate to the above path and search for favicon.ico and rename the file to FaviconBackup.ico.
Now copy your favicon (.ico file) to this folder and make sure it is named as "favicon.ico".
Now refresh your SharePoint site and you will see the new favicon displayed in the address bar.
How to display different Favicons for different sites in the server farm?
The only way is we will change the favicon in the master page inorder to set different favicons for different sites.
Hence, edit the V4.master page file in the SharePoint designer and check out the file and look for the following in the code view:
<SharePoint:SPShortcutIcon runat="server" IconUrl="/_layouts/images/favicon.ico"/>
Now,upload the favicon file in the image library or store the file with different name in this folder. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\newfavicon.ico
<SharePoint:SPShortcutIcon runat="server" IconUrl="/_layouts/images/ newfavicon.ico "/>
Give thenew URL in the tag and save the master page and check in the file. 
Refresh the SharePoint page and now you can set the different favicon for more than one site in the SP farm.


To know about creating FAVICON for WSS 3.0 and MOSS 2007 read this article

Apr 22, 2012

New features of SharePoint Designer 2010

Read this article, to know the Basics of Workflow in SharePoint.
Read this article, to know about Implementing Designer workflow in SharePoint using SharePoint designer 2007.
In this article, we will come to know about the new features added in the SharePoint designer 2010 for the workflow.

What is new in workflows in SharePoint Designer 2010?
In the SharePoint 2010 designer you will see a ‘ Work flows’ tab in the ribbon on the top. Now you can create three types of workflow in SharePoint 2010 using designer 2010:


Ø  List Workflow – This is associated with a specific list or libraries in SharePoint.

Ø  Reusable Workflow – This type of workflow can be associated with multiple lists or content types. It is more flexible than the List workflow type. Later this content type can be used with a list. One more advantage of this type of work flow is you can import it to Visual Studio and we can write code to enhance this type of workflow.

Ø  Site Workflow – This workflow is not associated with any lists or site content types and can be started from All Site content in the page i.e., it operates on the site level.

When you create a workflow, you will see the following new options in the ribbon which makes the user to create and trouble shoot the workflow in SharePoint very easily.

Now let us know about the new options for implementing the workflow in SP 2010 designer. Particularly in the ribbon interface.


  1. Save button – Now you can save the workflow. This option was not available in SharePoint Designer 2007.
  2. Publish button – By clicking the publish button, you can publish the workflow to the SharePoint site.
  3. Condition – Here you can implement the conditions for the workflow.
  4. Action – Here you can add multiple actions when a specific condition occurs in the workflow.
  5. Export to Visio – Using this option, you can convert a workflow and show it in a diagrammatic representation to the user which gives clear understanding, actions, process, people involved and status of the workflow.
  6. Initiation Form Parameters – you can define the starting parameters for the workflow.
  7. Local Variables – Here you can define the internal variables of the workflow using this option.

Apr 16, 2012

Workflow using SharePoint designer 2007

To know about the basics of the Work flows in SharePoint, read this article.
In this article, we will learn how to create a designer workflow in SharePoint designer 2007.
Scenario:
1.   Create a workflow in SharePoint designer 2007
2.   This workflow should be automatically triggered when an item is created or updated in a SharePoint Document library
3.   When the workflow is initiated, then the document created or updated in the document library should be copied to another document library
4.   Also, we will have parameter (flag) in the document library whether to move or not in the document library.

Solution:
We will create two document libraries named, “Draft Library” and “Publish Library”.
In the Draft Library we will create an additional column named Move to Publish Library of type Choice menu (YES or NO)
When a document is uploaded or updated in Draft Library with the flag value equals to yes, then the workflow should be triggered which will copy the item to the Publish Library.

Steps:
Open the SharePoint site in the designer and click on File -> New -> Workflow


Give the name of the workflow and Select the document library for the workflow to be associated (Draft Library in our case). Then Select two options Automatically starts the workflow when an item is created or change and click on Next.


In the Step1, click on the conditions and select Compare Draft Library field


Now, select the Move to Publish Library column and Value equals to Yes as shown below



Now we will apply the action for the workflow. Click on Actions -> Copy List Item. 


Now select Draft Library to Publish Library in the values as shown below


Once you click on finish, then the workflow will be associated to the “Draft Library”.


Navigate to the SharePoint Document library and when you check the workflow settings, and then you will see the MoveDocuments workflow associated with the Draft document library.


Now, we will test the workflow. Go ahead and upload a document into the “Draft Library”. Select YES in the Move to Publish Library option as shown below:


Now, our workflow will be initiated and you will see the status of the workflow (completed) in the document library as shown below:



Click on the completed in the document library where you will be navigated to the workflow information as shown below:


Now, navigate to the publish library, you will see the document being copied as result of the workflow as shown below:


Now, at the end of this article we have learned the following from this article:
1. Creating a Designer workflow in SharePoint using SharePoint designer 2007.
2. Used workflow to copy an item form one document library to another document library.


To know about the new features added in SharePoint Designer 2010, read this article.

Free to comment if this article helps you!