SharePoint Interview Questions and Answers2: List vs Library


Update a SharePoint list item without changes its version?
item.SystemUpdate(false);

Difference between Update and systemupdate in SharePoint list?
The Item.Update () updates the database with the changes, creates a new version and changes the “ModifiedOn” and “ModifiedBy” fields.
Limitation: There is no “item.SystemUpdate ()” method at client object model. Only server side is available.
References:

 Check in and checked out documents in SharePoint?
The check-in/check-out feature is one of the key features of SharePoint document libraries.
By default, required check-in and check-out is disabled in SharePoint.
  1. Go to library settings Ã versioning settings
  2. Required documents to be checked out before they can be editedà choose “yes” and click “Ok”

When a user has a document checked out, changes the user makes are not visible to anyone until the document is checked in. Means when a file is checked out to you, you are the only one allowed making changes to it. The file will remain locked (checked-out) until you release it.

Site administrators with correct privileges can discard the checked-out lock made by a user.
Minimum “Designer” level permissions required to override check out others checked out documents.

Note: If the System Account is the account that has the item checked out, users are no longer available to check in the item or discard the check out from the library’s views, even with the Override Check Out permission.

How to make document changes Offline:
When try to check out a document, SharePoint prompts you to save the document in your Local folder.
Your local drafts folder can be found at C:\users\%username%\documents\document name.
Now you can work with documents offline, make changes, and then synchronize those changes once done.

How to check in all the checked out documents at once?
You will be able to check in the item or discard the check out of all the checked out documents by using Manage Content and Structure feature.
Go to Site Actions > Manage Content and Structure
Check in all the checked out documents.

What all are minimum permission levels required to Discard check out the documents?
The Override Check Out permission allows one user to check in a document checked out by another user. The same permission allows a user to discard the check out of a document checked out by another user. This permission is part of the Design permission level. Anyone who has Design (or Full Control) roles can check in or discard check out for documents.

What is the default size of upload document in SharePoint?
50MB. But SharePoint supports max is 2GB.

How to upload large size of documents to document library in SharePoint?
We can’t directly upload the larger files which are all the files having >50MB size. You may encounter the below exception if tries to upload >50MB files.
"An unexpected error has occurred"
"The page cannot be displayed”
"An unknown error occurred"
"HTTP 404 – Page Not Found”
“Request timed Out’
Reason is:  By default, the maximum size for uploading files is set to 50 MB. The maximum file size that it can go up to is 2,047 megabytes (2 GB) and IIS connection time-out setting is 120 seconds.
Please follow the below steps for uploading the larger files >50MB’s:
By increasing the Increase the Maximum Upload Size for the Web Application from Central Administration site.
  1. By increasing the connection time-out setting in IIS.
  2. By increasing the maximum upload size in the web.config file of web application.
  3. By increasing the default chunk size for large files.
  4. By adding ExecutionTimeout Value in the web.config

Reference:
Blogger Tricks


Query a workflow status using caml query:


Recently I have got a requirement like need to display the list of items which are all having the workflow status is “In Progress”.
I used caml query to filter the date based on workflow status: “In Progress” like below:
<Query>
       <Where>
                  <Neq>
                          <FieldRef Name="MyWorkflowStatusName" />
                          <Value Type="WorkflowStatus">In Progress</Value>
                 </Neq>
         </Where>
</Query>

But got the “value does not fall within the expect range error”: I have checked the entire fields with both internal names and display names everything defined well but still getting same exception.
After goggling it I came to know that field with value type “WorkflowStatus” should have some predefined integer value types like below.

Status
Value


Not Started
0


Failed on Start
1


In Progress
2


Error Occurred
3


Canceled
4


Completed
5


Failed on Start (retrying)
6


Error Occurred (retrying)
7


Approved
16

   
Rejected
17

I wrote the query like below:
<Query>
       <Where>
                  <Neq>
                          <FieldRef Name="MyWorkflowStatusName" />
                          <Value Type="WorkflowStatus">2</Value>
                 </Neq>
         </Where>
</Query>

Yahooooooo.. I got the expected results…
Conclusion: Please refer the above table while filtering the data based on field with data type:WorkflowStatus
http://social.technet.microsoft.com/Forums/en-US/1b3a0ffc-e8ac-4238-b9d6-458057d735ca/unable-to-query-a-workflow-status-using-caml


Add Button to Ribbon using visual studio 2012

In this task, you will add a custom action to the ribbon of all Document Libraries to launch the App.
  1. In Visual Studio, right click the HelloApp node and select AddØNew Item from the Context menu.
  2. In the New Item dialog, select Ribbon Custom Action.
  3. Name the item Launcher and click Add
  4. In the Create Custom Action for Ribbon window, choose to expose the custom action to theHost Web.  The Custom Action should be scoped to List Template, and the particular item the custom action is scoped to is Document Library.  
  5. In the next window, we will specify settings to generate a button control for the ribbon.  Use the following settings:
    1. Where is the control located? Ribbon.Documents.Manage.Controls._children
    2. What is the label text for the button control? Go! 
    3. Where does the button control navigate to? HelloApp\Pages\Default.aspx


Launch an App from the Ribbon:

In this task, you will deploy the App and use the button on the Ribbon to launch it.
  1. In Visual Studio, right click the HelloApp node and select Deploy from the Context menu.
  2. After the App is deployed, open the home page of the portal where the App is hosted (not the App itself!).
  3. On the home page, click Site Contents.
  4. Click Add an App.
  5. Select to Add a Document Library.
  6. Name the Document Library Shared Documents.
  7. On the Apps page, click the newly-created Shared Documents library.  
  8. In the ribbon, click the Files tab.
  9. Launch the App using the button you created. 

Launching the App from the Ribbon



Create Client Web Part to the App using visual studio 2012

In this task, you will add a Client Web Part and code it. This web part can be used on pages outside of the App to add functionality to the hosting SharePoint site.
  • Add a Client Web Part
    • In the Solution Explorer, right click the HelloApp project node and selectAdd-->New Item from the context menu.
    • In the Add New Item dialog, select Client Web Part.
    • Name the new item MyClientWebPart and click Add.
  • Adding a Client Web Part
    • In the Create Client Web Part dialog, choose Create a new client web part page and give it the name MyClientWebPartSource. 


    •  Replace the entire contents of the Elements file with the following:
  1. <elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  2.   <clientwebpart defaultheight="200" defaultwidth="200" description="A simple client web part" name="MyClientWebPart" title="My Client WebPart">  
  3.     <!-- Content element identifies the location of the page that will render inside the client web part  
  4.          Properties are referenced on the query string using the pattern _propertyName_  
  5.          Example: Src="~appWebUrl/Pages/ClientWebPart1.aspx?Property1=_property1_" -->  
  6.     <content src="~appWebUrl/Pages/MyClientWebPartSource.aspx?Message=_DisplayMessage_" type="html">  
  7.   
  8.     <!-- Define properties in the Properties element.  
  9.          Remember to put Property Name on the Src attribute of the Content element above. -->  
  10.     <properties>  
  11.       <property defaultvalue="Hello, Client Web Part!" name="DisplayMessage" requiresdesignerpermission="true" type="string" webbrowsable="true" webcategory="Configuration" webdescription="A message to display" webdisplayname="Display Message">  
  12.     </property></properties>  
  13.   </content></clientwebpart>  
  14. </elements>  
  • Add a new JavaScript file to hold the logic for the client web part.
    • Right-click the Scripts folder in Visual Studio and choose Add / New Item. Choose Web / JavaScript File and give it a name of MyClientWebPart.js. 


    • Add the following code to the new MyClientWebPart.js file.
  1. <a href="http://www.blogger.com/blogger.g?blogID=482466563826823203" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a>function helloAppPart() {  
  2.     var message = getQueryStringValue("Message");  
  3.     document.getElementById("appPartDiv").innerHTML = "" + message + "  
  4.   
  5. ";  
  6. }  
  7. function getQueryStringValue(paramName) {  
  8.     var params = document.URLUnencoded.split("?")[1].split("&");  
  9.     var strParams = "";  
  10.     for (var i = 0; i < params.length; i = i + 1) {  
  11.         var singleParam = params[i].split("=");  
  12.         if (singleParam[0] == paramName)  
  13.             return decodeURIComponent(singleParam[1]);  
  14.     }  
  15. }  


In the Pages folder, open the item MyClientWebPartSource.aspx.  Add the following in the HEAD tag. <script src="../Scripts/MyClientWebPart.js"></script>
  • Replace the contents of the BODY tag with the following.
<div id="appPartDiv"></div>
<input type="button" value="Push Me!" onclick="helloAppPart();" /> 


The result will look like the following:
 

Add the Client Web Part to a Page:

In this task, you will run the App and add the Client Web Part to the home page of the portal.
  • Deploy the App
    • In Visual Studio, right click the HelloApp node and select Deploy from the context menu.
    • When the App is deployed, open your browser to the home page of the SharePoint site hosting the App (not the home page of the App itself!).
  • Add the Client Web Part
    • In the ribbon, select Page-->Edit Page.
    • Click Add a Web Part in any Zone.
    • Add the My Client WebPart part to the page. 
    •  
    • Click the Push Me button to test the functionality. 
    •  
    • Testing the Client Web Part
    • Retract the App
      • In Visual Studio, right click the HelloApp node and selectRetract from the context menu.
      • Note that the Client Web Part is removed from the home page.

Comments