Thursday, April 18, 2013

Workflow Can Use App Permissions Feature and Publish Workflow

When trying to enable "Workflow Can Use App Permissions" under Site Settings=> Manage Site Features => then trying to activate the feature, I found the following exception occurs:

Exception information: 
    Exception type: SPException 
    Exception message: We're sorry, we weren't able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator.
   at Microsoft.SharePoint.SPScaleOutDatabaseMap.CreateSqlSession(ISPScaleOutDatabaseMapProvider mapProvider, Byte[] compositeKey, Guid forceRefreshVersion, Guid& version)
   at Microsoft.SharePoint.SPScaleOutDatabaseCommandExecutor.Execute(ExecuteDelegate operation, ISPScaleOutDatabaseMapProvider mapProvider, SPSqlCommand command, Byte[] compositeKey)
   at Microsoft.SharePoint.AppManagement.AppManagementServiceApplicationProxy.PutApp(SPAppPrincipalInfo appInfo)
   at Microsoft.SharePoint.AppRegistration.AddOrUpdateAppNoPermissionCheck(SPAppPrincipalInfo appInfo)
   at Microsoft.SharePoint.SPAppPrincipalManager.RegisterWithInternalDirectory(SPAppPrincipalIdentityProvider identityProvider, String nameIdentifier, String displayName, List`1 appEndpointAuthorities, List`1 redirectAddresses, Boolean delegateAppPermissions, Boolean isInternalDirectoryApp)
   at Microsoft.SharePoint.SPAppPrincipalManager.CreateAppPrincipal(SPExternalAppPrincipalCreationParameters creationParameters)
   at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.EnsureAppPrincipal(SPWeb elevatedWeb)
   at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.<>c__DisplayClass1.b__0()
   at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.b__3()
   at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)
   at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)
   at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, SPFeatureActivateFlags activateFlags, Boolean fForce)
   at Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean fMarkOnly)
   at Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, Int32 compatibilityLevel, String featureName, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope)
   at Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid featid, Int32 compatibilityLevel, SPFeatureDefinitionScope featdefScope)
   at Microsoft.SharePoint.WebControls.FeatureActivatorItem.ToggleFeatureActivation()
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Also, Same exception appeared while trying to publish SharePoint 2013 Workflow. I tried to find a related events in the Event Viewer and I found a lot of exceptions related to "App Management Service" service application in SharePoint and I found most of exceptions was related the SQL login fail to the backend database. So, in that case, All you need is to check user permission to the database. Or simply delete the current App Management Service from central administration by going to Application Management, under Service Application click on Manage Service Application. In the page click on App Management Service then click delete from the ribbon. Then, you can go to the configuration wizard again at the left of the central administration and start the configuration again.

Please refer to http://technet.microsoft.com/en-us/library/fp161236.aspx

Also, Please be cautious at the live environment, the above steps are tested at the development environment.

Cannot Publish SharePoint 2013 Workflow using SharePoint Designer

When trying to publish SharePoint 2013 Workflow using SharePoint designer 2013, sometimes the following exception appears:

Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors:
Cannot set unknown member 'CompositeTask.RelatedContentLinkListItemIntegerId'. HTTP headers received from the server - ActivityId: 15459ce7-8e0d-4267-aa59-cc724289e422. NodeId: TECSRVSOL02. Scope: /SharePoint/default/c8ca3a4c-bb1a-4056-b675-597fa0348916/0d4731cd-bfe2-47b6-acd2-6caa6bd45931

I tried so hard to find a solution for this until I found this post (http://sp2013-blog.com/2013/04/solution-errors-were-found-when-compiling-the-workflow-the-workflow-files-were-saved-but-cannot-be-run-cannot-set-unknown-member/) Michael and the following Post by Tarek Yehia (http://sharepointserver-2007.blogspot.ae/2013/04/sharepoint-designer-error-while.html).

Basically, The solution was to register Workflow service again using SharePoint 2013 Power Shell.

Register-SPWorkflowService -SPSite 'https://myhost/mysite' -WorkflowHostUri 'https://workflowhost' -AllowOAuthHttp -Force

Sunday, April 7, 2013

SharePoint 2013 Workflows (Loops and State Machine)

Finally, SharePoint 2013 supports a state machine workflow. It is not mandatory to be sequential. Also, It supports loops now, so you can create loop without the guilty feeling of the workaround developers were doing in old SharePoint servers. Good Job.
In the image below, you can add go to another stage in the "transition to stage" scope. You have to configure Workflow Manager 1.0 and register the workflow service to the SharePoint 2013 Server. If you need more help about that, Kindly refer to http://technet.microsoft.com/en-us/library/jj658588.aspx


SharePoint 2013 Workflow Designer

Sunday, February 3, 2013

SharePoint 2013 Open Site Issue

After installing SharePoint Designer 2013 and after clicking on "Open Site" button, SharePoint designer 2013 crashes. This issue occurs only if you have both SharePoint designer 2010 and 2013 installed (Side by Side installation). To resolve this issue, Check this post by "Bradley Geldenhuys":

http://www.gtconsult.co.za/blog/Lists/Posts/Post.aspx?ID=8

Thank you Bradley :)

Thursday, December 2, 2010

Sharepoint 2010 Javascript error when adding or editing items in a list using popups

I have discovered a weird problem in Sharepoint 2010 and many of developers have discovered that too. To reproduce the problem follow the following steps:

1. Create new list of any type (Calendar, custom,...etc).
2. browse the list.
3. Click on Add new Item.
4. In the pop up, click on maximize before the page finishes loading (once the maximize button appear). (A).
5. once maximized or once the pop up appears, click on close to close the pop up dialog. (B)

Expected:
for A: the pop up should be maximized.
for B: the pop up should be closed and returns to the list view.

Actual:
For A: Invalid Argument javascript error occurs in SP.UI.RTE.js.
For B: Invalid Argument javascript error occurs in SP.UI.Dialog.js.

I have tried the above scenarios in multiple servers and i can reproduce the the error in all cases. i have tried to resolve the problem but i cannot find any straightforward one. However, i discovered that after the javascript errors appear, the pop up behaves normally so, i decided to try handling that error by writing a custom javascript to handle the error. After that, the javascript errors disappeared and everything is now working very well.

To handle that error, just write a custom javascript function to handle the error using the following code:

//START DIRTY WORKAROUND TO HANDLE THE JS ERROR WHEN CLICKING ADD NEW ITEM OR EDIT AND MAXIMIZE BEFORE WINDOW FINISHS LOADING
//ALSO HANDLES WHEN CLOSING THE POPUP BEFORE FINISHING, IT GIVES JS ERROR.
function noErrorMessages(err, url) {
    // HANDLE MAX THE POPUP ERROR
    if (err.search(/invalid argument/gi) >= 0 && url.search(/sp.ui.rte/gi) >= 0) {
        return true;
    }
    // HANDLES CLOSING THE POPUP
    else if (err.search(/or not an object/gi) >= 0 && url.search(/sp.ui.dialog/gi) >= 0) {
        return true;
    }
    return false;

}
window.onerror = noErrorMessages;

//END DIRTY WORKAROUND

The above javascript code hides the above errors only and behaves normally for the other javascript errors. (use browser default behavior). By adding the above javascript code to the master page or to the page that shows the adding new item or editing existing item, the javascript errors will disappear and everything will behave normally.

Tuesday, September 7, 2010

Configuring WCF for Multi Addresses

If you have a web site that has two address, for example: http://IP:PORT/ and http://www.YourSiteHere.com, and if you have a WCF that you need it to work in both URLs, then the configuration of the WCF will be different in that case. To achieve that add the following elements under system.ServiceModel

<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.YourSiteHere.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>

Thursday, February 11, 2010

Fixing Ajax using WCF in Web.config and IIS 7.0

Sometimes when you call WCF from javascript (http://Site/Service.svc/js) or adding your WCF URL as service reference in the script manager, you find that the JS Proxy of the WCF returns 404 not found from the server. You can Check my previous post for more error details here: http://kholyos.blogspot.com/2010/02/how-to-solve-404-not-found-when-calling.html
You can fix this issue using alternative method, by modifying in the web.config of your application. Using the <handlers> tag under <system.webserver> can do the trick for you.

By adding the following Elements under <configuration><system.webserver><handlers> you can fix the issue:

<add name="svc-ISAPI-2.0" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />



<add name="svc-ISAPI-2.0-64" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />



for more Information about handlers tag, you can follow this link to MSDN: http://msdn.microsoft.com/en-us/library/ms691481.aspx

That's it. And Enjoy :).

Monday, February 8, 2010

How to Solve 404 Not Found When Calling WCF from Javascript using script manager

When you and Service reference in the script manager to point to .svc file, and then calling it from javascript, sometimes it gives you script error in the page that the service cannot be found. To solve this issue, follow these steps (Considering you have IIS 7.0):
  1. Make sure that .Net framework 3.0 or later is installed on the server. You can find it here.
  2. Register the service model to the IIS by doing the following:
    • Open CMD.exe
    • Navigate to: "C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation"
    • Run "ServiceModelReg.exe -r"
    • then, if you have x64 Windows, Navigate to: "C:\Windows\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation"
    • then run: "ServiceModelReg.exe -r"
  3. Open IIS. You can use Run->inetmgr.
  4. Click on the site that hosts the .svc file, and browse the Features view in the IIS. Then, open the Handler Mappings.
  5. In the right Panel (Actions), Choose Add Script Map.
  6. A window will appear to add new script map, and fill the following parameters:
  7. Request Path : *.svc

    Executable : %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll

    Name: svc-ISAPI-2.0

  8. Click Add Script Map again if you have x64 Windows and use the following parameters:
  9. Request Path : *.svc

    Executable : %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll

    Name: svc-ISAPI-2.0-64

  10. Then browse the Service using your internet browser : http://yourURL/...../YourService.svc/js, if you can see the scripts generated by Microsoft Ajax then you are done. Otherwise, you should allow anonymouse in your web site.
That's it and Enjoy :).

Thursday, July 2, 2009

Link 2 Imagine Cup

Check my blog for Imagine Cup at Link 2 Imagine Cup Blog. It's all about imagine cup and my experience there. Imagine Cup is the biggest Technology Competition in the world organized by Microsoft. Check imagine cup new in Egypt at Link 2 Imagine Cup, check my posts there and Enjoy :).

Wednesday, May 20, 2009

Barmagy

WOWW, Now I’m one of Barmagy Community and I’m really proud of that. I’m starting my activities soon to help people learn more and more about technologies. Wish Barmagy for more progress. Check barmagy Community at: http://www.barmagy.com

Thursday, March 26, 2009

JQuery with ASP.NET

In the past few days, I was working in development some components using JQuery. I was really impressed with the functionalities and performance as I am really a big fan of javascript.

You can take a look on JQuery and download the library from: http://jquery.com/.

Now, I’m going to give a sample about how to use JQuery ASP.NET to have an AJAX page.

1.Download the library from http://jquery.com/.

2.Create New ASP.Net web application using Microsoft Visual Studio.

3.Add new User Control in your project.

4.Add the downloaded file of JQuery to your project.

5. drag and drop the JQuery .js file into your control or just add the following line to your ascx:

<script src="jquery-1.3.1.min.js" type="text/javascript"></script>

Now we are going to start the most interesting part.

Consider a case that you want to have an expand/collapse button, when user clicks on it, it shows a form to let the user enter a data, if it is already expanded, then collapse it. Also you need to expand or collapse with animation (slide the form that will appear), that is, not just appears suddenly to the user.

Consider the following:

   1: <div>
   2:         <div>
   3:             <!--The button to expand or collapse-->
   4:             <a href="javascript:;" onclick="ExpandCollapse(this,'expandcpllapse')">+</a> Show
   5:             Panel
   6:         </div>
   7:         <!--The div that needs to be shown or hidden based on expand or collapse-->
   8:         <div id="expandcpllapse" style="display: none">
   9:             <asp:Label ID="lblName" runat="server" Text="Name"></asp:Label>
  10:             <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
  11:         </div>
  12:     </div>

and the javascript to expand/collapse



   1: //Represents the current status of the panel to expand/collapse
   2: var status = 'Collapsed';
   3:  
   4: //Expand the form if collapsed. if collapsed, expand it.
   5: function ExpandCollapse(sender, div)
   6: {
   7:     switch (status)
   8:     {
   9:         case 'Collapsed':
  10:             {
  11:                 //Show the div that contains the data. the parameter "0" represents the speed to show it
  12:                 $('#' + div).show("0");
  13:                 //Change the text from "+" to "-"
  14:                 $(sender)[0].innerText = '-';
  15:                 //Change the status to be expanded
  16:                 status = 'Expanded';
  17:             }
  18:             break;
  19:         case 'Expanded':
  20:             {
  21:                 //Hide the div with speed "0"
  22:                 $('#' + div).hide("0");
  23:                 // change the text from "-" to "+"
  24:                 $(sender)[0].innerText = '+';
  25:                 //Change the status to collapsed
  26:                 status = 'Collapsed';
  27:             }
  28:             break;
  29:     }
  30: }

that was a very little from JQuery functionalities and how to use it to reach a better user experience.

Wednesday, January 7, 2009

Visual Studio 2010

Microsoft has announced about Visual Studio 2010. You can take a look about it here: http://www.microsoft.com/Visualstudio/products/2010/default.mspx

Also you can download the CTP version. Enjoy

Tuesday, January 6, 2009

Imagine Cup 2009

In Jan 2006, My life has changed. One of my friends told me about a competition organized by Microsoft called "Imagine Cup" and he asked me to participate in this competition and to costruct a powerful team together to represent Egypt in the finals. I've been impressed by the idea and I decided to take the challenge with my friend. We started to collect the team members, and finally we found two of our friends that can represent Egypt in that huge Challenge. Now we are a team that our dreams has no end. We have many ideas many dreams to participate in Imagine Cup. In Feb 2006, we started to develop our chosen idea and we loved that project like one of our sons :). In March 2006, this is my turing point in my life, a phone call from "Ahmed Adel" from Microsoft Egypt to tell us that we have won the 1st rank in the local competition and we were chosen to represent Egypt in the finals in India.

Now, Imagine Cup competetion will be in Egypt. That makes me really proud and really so happy for that. Go to that link http://egyptimaginecup2009.spaces.live.com/ to check about the new updates about Imagine Cup in Egypt.

If you are student, Please don't hesitate to participate in Imagine Cup. If you are not, try to check the real challenge and the spirit of all participants. That will really make you impressed and proud of the ideas and the students.

Check Imagine Cup web site at: http://imaginecup.com/

Wednesday, June 4, 2008

Great Experience with TFS 2005

In the last two weeks, I decided to install Team Foundation Server (TFS) 2005 on a virtual machine at my home. It was really a great experience. I worked in the check-in policy before but I decided to get more experience about TFS.

Installing TFS is not so hard but all you need to do is to follow the installation guide. You can find the guide file burned on your DVD of TFS or you can find it at Microsoft web site. also you can try TFS 2005 trial version. It's trial for six months. Find the TFS 2005 trial at:

Team Foundation Server 2005 Trial Download link

But unfortunately, After Installation, I found that Microsoft has just released Microsoft Team Foundation Server 2008 and i knew that after installing TFS 2005 :( but I'll install it soon.

Remember, just follow the guide and everything will be OK.

Tuesday, May 27, 2008

What is LinQ?

LinQ stands for "Language Integrated Query". It extends C# and visual basic syntax with the new LinQ syntax to provide more capabilities in your code.

It's an interesting feature in C# 3.0. I'll hit an example for LinQ. consider the following class:

   1: class Student

   2:  {

   3:      int id;


   4:  

   5:      public int Id

   6:      {

   7:          get { return id; }

   8:          set { id = value; }

   9:      }

  10:      string studentName;

  11:  

  12:      public string StudentName

  13:      {

  14:          get { return studentName; }

  15:          set { studentName = value; }

  16:      }

  17:  

  18:  }



List<Student> studentList = GetStudentList();


now you need to find all student with name John:


   1: var studentQurey = from student in students

   2:                    where student.StudentName == "John"

   3:                    select student;

   4: studentQurey.ToList();


that was a so simple example for LinQ. You can use LinQ to SQL to search in a database in your application and a lot of feature included in LinQ.

Monday, April 21, 2008

Need for performance

Wrong Thoughts:

Some people think that the hardware power has been increased in the last few years and that makes them think that they can develop applications without taking in consideration the minimum requirements for their applications. For example: your application needs 150 MB in the memory to work and you found your team telling you: "Whatever, the laptops now support up to 4 GB, just release it.". This is totally wrong vision. You have to think if you are really in need to these 150 MB in memory, or you can optimize your code to reduce the memory required for your application.

Now, if your application is taking 3 seconds to perform a user task, the user will consider this application as a slow application. Later, we will find that it will be reduced to 1 second. The target now is to build applications with the highest performance we could reach. For example: if you have a list of objects and you need just one of them, you can loop to find it or you can think if you can get it when constructing that list. Try to use the latest tools like LinQ from Microsoft to search for an object in a list. Also, if you need some objects only from that list, try not to put them in another list, just try to remove the unwanted objects from it if that is possible.

All you need to do now is to think how to optimize your code to reach the maximum possible performance for your application. Do not think that you are protected by the increasing of the hardware power, just optimize your code.

Friday, April 18, 2008

My First Post

.Net Dimension, I spend a lot of time thinking about that title for this blog. One of my friends called Amr Sawy suggested this name for me. Thanks Amr for this name. I'll talk in this blog about any thing that carries Microsoft Name :) but my target is to build application using these products.