Wednesday, 19 January 2011

Overview: Once the Timesheet wasp is installed, the new Timesheet database and the web.config changes have been made as described in Part 3 (Timesheet Installation), you need to add pages for users to input there timesheets and administration. You will need to create at least 1 client, 1 project and add a person to a project before you can submit timesheets.

Add pages to the Timesheet application within SharePoint 2010:
I create a "new publishing site" called "Timesheet" with the following url http://intranet.dev/timesheets/Pages/default.aspx.
I then added the following web parts to the page:

All the web parts are connected web parts (To connect the web parts, when the page is in edit mode,click the button to edit).

﻿Create the popup page that is linked to on the page just created.

Ensure that the "New task" & Edit task links are working.

Create a new Administrators page, add the "Admin - Main" web part to the page.﻿

﻿Check the following 3 web.config settings and create the appropriate pages, each page has 1 web part as shown below.

You need to open you ULS logs (or use ULS viewer) in notepad. Find the correlationid that you have posted, then send me the log. This will give you an indication of what the issue is with the BookTimeItem web part.

Pls ensure you have the appropriate read/write permissions on the database for the IIS app pool account. If your other web parts are working (getting data from SQL) than this is not your issue.

Thanks for the quick response. The initial problem was permission, but I sorted that out by creating a specific user and modifying the web.config. However, I'm still getting an error with the BookTimeItem part.

This error appears, when i modify the BookTimeItem acsx.cs;when I add OrDefault to .Single

System.NullReferenceException: Object reference not set to an instance of an object. at PaulBeck.Timesheet.WebParts.BookTimeItem.BookTimeItemUserControl.Page_Load(Object sender, EventArgs e) at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.AddedControl(Control control, Int32 index) at PaulBeck.Timesheet.WebParts.BookTimeItem.BookTimeItem.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Hello Paul,I am having the same problem with the webpart BookTimeItem. You describe having the proper seed data in the tables. Can you provide some additional deatail. I have put some dumby data into those table from SQL Manager but it has not changed the result.Any help is much appreciated.Thank you,Craig

Hello Paul,Thank you. That was partly the problem. I purged the tables and repopulated them with new data, making sure to pay attention to all the keyIDs and have the main screens working. This would be the TimeSheet and the Adminstrator screens.

However, I still have a snag on the launching of the popup screens from the javascripts like getDDLClient, getDDLProject, OpenDialogAdr, etc.

All of the popup screen have an Error. There is Correlation ID: but I have not been able to find the that it is writting to the log file into log files in .../Web Server Extension/14/LOGS. I have to appologize. I am not a Sharepoint Developer so I may need extra explaination.

I am suspecting that there is a path issue (myurl) in the Javascripts that is causing this problem. Can you guide me as to where this can be corrected? Thank you in advance.Craig

I'm having an issue with your code. I'm tracked down the problem: when opening up a ModalDialog, the querystring attached to the url has ampersands. These ampersands don't get escaped for some reason and as a result, Sharepoint chokes on it. I tried hardcoding escapes in, but for a dialog, Sharepoint appends &IsDlg=1. The url doesn't escape it and so Sharepoint chokes on it. Any ideas?

Once you have the ULS logs open either using ULS view or notepad (ensure you have the latest ULS file) open the file 2 minutes after getting the error and do a find in the ULS file for the correlation Id (Error Id) you receive. It will be there 100%.

Pls provide additional information:Is you problem for all ModalDialogs? (Specify which ones)Does this problem occur in various browsers?What is the error? Add more detail to the process and error so I can take a look.

The problem is for AddProjectResourceUserControl and BookTimeUserControl. It occurs in both IE 8 and Chrome. After looking at it more closely, I've refined the cause of the error, I think. The error is:

When calling SP.UI.ModalDialog.showModalDialog(options), the . For instance, because Sharepoint does not like the '&' symbol in URLs, the URL for Timesheet Add or Edit should be:

And instead of opening a ModalDialog, I do a window.open(options.url). This allows the application to work somewhat, but callbacks for refreshes don't work with this method.

Please let me know if you need more information. Your solution is a huge timesaver and is well made and I thank you for it, this little issue has been giving me a bit of a headache, though... I really appreciate your help.

If you are getting an application error on all you popup pages, ensure you are using the correct page types that contain the Dialog Framework. For more info see: http://ranaictiu-technicalblog.blogspot.com/2010/06/ribbon-tab-with-id-has-not-been-made.html

If you get:Unexpected System.ArgumentException: The Ribbon Tab with id: "Ribbon.Read" has not been made available for this page or does not exist. Use Ribbon.MakeTabAvailable(). The pages you are using do not have the dialog framework available, see http://ranaictiu-technicalblog.blogspot.com/2010/06/ribbon-tab-with-id-has-not-been-made.html

Thanks a ton for your solution.Regarding the exception "Sequence contains no elements" raised when the Timesheet-BookTimeItem webpart is added, you gave 2 solutions.

1.Proper seed data should be filled in all tables - I filled the data, but still it gives an exception.Do you have any sql file which generates the seed data needed to add this web-part with out any trouble?

2.Ammend the LINK method from .Single() to .SingleDefault(). Or put a try catch block around this code - I have added your timesheet solution using the wsp file that you have provided.In which file should I make this change?

I am sorry if I ask you too naive questions.i am still in the process of learning sharepoint !

The solution is meant as a base to build a timesheet solution hence the project files are downloadable however you can use the wsp's but you need to get your seed data correct. The issus people hit is that the foreign keys are not correct.1.> Good suggestion on the base data, I look into providing data for the soluttion.2.>You ned to compile you own code/wsp to use .SingleDefault so unless you use Visual Studio, thei isn't an option for you.

Thanks for this walk through. I am a novice at this and I would like to ask a question. Using SP Foundation you say to create a new Publishing site. SP Foundation however doesnt have publishing infrastucture. So just creating a new blank site instead as the first page and adding the web parts as per your instructions above, when I try and connect the web parts I get a long page error.

I believe that I have created all of the databases etc but it is this first part that I cant seem to get past.

I really appreciate your efforts as well as the others who have contributed to this effort. I am not a programer, but someone looking for a time card solution in Sharepoint. Specifically, Sharepoint on MS 365.

It does not appear that the solution that is provided here will work. Any suggestions?

This solution will not work on SharePoint Online (SPO) (Office 365), it is an on premises SharePoint 2010 solution. Could be a good project for a programmer to make it SPO ready however I have no intention of making this available on SPO.

I am having a bit of a problem setting this up. I haven't done too much programming with SharePoint and I was thinking about implementing your solution to see how it works.

Basically I have done everything up until Part 4 but I keep getting an "Unexpected Error Occuring". I have tried looking in the ULS logs and my error message is below. Do you have any idea why this is happening? Is the connection to the databse not working?

Thanks for the reply. I have changed the connection string and am no longer getting any error, however, nothing shows up in my consultant or any of the other drop down menus. (I have populated each one of the sql tables with one value, so that should show up right?) Would the connection string still be the problem here? I followed this guide to get the correct connection sting information: http://www.gotknowhow.com/articles/test-a-database-connection-string-using-notepad

Also, I am confused how to create the pop up pages. I have added the code in the web config as highlighted but what's next? Sorry if its a super simple answer but this is something I can't seem to get right.

EDIT to my previous post, I don't think the connection string is the problem. I have added some of the Admin web parts and I can see my values in the drop downs and can add new Clients and Projects to the database so the connection string is working fine BUT I still can't see the Consultant drop down options and I entered a record in the Resource table. Any idea why this is?

Connection string: It sounds like your connection string is now fixed, as you are not getting an error this sounds proven to me.

Consultant dropdown: Works by checking is the current login user is a site collection (SC) administrator, if you are it will show all records in the resources/consultants db table. If the logged in user is not a SC admin, you will only see your own timesheet and details in the ddl. Key is the logged in user name needs to match the value in the db. If you look at the source html for the drop down consultant list, are there any values? If so tell me the text and value.

Popups: The web.config dictates the path to the popup pages. So for each web.config entry the corresponding relative path needs to be added. Also note that the path is from the web app for the web.config entries not from the SC url.

Thanks for the reply and all the help Paul. The connection string is definitely fine, as I created the admin page, the drop downs work and I can insert a client into the database. I also figured out the popup pages! :) I didn't want to send another post with that update but I ended up figuring that out.

Currently I am logged in as the Farm Administrator for SharePoint, and this is in my test environment. I have another user that I tried logging in with that is just a regular Domain User. So when I am logged in as Farm Administrator I should be able to see all users right? But I can't see any and I have entered my Domain User's name into the Resource Table but I still can't see him in the drop down. All the drop downs work for the Admin web parts so I'm not too sure what I did wrong here.

One other issue I am having is, as many others have posted, with the BookTimeItem web part. Basically I wanted to take the route to edit the code but I have no idea where to add the .SingleDefault(). I have extracted the .wsp package and have looked through the files to find where the .Single() method is being called but I can't find it.....am I doing something wrong? I have never created or modified a .wsp package before so thanks for any help on this. Editing this method name should then fix the issue with the BookTimeItem? Or should I repopulate the database?

Tudor: "So when I am logged in as Farm Administrator I should be able to see all users right?" Paul: CorrectTudor: Farm admin can't see al users.

Paul: "The farm admin shows up as the 'System Account' so the resource/people picker does not work, ammend the user in the table. If you are a site collection administrato you will see everyone, I suggest explicitly adding the farm account as the SC admin".

Tudor: " .SingleDefault() fix". Paul: "Code change is if you are editing the timesheet programtically in VS, you aren't so you fix is ensure your data in the SQL Server datbase tables are correct."

Note: This is not a commercial project but guidance for creating a timesheet in SharePoint, so you need to work through all these issues such as populating the SQL Server tables with the correct data.

Ah I figured it out, basically the tables that need to have some data inserted are: Clients, Project, and Resource, the rest will be automatically populated by the web parts when timesheets are filled out. I had entered some data in the other tables and that's what was causing the errors so I removed that data and it all works now and it pretty cool haha. Thanks Paul! And thanks for all the help! I'm going to try and expand on it but this was a great start, thanks a lot!

Managed to get everything working ish, apart from after getting the screens to show once i can no longer get on to them. i get the unexpected error occured. in ULS the error is

System.NullReferenceException: Object reference not set to an instance of an object. at PaulBeck.Timesheet.WebParts.Week.Week.get_GetWeekId() at PaulBeck.Timesheet.WebParts.BookTime.BookTime.ReceiveProvider(IWeekId p)

The project is made for customisation, hence no error catching is added to the code. You appear to of missed a step. I'd suggest you walk through the tutorial/posts again. You error is causes as the underlying database is missing entries that relate to one another.

Hi Paul, i have gone through all the steps again, and believe everything has been done. i can access the admin pages ok, i have a list of consultants, a couple of projects and clients. i can create projects via the site. but unable to add tasks. Anything else you suggest... very frustrated, so close yet so far...

I'm kind of lost with where you are up to. If you have followed all the steps, log how you get each error, include the error message and additional info. I'd suggest you run in debug mode, it makes figuring ou the issue a lot easier.

only thing not working is the timesheet-add-or-edit.aspx webpart booktimeitem. it does not display any day information in the ddl. the timeshhe week webpart on the home page is now working along with the rest of the items.

ok. sorry for being nieve at this point, but i cannot see any where for debugging...

i have noticed in the dbo.dayentry table which it has now autopopulated after adding some seed data, is that although i have week id 1,2,3 etc and day number 1-7 which makes sense. i have duplicated daydates. for instance i have 3x 2013-02-18 same daynumber but different weekentry id? is this correct?

Hi Paul, Please excuse me if I sound silly. I have made changes to web.config. In the last part of your write up, you have added web parts on the site page. I have created a site, but I cant see anything under web parts to add. Do I need to upload any web part first?

I am having the same problem with the webpart BookTimeItem.I've filled proper seed data manually in all the 7 tables in SQL Server. Amended the LINQ methods from .Single() to .SingleToDefault() of all occurences in BookTimeItemBOL.cs file. Then redeployed the package using "Install-SPSolution -Identity paulb-timesheet.wsp -WebApllication http://esystfs:8138 -GACDeployment -force" cmdlet in Powershell. Finally, embedded this webpart in a new page and not in a webpart page.

Have I done anything wrong in any of the above mentioned steps? I am sorry if I ask you too naive questions. I am still in the process of learning sharepoint!

Download the Visual Studio Solution file, remove the tfs binding and then you work on the code, this allows you to create the new wsps with code changes and your own customisations. Once you have done this and created the wsp's and deployed the wsps - it should work. If it doesn't give me the error message so I can help you figure out what is wrong.

This is a great post. Thanks much. I have added all the webparts. i am done with all steps. I am getting the below error message:

[NullReferenceException: Object reference not set to an instance of an object.] PaulBeck.Timesheet.WebParts.Week.Week.get_GetWeekId() +84 PaulBeck.Timesheet.WebParts.BookTime.BookTime.ReceiveProvider(IWeekId p)