Wednesday, 21 September 2016

Error occurred in deployment step ‘Activate Features’: Attempted to perform an unauthorized operation

I have created a SharePoint empty project and added visual webpart into it.
When I try to deploy the solution, ended up with below error.

"Error occurred in deployment step "Activate Features" attempted to perform an unauthorized operation"


Reason:
The account which you are trying to deploy the solution may not have permission to specific webapplication/SiteCollection.

Solution:
  • Open SharePoint 2013 Central Administration.
  • Navigate to Application Management and choose Change site collection administrations
  • Select the site collection where deployment should happen
  • Add you windows account[Account which you are trying to deploy] as the primary (or) secondary site collection administrator.

Also check account has permission to access database, if not please add into Security section of SQL Server.

Hope this helps!!!

Monday, 13 June 2016

How to update URL field in SharePoint List using JSOM

 Here is the code to update URL field.
URL will have two properties. One is url and other is description.
Code below is using JSOM.
======================================================
var itemCreateInfo = new SP.ListItemCreationInformation();
var rootUrl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;
itemCreateInfo.set_folderUrl(rootUrl + "/Lists/PROJECTS/Folder");//Create item folder inside list
this.oListItem = oList.addItem(itemCreateInfo);
oListItem.set_item('NUMBER', "23");
     var fvalue = new SP.FieldUrlValue();                  
    fvalue.set_url("http://google.com");
    fvalue.set_description("GoogleLink");
oListItem.set_item('URL', fvalue);
oListItem.update();
======================================================

Hope this helps!!!

Friday, 10 June 2016

Change the URL of the SharePoint List - Create 2010 Tasks list

Problem:
Sometimes when we create the sharepoint task list with 2013 Tasks template(171). We may not open that task and it results to error to open webparts maintenence page.

Resolution:
To resolve this, create Task list with 107 template id which is available with sharepoint 2010.
To do that, Open designer and create 2010 workflow and create task list with that workflow. It will create 107 template id task list.
But name of the task list will be created with the name Tasks and prefixed with workflow name.
ex: WorkflowNameTasks
To rename, we can open the list in sharepoint and edit the name. But it will not change the url. Url still refers old name, only display name changed now.
To change URL also, open the sharepoint site in explorer view and choose the list and rename. This completes URL change also.
Change the list internal name with the url in sharepoint by opening the site in explorer view and rename the list.

Hope it helps!!!

The workflow contains errors, but they are not visible in the current view

Hi,
Sometimes when you work on workflows in SharePoint Designer you can not publish it, because the Check for Errors fails with the following message: “The workflow contains errors, but they are not visible in the current view”
130420_02
Usually in this case you really can’t see the place where the error is and it seems like everything is OK.
I spent some time to understand where the error is when I saw this error for the first time. Most likely it is an issue in SPD. However, it is rather simple to overcome it and force SPD to show the place the error is.
The solution: you just have to save your workflow (by pressing Save button in the ribbon), close it and open it again (by selecting it in the Navigation\Workflows and pressing the “Edit workflow” link).
After that you should be able to see what fields are set incorrectly:
130420_03
You can press Check for Errors button to highlight all the errors with the red color:
130420_04
I stumbled into this moment several times after copying-pasting my workflow. It seems like this new feature works well in the most parts of the workflow, except the Transition to stage part. At least, in my cases after pasting I had to repair fields in the Transition to stage part only.

Reference Url:
http://sp2013.pro/2013/04/solution-the-workflow-contains-errors-but-they-are-not-visible-in-the-current-view/

Manage Site Content and Structure in SharePoint 2013 Missing?

Recently, when I am searching for Manage Content and Structure, I couldn't find in Sharepoint 2013 env, where as it was available in Sharepoint 2010.

But It's not removed - just moved to Site Settings > Site Administration
enter image description here

Hope this helps!!!

SharePoint 2013: Start Workflow with JavaScript Client Object Model

//dialog element to show during processing
var dlg = null;      

//Subscription id - Workflow subscription id
//list item id for which to start workflow. If site workflow, then send null for itemId
function StartWorkflow(subscriptionId, itemId) {
   showInProgressDialog();
   var ctx = SP.ClientContext.get_current();
   var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx, ctx.get_web());
   var subscription = wfManager.getWorkflowSubscriptionService().getSubscription(subscriptionId);
   ctx.load(subscription, 'PropertyDefinitions');
   ctx.executeQueryAsync(
       function (sender, args) {
           var params= new Object();
           //Find initiation data to be passed to workflow.
           var formData = subscription.get_propertyDefinitions()["FormData"];
           if (formData != null && formData != 'undefined' && formData != "") {
               var assocParams = formData.split(";#");
               for (var i = 0; i < assocParams.length; i++) {
                   params[assocParams[i]] = subscription.get_propertyDefinitions()[assocParams[i]];
               }
           }
           if (itemId) {
               wfManager.getWorkflowInstanceService().startWorkflowOnListItem(subscription, itemId, params);
           }
           else {
               wfManager.getWorkflowInstanceService().startWorkflow(subscription, params);
           }
           ctx.executeQueryAsync(
               function (sender, args) {
                   closeInProgressDialog();
               },
               function (sender, args) {
                   closeInProgressDialog();
                   alert('Failed to run workflow');
               }
           );
       },
       function (sender, args) {
           closeInProgressDialog();
           alert('Failed to run workflow');
       }
   );
 }

function closeInProgressDialog() {
   if (dlg != null) {
       dlg.close();
   }
}
 

function showInProgressDialog() {
   if (dlg == null) {
       dlg = SP.UI.ModalDialog.showWaitScreenWithNoClose("Please wait...", "Waiting for workflow...", null, null);
   }
}
Code Snippet 1: Start workflow

As shown in the above code example, you need to pass subscription id and item id. Everytime you associate workflow with list or site, you will get an association id for this association.To get an association id, go to the workflow settings page and then right click on workflow name and from the URL, you can find the subscription id as shown below:
image
Figure 1: Get the Workflow Association Id from Workflow Settings Page

If your workflow is Site Workflow (for your information, SharePoint 2013 workflow can run on a list item or for site), then pass null value for itemId. ‘FormData’ retrieved from workflow Subscription, will be passed to workflow initiation. But if you would like to pass your own additional parameters, you can do so as shown below:
var params= new Object();
//Find initiation data to be passed to workflow.
var formData = subscription.get_propertyDefinitions()["FormData"];
if (formData != null && formData != 'undefined' && formData != "") {
    var assocParams = formData.split(";#");
    for (var i = 0; i < assocParams.length; i++) {
        params[assocParams[i]] = subscription.get_propertyDefinitions()[assocParams[i]];
    }
}

//your custom parameters
params['mykey']='this is custom value';
Code Snippet 2: Passing workflow initiation parameters


Reference URL: http://ranaictiu-technicalblog.blogspot.ae/2013/06/sharepoint-2013-start-workflow-with.html

SharePoint 2013 Workflows Deployment Steps

Understanding how to package and deploy workflow in SharePoint 2013



Overview of the workflow packaging capabilities of SharePoint Designer 2013


SharePoint Designer 2013 provides the capability to save a workflow as a template. Saving a workflow as a template is also known as packaging the workflow. After the workflow is saved as a template, it can then be imported into other SharePoint Server 2013 environments and used without the need to redevelop the workflow. Not all workflow types can be saved as a template. The following matrix shows the workflow types that can be saved as a template.
Support, by platform, for saving a workflow as a template
Workflow type
SharePoint 2010 Workflow platform
SharePoint 2013 Workflow platform
List Workflow
No
Yes
Site Workflow
No
Yes
Reusable Workflow
Yes
Yes

Note
SharePoint Server 2013 contains two different workflow platforms: the SharePoint 2010 Workflow platform and the SharePoint 2013 Workflow platform. Both platforms are available in SharePoint Server 2013. For more information about the two workflow, see Getting started with SharePoint Server 2013 workflow.

Packaging a workflow by using SharePoint Designer 2013


The process for packaging a workflow involves saving the workflow to a template file by using SharePoint Designer 2013. A workflow package is in the form of a Web Solution Package (WSP) file and has a .wsp extension. To package a workflow follow these steps.

Package a workflow

  1. Open an existing workflow, or develop a new workflow, in SharePoint Designer 2013.
  2. On the Workflow Settings tab in the ribbon, click the Save as Template button in the Manage section as shown in the figure.
    Figure: Save workflow as template

    Packaging workflow in SPD 2013
  3. An informational dialog box appears to let you know the template has been saved to the Site Assets library.
  4. Click the Site Assets library to view the workflow template as shown in the figure.
    Figure: A workflow template in Site Assets

    Workflow template in Site Assets.
Tip
A workflow template automatically saves to the Site Assets library of the site collection in which the workflow resides.

Deploying a workflow package to SharePoint 2013


You can deploy a workflow package to a SharePoint farm or site that is different from the farm or site in which it was developed. In order for a workflow deployment to be successful two items must be fulfilled:
  • All workflow dependencies such as lists, libraries, columns, and content types must already exist on the new site.
  • Each dependency must have the exact name of the source dependency.
If a workflow is deployed and the exact dependencies do not exist then the result will be an error.
Before you can deploy a workflow you must first export the workflow template from the source SharePoint Server 2013 farm. To export a workflow template, follow this procedure.

Export a workflow template

  1. Open SharePoint Designer 2013 and navigate to the Site Assets library where the template is located.
  2. Select the workflow template you want to export by clicking it.
  3. Click the Export File button to save the template file to your local computer or a network drive, as shown in the figure.
    Figure: Export workflow template from SharePoint Designer 2013

    Export workflow file from SPD.
To deploy a workflow package follow this procedure.

Deploy a workflow solution

  1. Open Internet Explorer and navigate to the SharePoint Server 2013 site collection where you want to deploy the workflow.
  2. Click Site Actions and select Site Settings.
  3. In the Web Design Galleries section click Solutions.
    Note
    You must be on the Site Settings page for the site collection in order to see the Solutions gallery. If you are on the Site Settings page for a sub-site then the Solutions gallery is not visible.
  4. Click the Upload Solution button to upload the solution as shown in the figure.
    Figure: Upload Solution button

    Upload solution button.
  5. Activate the solution by clicking the Activate button as shown in the figure.
    Figure: Activate Solution dialog and button

    Activate solution after upload.
After a workflow solution has been activated for a site collection, it is available as a feature for all sub-sites. To activate the workflow feature for a sub-site, follow this procedure.

Activate the workflow feature

  1. Open Site Settings on the site where you wish to activate the workflow feature.
  2. In the Site Actions group, click Manage site features.
  3. Click Activate next to the workflow feature as shown in the figure.
Figure: Activate workflow feature for site

Activate site feature.
Reference Url:
https://msdn.microsoft.com/en-us/library/office/jj819316.aspx