Pages

Monday, June 15, 2009

Visual Studio 2005/2008 Sharepoint Workflow with Active Directory

Hello Friends

Business Case:

In Project, Requirement is like develop one workflow steps like

 1>     Create task and Assigned To is its manager which is decided by Active Directory

2>     Tasks are created like Originator à Project Manager à Director àDeputy à Superintendent. (Means we have to go to that level until whose manager does not exit.)

3>     For every user we have to create one task .If it is approved or deferred we have to send mail. If it is approved we have to send mail to person who has created task for the manager and create a new task for next level.

4>     Now if a person does not look at that task up to some duration we have to send email to person for overdue task and extend its due date for one day.

5>     If person deferred task workflow must be terminated. And email also sends for task is deferred or cancelled.

6>     Main requirement is that we have to search for manager from Active Directory.

Solution:

Develop a Sequential workflow.

Let us go into detail

1>     Create new project Project Type Sharepointà Sequential Workflow.

2>     Now Select activity that is “TaskCreated”.

3>     Then we have to add one while activity where we put one condition check that manager name is empty or not and if not then workflow must be stopped.

4>     Now there is one limitation of while activity is we add only one activity under while activity so I add one sequence activity and in that I add conditionactivitygroup there.

5>     In that I add one activity which is “CreateTask” Activity .Then on I add “OntaskCreated” Activity.

6>     Then I have to do like when task status changed from not started to Completed or Deferred we have to wait So I add one condition activity group which has condition like up to taskiscompleted == true.

7>     In group of activities I took 2 Sequence Activity. First Sequence activity is as under


























 8>     And another one is as follows.








































9>     In last once again we have to write one code activity which takes managername of current user.

10>  Workflow is completed

11>  How we can take manager name from Active Directory.

For that we have to use one directory Add reference

using System.DirectoryServices;

and also for regx you have to use

using System.Text.RegularExpressions;



        private string getManagersName(string employeesName)

        {

            string managersName = string.Empty;



            // Strip off the domain reference: eg: somecompany\\someusername. "somecompany\\" is the domain reference

            string cleanUserName = employeesName.Substring(employeesName.LastIndexOf('\\') + 1);



            // Setting the Active Directory folder to the root foler

            DirectoryEntry adFolderObject = new DirectoryEntry();



            // Creating the AD Searcher Object

            DirectorySearcher adSearcherObject = new DirectorySearcher(adFolderObject);



            // Setting the Search Scope to the AD Root tree and the subtree

            adSearcherObject.SearchScope = SearchScope.Subtree;



            // Get the UserName of the person who uploaded the document from the Document Library

            employeesName = workflowProperties.Item.GetFormattedValue("Created By");

             cleanUserName = Regex.Replace(employeesName, @"<(.|\n)*?>", string.Empty);



            // Set the Active Directory Search Filter to the, now stripped, username

            adSearcherObject.Filter = "(CN=" + cleanUserName + ")";



            // Execute the Active Directory Search

            SearchResult adObject = adSearcherObject.FindOne();



            // The Active Directory Search will return several properties for the Manager Object.

            // Store them in an array

            string[] properties;



            // Ensure that the user has a value in the Manager field

            if (adObject.Properties["Manager"].Count > 0)

            {

                // The properties are "," delimited, so we will split the properties on that character

                properties = adObject.Properties["Manager"][0].ToString().Split(',');



                // The Manager Name field starts with "CN=...", so stripping that off leaves us with the

                // Managers Name

                managersName = properties[0].Substring(3);



                // Get the Domain of the Users Active Directory Root

                string domain = adFolderObject.Name.Substring(3);



                // Convert the manager string to a SPU User Field

                managersName = workflowProperties.Web.AllUsers[domain + "\\" + managersName].ToString();

            }



            // return the managers name or an empty string, if there is no manager

            return managersName;

        }



12>  Second thing When you have list field type as “People Or Group” if you access fieldvalue and you want that thing display as “domainname\username”.You must have to use

employeesName = employeesName.Substring(employeesName.IndexOf(@"\") + 1);



13>  When you want to access some users which are in list and you want to use that name in task assigned list so you have to do one change and that is go to that edit that column and make Show Field as “Account”.







































Now I will give you concept wise description.

ConditionedActivityGroup:

The ConditionedActivityGroup activity is a CompositeActivity, meaning the ConditionedActivityGroup activity is group of other activities. The ConditionedActivityGroup activity runs and re-executes child activities based on the evaluation of their when conditions. All rules are evaluated whenever required based on their data and state change dependencies. All of activities until an until condition is true of ConditionActivityGroup.

UntilCondition = this._IsTaskCompleted == True

SequenceActivity :

The SequenceActivity is a CompositeActivity, meaning the SequenceActivity can contain other activities.

The SequenceActivity class coordinates a set of child activities in an ordered manner, one at a time. The SequenceActivity is completed when the final child activity is finished .There is one when condition is attached with Sequence Activity. If we do not specify that condition then it executes all activities under Sequence activity one at time but if we wish to executes all activities must run under some condition we can specify that thing under when condition and when it is true then and only then all activities run.

First Sequence Activity When Condition : None

Second Sequence Activity When Condition : this._IsTaskCreated == True && this._IsTaskCompleted != True

DelayActivity:

The Delay activity causes the containing branch of the workflow to wait for a specified amount of time

I need that otherwise workflow goes into infinite loop I have to tell workflow to wait for 2 minutes. Then check code condition for due date.

95 comments:

  1. Hi Disha

    I am new to Sharepoint. I have couple questions in document library and Ajax with sharepoint.

    1) Document Library
    I am uploding the documents in sharepoint document library using custom webpart(Bulid in C#). But the documents are stored in document library with status "Draft" . That should be stored in the doc library with approve status. So for this what change i have to do in my coding. Already i tried with checkin/checkout. I am using below code for uploading

    using (SPSite siteCollection = new SPSite(siteUrl))
    {
    using (SPWeb spWeb = siteCollection.OpenWeb())
    {
    SPDocumentLibrary doclib = (SPDocumentLibrary)spWeb.Lists[ConfigurationManager.AppSettings.Get("DocLib").ToString()];
    SPFolder root = doclib.RootFolder;

    Byte[] fileContent = null;

    fileStream = File.OpenRead(FilePath);

    fileContent = new byte[Convert.ToInt32(fileStream.Length)];
    fileStream.Read(fileContent, 0, Convert.ToInt32(fileStream.Length));
    spWeb.AllowUnsafeUpdates = true;
    root.Files.Add(strSelectedFolder + "/" + FileName, fileContent, true);
    }}
    2) Ajax
    If i will use custom coding for implementation of ajax in sharepoint, then it works in custom master pages and custom pagelayout screens. But its not worked in userpages (I mean default.master,bluband.master)

    Thanks in advance

    ReplyDelete
  2. Hi
    Thanks for Comment.
    Now, Answer related to your first question.
    1. I think you need to change your document library settings from the GUI and when you upload your documents through code, it will store in Approve stage.
    Can you please try below things from SharePoint site and try to upload documents from code?
    1.1 Go to your document library list
    1.2 click on settings->document library settings
    1.3 click on version settings under settings section
    1.4 First section which says require content approval for submitted items, check "NO" and click on SAVE
    1.5 now uploads your documents

    If this won’t work then I’ll see from coding point of view,
    2. for Second Question
    If you open any master page which is related to publishing Portal Template you find this tag





    You NEED to make CHANGES for Enabling AJAX with this






    NOTE: Master pages structure is different which are related to Publish Portals and Other Site Templates (Like TeamSite, blankSite) Etc...
    Thanks and Enjoy
    Disha Shah

    ReplyDelete
  3. Hi Disha

    Thanks for your feedback. Now i am able to upload the document and it is visible to all the authenticated users. But we are facing one more issue, the old documents which are in draft status are viewing to only to that user who is uploaded that one. Are we able to make public those documents?

    Regarding AJAX.still now i am not clear. Can you provide any small test application, for the same. I have to create custom webpart and it should implement AJAX. i have to add that webparts in system defiend pages. Piease of code whih is i used for "checking script manager" is as follows. But it throws the error.

    protected override void OnInit(EventArgs e)
    {
    base.OnInit(e);
    try
    {
    EnsureScriptManager();
    EnsureUpdatePanelFixups();
    }
    catch (Exception Ex)
    {
    this.Controls.Add(new LiteralControl(Ex.Message));
    }
    }

    private void EnsureScriptManager()
    {
    ScriptManager ajaxScriptManager = ScriptManager.GetCurrent(this.Page);

    if (ajaxScriptManager == null)
    {
    ajaxScriptManager = new ScriptManager();
    ajaxScriptManager.EnablePartialRendering = true;

    if (this.Page.Form != null)
    {
    this.Page.Form.Controls.AddAt(0, ajaxScriptManager);
    }
    }
    }

    private void EnsureUpdatePanelFixups()
    {
    if (this.Page.Form != null)
    {
    string formOnSubmiAtt = this.Page.Form.Attributes["onsubmit"];
    if (formOnSubmiAtt == "return _spFormOnSubmitWrapper();")
    {
    this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
    }
    }

    ScriptManager.RegisterStartupScript(this, this.GetType(), "UpdatePanelFixup", "_spOrginalFormAction = documnet.forms[0].action", true);
    }

    ReplyDelete
  4. Hi Sai,

    You need to publish your all old documents from draft to publish status, so then all users can see those documents, if you are using “Publishing” site templates, then there is some way from which you can get reports of all draft documents and you can publish them all by clicking only one button. But again, these all are manual steps to make old documents available to all users.

    Can you please give me some more detail description for what exactly are you looking for AJAX implementation into SharePoint?

    Thanks,
    Disha Shah

    ReplyDelete
  5. Hi Disha

    Thank you. Even i able to implement Ajax. Now i am facing another problem. I have a site in sharepoint, which has one document library is there. I need to access those documents in asp.net site. While i request fro document from asp.net site (e.g. Like this http://servername:port#/documents/test.pdf), it asks credentials. I want that document should open directly(With out credentials). Is there any way to archive this.

    Advance thanks.

    Sai

    ReplyDelete
  6. Hi Disha,

    How can i insert a Bulk data into Sharepoint List..using coding.

    Thanks in Advance.


    Regards,
    Nitin

    ReplyDelete
  7. Hey Nitin,

    There are many ways to insert bulk data into SharePoint list using coding, it’s depend on case to case basis, like what will be source of bulk data, it’s from database or any other flat file, etc …

    In general scenario - You can take data into datatable or recordset and loop through your records and insert into SharePoint list by ListItem class/methods.

    Can you please give some more idea about your requirements?

    Thanks & Reagrds
    Disha Shah

    ReplyDelete
  8. Nitin,

    You can also do one thing, you can write web service call to your SharePoint list and use LISTS web service to update/insert bulk data, you need to generate your XML nodes with all your required SharePoint list columns and values and then pass same values to LISTS web service/methods.

    Thanks,
    Disha Shah

    ReplyDelete
  9. Hey Sai,
    You can try to write with two options.
    1> Your code between spsecurity.runwithelevatedprivileges delegates.
    2> try to pass current credentials by using this class “System.Net.CredentialCache.DefaultCredentials” to the SharePoint site/document library.
    Ideally speaking, the user who is trying to open documents from ASP.NET site needs to have correct access privileges into SharePoint site also. So I prefer to use “System.Net.CredentialCache.DefaultCredentials” option.

    Thanks,
    Disha Shah

    ReplyDelete
  10. Thanks Disha.

    I have implemented the Bulk insertion in Sharepoint List by creating XML with "Batch" node and passing that XML to ProcessBatchData method.

    Thnaks a lot.

    Regards,
    Nitin

    ReplyDelete
  11. Hi Disha

    Thanks its worked.
    One more question :)

    In my sharepoint site already one content type is there. That content type consists one column(dropdown). My requiremnt is, i have to fill that column with items which will come from external data base(e.g. Oracle). So how can i achive this. Please help. Thanks in advance.

    ReplyDelete
  12. Hi Sai,

    It’s good to hear that it’s worked!!!


    Now regarding your question – I have general idea about how to achieve that …

    I think there are different different ways for meeting those requirements.


    1.

    1.1. Write ADO.NET code to connect your external database (oracle) and make a record set (data table or any other) which returns the values which you are looking to fill into drop down of content type.


    1.2 There are many classes into SharePoint object model which gives facility to play with Content Types, Class Name called “SPContentType” and you can also get specific content type from LIST by doing “LIST.Content types” ….. Try to take the content type into your code and assign values from your data table which you already filled from oracle database.

    2. You can also create BDC data connection which has connection to your external database entity, and into your code you need to take your SharePoint site SSP and BDC entity which you created for oracle database to get the data from oracle – here we are trying to achieve step # 1.1 – for filling data.


    Then you can go with step # 1.2 to assign values to content type.


    You need to look for exact class name and syntax for content type…

    I hope above answer give you some idea to start with your work.

    Good Luck!!

    Disha Shah :)

    ReplyDelete
  13. HI Disha,

    ther is a requirement from Client like, From drop down he can select a cityname once he selects the city from list and click on submit, data has to be save with cityname and his details. After that once this request is done mail has to go to the requested person as well as Administrator....

    So i am planing to insert this data into Task list and assign the workflow to send the email....but i am not getting succeed while doing cutoms workflow using Visual studio. If this approach is correct could you pls tell me how can i go ahead with this.

    Thanks in Advance.

    ReplyDelete
  14. Hey Nitin,

    Please let me know, do the client need any kind of approval or rejection into your list?

    If not then you can go with Event handler approach without creating workflow like when you add Item, on ItemAdded event, write a code for sending email to people and provide some link to Administrator in email so he can response back to that from email..

    Yeah, you can do same thing with SharePoint Designer workflow as well as also Custom Visual Studio Workflow. It’s all depending on what are exact requirements for workflow.

    Can you please tell me what your exact problem is? You are not able to add task in task list or not able to send email or problem with deployment of workflow or when it started it gives error like "failed to start" or some another error (clarify me on this so I can help you out)?

    FYI: For sending email you need to configure farm settings for outgoing email with your smtp server, when you deal with workflow please be careful with correlation token.

    Thanks,
    Disha Shah

    ReplyDelete
  15. Exact requriement is,

    1)External user will make a request For perticular city

    2)After request, mail need to send to Administrator stating that there is a request from external user as well as mail need to send to Requested person(External user).

    3)Administrator can Approve the request or Reject the request.
    once approve the request mail need to snd to external user and data need to insert in a list.

    Thanks in advance

    Regards,
    Nitin

    ReplyDelete
  16. Disha,

    Can we add buttons in list like in grid we can have button int each row?

    Is it possible in list to add buttons in each row?


    Thanks in adavance

    Regards,
    Nitin

    ReplyDelete
  17. Nitin,

    Can you please let me know which list are you talking about? Is it Custom list or any type of custom or out of the box web part?

    One thing you can do, you can use SP Grid View control into your custom code instead of normal ASP.NET grid control and you can include all functionality of normal SharePoint list menu into SP Grid View control, it’s same like if you see display form of any SharePoint list.You can use SPMenuItemTemplate for that.

    Once you will use SP Grid View control then you can also add buttons into each row …

    Thanks & Regards
    Disha Shah

    ReplyDelete
  18. Nitin,

    By Looking at your requirements, I think SharePoint designer workflow is easiest, In designer workflow you need to add each steps and take respective activity like “Send Email to User” for sending email to administrators and users, then for approving or rejecting items, you can take “collect data from user” activity and so on …..

    Deployment in SharePoint designer workflow is not easy, here are limitations for designer workflow http://sanketinfo.wordpress.com/2009/05/05/limitation-of-sharepoint-designerspd-workflow/,
    and you can also create same workflow in visual studio and use feature to move visual studio workflow from one environment to another environment.

    Thanks & Regards
    Disha Shah

    ReplyDelete
  19. Disha,

    I have doubt while implementing permissions for each users

    Below is the requirments.

    1)THere will be two users, admin and End users(will be Many)

    2)End user will make a request for particular document. Once he make request data will insert in to one MasterList say "DocumentList"

    3)In this list i am storing the info users with his Email id, login id, and Document Name

    4)Admin will approve this request, for this iam just creating custom webpart.

    After that End user will login for whom admin has approved.
    Once he loggedin he should see the entry in his list.

    But second end user should not see his entry because he has not make any request for this.

    5)Finally it means that Each users should see there approval document in there list.


    Now my requirement is that
    i wanted to display the master list data depends on the logged in Users.

    I wanted to select data based on the users login.

    How can i do that? Please suggest how can i achieve this.

    ReplyDelete
  20. Hi Sai,

    Can you please provide the code for opening documents from asp.net site? I am struggling to get this working without getting asked for credentials. My application search a document library in Sharepoint and lists the document in a grid. When the user clicks the document they get asked for credentials. The url to the document is something like http://servername/documents/test.pdf

    ReplyDelete
  21. Hi Nitin,

    If I understood your requirements correctly, then you want to display data from some list called "master list" depends on logged in users , I mean if userA created two records out of five records into custom list, then you want to display two records when userA login into SharePoint site.

    For achieving above requirements, you can create custom view into SharePoint list and mark created custom view as "Default" view for all users, now into custom view you can put filter criteria by specifying username as [Me]. That mean it will display all the records created by logged in users.

    Hope it will help to you.
    Thanks,
    Disha Shah!!

    ReplyDelete
  22. Thanks Disha..

    It helps for me.

    ReplyDelete
  23. Hi Disha

    Can i fill a custom list from external data base. But that list alwasy connected with that external db table. If any change will occur in external table, than automatically list should update. How will i acive this.

    One more question, i created one custom field in sharepoint. Its working fine. But in column defination it should display to owners group. is it possible. Column defination means, while you click create column it shows types of coulm like (Single line text, Multiple Line text, also my custom fields). On that screen it should disply to only owners group.


    Thanks in advance.
    Sai

    ReplyDelete
  24. Hi Sai

    Yes you can fill custom list from any external database with writing code to access DB directly or with BDC code you can achieve this …


    But I think you have to write code to update your list automatically which will synch with your external database. It’s depend on which external database you are trying to connect, you can also write SharePoint timer job which will go into your external database on specified time and update your SharePoint list with your updated records, there are different type of solution to achieve functionality.


    For your second question regarding displaying custom field to owners group, I am not following you correctly, do you mean that your custom field which is displaying on create new column page – will display or visible to people who are in owner group? Please correct me if I am misunderstanding.


    I am not sure that whether you can do that or not, I am thinking that you can check current user into your custom field and display/visible your data type based on owner group. Even if that’s just my idea.....


    Thanks,
    Disha Shah

    ReplyDelete
  25. Hi Disha

    Thanks For your reply.

    I succeed in my first question. Regarding second question you are correct, i require this funnctionality in create column page. coulmn defination, which is devloped by me should display to owner group only. That is the requirement.

    One more question :), I never developed any workflow in VS 2008. I devloped in sharepoint designer, but with sharepoint designer features, my requirement is not full fiiled. Becoz through designer we can't achive looping. I have a requirement now. There is issue trcker list is there. ASA admin will post one issue than "asigned to" fellow should get one mail that one issue is assigned to you. Than assigned fellow should approve or reject the issue. If he approve the issue, that he should confirm - Due date is ok or not. At last assigend fellow update the taske with complet staus. If assigned fellow reject the issue, than admin should reassign to any body. Than once again steps will go. At last work flow should complete.

    Thanks in advance

    Sai

    ReplyDelete
  26. Sai,

    That’s great you got success in your first question.

    Regarding second question, as I have explained you that please try to see whether you can write custom code to check current user into column definition or not..

    I understand your requirements regarding workflow, I am not sure what exactly you are looking from me, but you can take reference from below link for visual studio workflows.

    GOOD WORKFLOW LINKS:

    http://sheltonblog.com/archive/2007/11/21/how-to-video-building-a-basic-approval-workflow-with-sharepoint.aspx

    http://rshelton.com/Tags/Workflow/default.aspx

    Thanks!
    Disha Shah

    ReplyDelete
  27. Hi,
    Dishashah I'm new SharePoint, I want display display records in Grid When the page load in SharePoint. Which event I use, Please..

    Thanks

    Govindaraj

    ReplyDelete
  28. Hi GovindaRaj,

    If you are displaying records in grid into custom ASPX page then you can write your code into page load event, and you can also write your grid code into different events as per your requirements like you can also trigger your code on button click on something else .

    Please let me know if you are thinking to achieve something else with grid!!

    Thanks,
    Disha Shah

    ReplyDelete
  29. Hi Disha,

    I want some sample coding about AspMenu for sharepoint
    ex.
    File
    New
    open

    K. Govindaraj

    ReplyDelete
  30. Hi, Disha
    I Create one button in Sharepoint Designer, I want to write the coding for button in Sharepoint Designer, when I click the button it will display some text, how to write code. Please

    Govindaraj. K

    ReplyDelete
  31. Hi Govindaraj,

    You can use SharePoint:AspMenu and to display menu items, you can use “asp : SiteMapDataSource”. Try to search on both these things and fulfill your requirement.

    Thanks!
    Disha Shah

    ReplyDelete
  32. Hi Govindaraj,

    It depends on your requirement of your button click, if you just want to do validations you can use JavaScript as you write in any HTML or ASPX page, and if you have any long and complex Requirement, I will prefer go with Web part.
    Sample code for writing PAGE LOAD event into SharePoint Designer:






    protected override void OnLoad(EventArgs e)
    {
    Response.Write("This is from the onload event");
    base.OnLoad(e);
    }









    Thanks and Regards
    Disha Shah

    ReplyDelete
  33. Thank you, Disha Shah

    Govindaraj K

    ReplyDelete
  34. Hi, Disha

    I Designed one form in SharePoint Designer, textbox and buttons.
    When I type text in the textbox, and it want to store in the SQL Database.
    can you help me to do this. Only in SharePoint Designer.

    Govindaraj K

    ReplyDelete
  35. Hi Disha,

    I have created a Task edit form in ASP.NET, But when i try to access this form with following url
    "http://servername/CustomApprovalForm/DesginApprovalForm.aspx" i am getting following error

    "The virtual path ‘/_catalogs/masterpage/default.master’ maps to another application, which is not allowed "

    I have tried with creating ASP.NET application using HTTP as well as FileSystem. But still i am facing same problem.

    Even i have changed the settings in IIS under _layouts folder by setting application name to Root...But still same error

    Could you please suggest any solution to resolve this issue?

    Thanks in advance

    Regards,
    Nitin

    ReplyDelete
  36. Hey Govindaraj,

    I don’t know for which reason you want to do programming with SharePoint Designer, I think it’s not possible or little bit difficult to write complex programming into SharePoint Designer Pages. If you find any way to do so then please share with me, thanks!

    But in my opinion you can do this thing – create one ASPX page and write your saving of data code into ASPX page, put same page into _layouts folder, so in this way, you can open your ASPX page from SharePoint site.

    OR

    You can also create one web part and put your logic which will save data into SQL Server inside web part.

    ~Disha Shah

    ReplyDelete
  37. Hi Nitin,

    Can you please let me know that where you put your ASP.NET created ASPX page, I mean which directory or how you deploy your page?

    If you want to see your ASP.NET created ASPX page into SharePoint site, then you have to put that ASPX page into 12 hive/layouts folder directory then you can access your page from http://yoursharepointsiteurl/_layouts/aspnetaspxpage

    I think it’s nothing to relate with IIS settings or how you created your ASP.NET page, the things here is how you deploy your ASPX page into SharePoint site.

    I hope that from above information you can get some direction to work on!!

    Disha Shah

    ReplyDelete
  38. Hi,
    First of all i thank you for this good effort...
    I have wrote a workflow coding for approval... In a task list user will provide the data at once it will mail to TL and after TL approval it will mail to VP..
    For this case i want to get the TL name from user.. the user will add the TL name in the Task List while adding the task.. I tried with code like.
    createTLapprovaltask.TaskProperties.AssignedTo = workflowProperties.Item.GetFormattedValue("Assigned To");
    But it is showing that error occured.. If i define a user in the code it works fine... What may be problem... Pls provide a suggestions...
    Regards,
    Siva..

    ReplyDelete
  39. Shiva

    As you know "Assigned to" field is user and group field type,
    Go to Task List Settings and "Assigned To" Columns settings, there you can see "Show Field" property at the bottom. Check what you have selected there, if it is Name(with presence) you need to add domain name in your coding, Or you can change showField value as "Account" rather than Name(with presence)

    Hope this solves your problem.

    Thanks
    Disha Shah

    ReplyDelete
  40. Hi Disha,
    Thanks for your response...
    I followed your advice and got the needed things..But now im facing an error with mail sending..
    When the user is assigned the task email must be send... At that instance an error meaasage "The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly."
    I tried lot of things for this but no use... What to do for this any ideas...?

    Thanks in Advance..
    Regards,
    Siva...

    ReplyDelete
  41. Hi Siva,

    There are couples of issues for error "The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly", as you know mainly it’s related to SMTP email configuration settings.

    Please try below initial setup reference link.

    http://technet.microsoft.com/en-us/library/cc262947.aspx
    http://technet.microsoft.com/en-us/library/cc263462.aspx
    http://searchexchange.techtarget.com/tip/0,289483,sid43_gci1308762,00.html


    You can also try one more thing – write object model code which will send email to any user and check whether you are getting any errors or not.
    E.g. SPUtility.SendEmail (SPWeb, Boolean, Boolean, String, String, String)
    Thanks,
    Disha Shah

    ReplyDelete
  42. Hi Disha,
    Actually there was a problem with the ISP ports.. The port was blocked due to some firewall issues. Now that issue was cleared and mails are sent. But there arise another problem. What i designed in my workflow is for an approval by TL and then VP. When new item is added mail will go for TL and if TL approves it mail will go for VP. If TL rejects mail wont go for VP.. i.e. multilevel approval workflow.. Now when i tried it mail is going for TL but when TL approves it mail is not going to VP what may be the issue.. Is there any way to check it..
    Thanks in advance..
    Regards,
    Siva...

    ReplyDelete
  43. hi dish, u r blog is super. i is very useful .i am new for sharepoint. pls send more programs on workflows.plsssssssssssssssssssss

    ReplyDelete
  44. Hi Disha,

    Hope u r doing good.
    The article u have written is very good. Thanks.

    My Question :I am lost in writing code which combines code with events and tasks in sharepoint sequential workflow. I have to write Document approval workflow process for a document library using sharepoint sequential workflow + visual studio 2008. I completed design but confused in writing code for events. Can u help me please?

    Thanks in advance.
    Vani

    ReplyDelete
  45. Mahesh

    Thanks for appreciation.

    Which kind of workflows Programs you need? Are you looking for Sequential or state Machine Workflows or SharePoint Designers?

    I can send links depends on your requirement or if you start with your workflow and stuck anywhere let me know.

    Thanks
    Disha Shah

    ReplyDelete
  46. Vani

    Did you complete your design in Visual studio or are you ready with your steps?

    If you put every Sequential workflow activity, and double click on that it will generate one event handler associated with it.

    Please refer these links.
    http://msdn.microsoft.com/en-us/library/cc936628.aspx
    http://www.codeproject.com/KB/WF/sharepointworkflow.aspx

    Thanks
    Disha Shah

    ReplyDelete
  47. Siva

    Check that VP has valid email Address, and what you written for send email ? you achive that portion with SendEmail Activity or by code Activity?
    Make sure whatver you have written for TL for sending email, same thing will repeat for VP for sending email if TL approves.

    Thanks
    Disha Shah

    ReplyDelete
  48. Hai Disha,

    Its very nice blog,and very usefull.

    My Manager assigned one task to me, that is

    If Any employee apply the leave application through infopath .then it will goes to his manager for approval and once mangager approverd then goes to his manager . if any manager leave on behalf of any one employee should reached.

    I think we can do using Workflow.
    So, Please can u tell me tell me how to do that i dont have that much coding knowledge.

    Please do the needfull.waiting for your comments.

    Regards
    Mansoor

    ReplyDelete
  49. Hi Mansoor

    Thanks for appreciation.

    Yes Mansoor , you are right, you can do the same thing with the Workflow.

    If you have less knowledge of code then you can use Sharepoint Designer Workflow where very less coding required but the main difficulty is to deploy that workflow from one Environment to another environment.

    You can also use Visual Studio Sequencial workflow with the some coding but it is very powerful.

    But I think you need to use Infopath forms if requirement needs to ask some input from the user like comments, Leave Date , Leave Duration etc.

    If you have any more question, please leave a comment.

    Hope this helps.

    Thanks & Regards
    Disha Shah

    ReplyDelete
  50. Hi Disha,

    Thanks for your quick response and valuable comments.

    I am using Infopath for leave application,but the question is If one of any manager is on vacation, how can we fullfill this requirment. if we choose other employee on behalf of , how to do that logic.it can be using Designer workflow or Sequential workflow ?


    Regards
    Mansoor

    ReplyDelete
  51. Hi Mansoor

    You need to use Visual Studio Sequential Workflow to fulfil your requirement.

    I have some questions like
    1> Where you are storing all employee's leaves? I think answer will be in a Sharepoint List.

    2> How you are deciding Who is the manager of a employee? From Active Directory or From MySite?

    When you are writing your Sequential workflow, add one "Code Activity" after leave request reaches to Manager and check inside sharepoint list whether the manager is available or not.

    If not then try to take manager of that manager and go through the entire process.

    Hope this helps!!!!
    Disha Shah

    ReplyDelete
  52. Hi Disha,

    Answers for which you are asking me

    1> For Employee's leave form ,am using Infopath and stored in Sharepoint list
    2>From Active Directory we are retrive the employee manager.

    But the question is if Manager is off.how do we know and how to fulfull this requirment.any other solution fot that?

    Its very urgent , Please do the needfull and please provide the code .

    Regards
    Mansoor

    ReplyDelete
  53. Mansoor

    You need to use SPQuery on SharepointList where all leaves are being stored and check whether manager is on leave or not when employee submit their leave request.

    This logic you need to write in Visual Studio Workflow Activity names as a "Code Activity". It should roughly look like this

    In a code activity

    1> First findout manager of the person.
    2> Take date of today.

    Use "And" Operator in your query on fields value is and manager field with manager name from active directory and check whether he is off or not.

    And if he is off then find his manager and submit task to him.

    Hope this helps!!!
    Disha Shah

    ReplyDelete
  54. Hi Disha,

    I tryed to write the code but am not getting proper result ,and some changes in the requirment

    We have more than 30 departments , any employee try to apply leave form it will automatically goes to corresponding his employee department manager.
    Here, the question is how to find the employee is belongs to his department .
    My logic will be

    If( ITemployee belongs to IT department) then
    send a mail to ITManager@xyz.com
    else
    if(HRemployee belongs to hrdepartment) then
    send a mail to hrmanager@xyz.com
    .......
    .
    and so on..for 30 departments , i have to write 30 if statements. this is not good code.

    Future if new department is created then what wil be happend then again i have to update the code write the one more if statement
    this is no good.

    Note: Manager,department all are getting from AD

    So,Please send me the code, am dont have much knowledge.

    Regards
    mansoor

    ReplyDelete
  55. Hi Disha,

    Kindly help,its very urgent.
    waiting for your reply


    Regards
    mansoor

    ReplyDelete
  56. Hi Masoor

    As you say you are taking person's manager and department from Active
    Directory then what is Department manager?

    Do not worry about how many departments are there, you just need to take a manager of an employee from the Active Directory because in the active directory we normally store manager of employee not manager of department.

    If you have requirement like you need to send the email to the Department manager of that Employee how do you determine?

    Yes you can write the If..Else statement in case of manager is absent and sends email to HR.

    Have you started with your workflow? SharePoint Designer or Visual Studio Workflow?

    Thanks & Regards
    Disha Shah

    ReplyDelete
  57. Hi Disha,

    Please do the needful. am waiting code


    Regards
    Mansoor

    ReplyDelete
  58. Hi Disha,

    "Sharepoint Designer Workflow e-mail does not start automatically in Sharepoint " using Form library

    But it is working...using Custom list not in Form libraries.for your information :i was login with another user not system account.

    I dont know, what is the problem .

    Can you please do the needful.

    REgards
    Mansoor

    ReplyDelete
  59. Hi Disha,

    Did you check my above issue, regarding Sharepoint Designer Workflow email...

    I login as normal user in sharepoint , when i create a list or modified a list , the "modified by" column in a list shown as a "System Account". why ?



    Regards
    mansoor

    ReplyDelete
  60. Hi Disha,

    I have started working on visual studio workflow ,As you said, we didn't send a mail to Department manager,
    But we have department wise mail id's. So I have to check to if the employee is belongs to his department then send to department mail id.

    But Here question is how to check the user is belongs to his department ?
    am struct here ,Can you send me the peice of code .

    Very helpful me

    Regards
    mansoor

    ReplyDelete
  61. Hi Mansoor

    When you login as a normal user and try to add , update item and for that if it shows "System Account" then there is one possibility for why it is showing like that is, that normal user ‘s role is "site Collection Administrator" so it says as "System Account" for that user.

    Hope this helps
    Disha Shah

    ReplyDelete
  62. Hi Mansoor


    Please search for "DirectoryEntry" and "DirectorySearcher" object and read them online and learn about it.

    Here is a code how to find the department related to a particular user from Active Directory

    strUserName = SPContext.Current.Site.RootWeb.CurrentUser.Name;
    deUserRootEntry = new DirectoryEntry("LDAP://Pathof user with like CN=username,DC=.... ");
    dsUserSearcher = new DirectorySearcher();
    dsUserSearcher.SearchRoot = deUserRootEntry;
    dsUserSearcher.Filter = "name=" + strUserName;

    if (dsUserSearcher.FindOne().GetDirectoryEntry() != null)
    {
    if (dsUserSearcher.FindOne().GetDirectoryEntry().Properties["department"].Value != null)
    ///you get department name
    }


    Hope this helps!!!
    Disha Shah

    ReplyDelete
  63. Hi Disha,

    I have created Sahrepoint feature receiver class, when i was install the feature am getting below error, U have any idea ,



    Feature '24c1825e-183a-479c-9521-973a11646912' could not be installed because the loading of event receiver assembly "ClassLibrary12.Managers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bfeac2b56d2f2aad" failed: System.IO.FileNotFoundException: Could not load file or assembly 'ClassLibrary12.Managers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bfeac2b56d2f2aad' or one of its dependencies. The system cannot find the file specified.
    File name: 'ClassLibrary12.Managers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bfeac2b56d2f2aad'
    at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
    at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
    at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
    at System.Reflection.Assembly.Load(String assemblyString)
    at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

    REgards
    Mansoor

    ReplyDelete
  64. Mansoor

    Have you installed event receiver DLL to bin directory or GAC?

    Thanks & Regards
    Disha Shah

    ReplyDelete
  65. Hi Disha,

    I have deployed dll into the GAC,and redeploy also,even same error getting. From scrtch i was developed feature,same will be happen ...am feel very hesitate this problem last few days.

    advice me

    Regards
    Mansoor

    ReplyDelete
  66. Mansoor

    Can you please give me the content of tag inside the elements.xml file of Feature.xml file?

    Thanks & Regards
    Disha Shah

    ReplyDelete
  67. Hi Disha,

    Below is the files which you requested by me.

    Feature.xml...........










    elements.xml............




    Delegation
    FeatureActivated
    1000
    ClassLibrary1.Managers, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f9f7e1719a4c0519
    ClassLibrary1.Managers




    install.bat.........



    @SET TEMPLATEDIR="c:\program files\common files\microsoft shared\web server extensions\12\Template"
    @SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"
    Echo Copying files to TEMPLATE directory
    xcopy /e /y TEMPLATE\* %TEMPLATEDIR%
    Echo Installing feature
    %STSADM% -o installfeature -filename DelegationManagers\feature.xml -force
    REM IISRESET

    ReplyDelete
  68. Disha,

    Feature.xml is not appear in ur blog comment.

    ReplyDelete
  69. Hi Disha,
    Thanks for given reply .The Assembly error was solved, i just modified the feature.xml file in the Receiver assembly. I mention only namespace instead of namespace with class name.finally the error was solved but it showing two features in the site . And when it activating its given other error " Requested value 'FeatureActivated' was not found " . and am not able to attach the process,for debugging.i send you the code, Is there any wrong in that code.? list fields are corrent in the site there is no doubt


    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
    // throw new NotImplementedException();


    SPSecurity.RunWithElevatedPrivileges(delegate
    {
    SPSite ospSite = (SPSite)properties.Feature.Parent;

    SPWeb web = ospSite.OpenWeb();


    DateTime date = DateTime.Now.Date;

    SPList list = web.Lists["HR Delegation"];

    foreach (SPListItem item in list.Items)
    {

    DateTime dt = Convert.ToDateTime(item["From Date"]).Date;
    DateTime dt1 = Convert.ToDateTime(item["To Date"]).AddDays(1);
    TimeSpan tp = dt.Subtract(date);
    TimeSpan tp1 = dt1.Subtract(date);

    if (tp.Days == 0)
    {

    web.AllowUnsafeUpdates = true;
    item["Current Manager"] = item["Acting Manager"];
    item["Extension"] = item["AM_Extension"];

    item.Update();
    web.AllowUnsafeUpdates = false;

    }
    else if (tp1.Days == 0)
    {
    web.AllowUnsafeUpdates = true;
    item["Current Manager"] = item["Manager"];
    item["Extension"] = item["M_Extension"];
    item["Acting Manager"] = null;
    item["AM_Extension"] = null;
    item.Update();
    web.AllowUnsafeUpdates = false;
    }


    }
    });

    }

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
    throw new NotImplementedException();
    }


    Regards Mansoor

    ReplyDelete
  70. Mansoor

    Glad to hear that you resolved your error. Because I have the same idea about type mistake in feature.xml file that is why I have asked to give the code what you have written inside that.

    May be you have activated same feature with two different GUIDS.

    By looking at your code you need to do some kind of operation on a list so why you have written on FeatureActivated.

    This is completely wrong!!!
    Can you please tell me what you want to achive by Event Receiver?

    Thanks & Regards
    Disha Shah

    ReplyDelete
  71. Hi Disha,

    we have a list feilds like below



    Depatment Choice
    Manager Person or Group
    M_Extension Single line of text
    From Date Date and Time
    To Date Date and Time
    Acting Manager Person or Group
    AM_Extension Single line of text
    Current Manager Person or Group
    Extension Single line of text

    Our requirment is :
    When From date is equal to Today system date then
    Activing manager should updated as Current Manager and
    AM_Extension should updated as M_Manager

    else if
    When today is equal to next system date then
    Manager should updated as current Manager and
    M_Extension is should updated as Extension

    hope ur understood

    Regareds
    mansoor

    ReplyDelete
  72. Mansoor
    You have written wrong EventReceiver for your requirement. FeatureActivated EventReceiver is used to run when you activate feature!!!So definitely when you activate feature it gives error and does not fulfill your requirement!!

    For this requirement, I do not see that you should write the EventReceiver but you would write custom timerjob which runs every day and executes your custom timer job every day.

    Please follow this link, you have a clear idea about Custom timer jobs and how to deploy that!!!
    http://www.andrewconnell.com/blog/articles/CreatingCustomSharePointTimerJobs.aspx

    Hope this helps!!!
    Thanks & Regards
    Disha Shah

    ReplyDelete
  73. Manifest.xml


    Manifest.xml..........

    Solution xmlns="http://schemas.microsoft.com/sharepoint/"
    DeploymentServerType="WebFrontEnd"
    ResetWebServer="TRUE"
    SolutionId="89F927F5-BAB2-479d-A14F-3007840E15E7">






    /Solution



    install.bat......



    @SET TEMPLATEDIR="c:\program files\common files\microsoft shared\web server extensions\12\Template"
    @SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"
    Echo copying dll..
    @SET GACUTIL="C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe"
    %GACUTIL% -if bin\Release\SpTimerJob.dll
    Echo Copying files to TEMPLATE directory
    xcopy /e /y TEMPLATE\* %TEMPLATEDIR%
    Echo Installing feature
    %STSADM% -o installfeature -filename DELEGATIONTIMER\Feature.xml -force
    REM IISRESET

    ReplyDelete
  74. I resend the xml file ,

    Manifest.xml.........

    Solution xmlns="http://schemas.microsoft.com/sharepoint/"
    DeploymentServerType="WebFrontEnd"
    ResetWebServer="TRUE"
    SolutionId="89F927F5-BAB2-479d-A14F-3007840E15E7">
    Assemblies>

    /Assemblies>
    FeatureManifests>

    /FeatureManifests>
    /Solution

    ReplyDelete
  75. Disha,

    Assembiles tag is not appear, so i again send it. sorry for intrub


    Solution xmlns="http://schemas.microsoft.com/sharepoint/"
    DeploymentServerType="WebFrontEnd"
    ResetWebServer="TRUE"
    SolutionId="89F927F5-BAB2-479d-A14F-3007840E15E7">
    Assemblies>
    Assembly DeploymentTarget="GlobalAssemblyCache"
    Location="SpTimerJob.dll"/>
    /Assemblies>
    FeatureManifests>
    FeatureManifest Location="DELEGATIONTIMER\Feature.xml"/>
    /FeatureManifests>
    /Solution>

    ReplyDelete
  76. Disha,

    I removed install.bat file and added ddf and target files.

    install.ddf.......


    .OPTION EXPLICIT
    .Set CabinetNameTemplate=SPTimerJob.wsp
    .Set DiskDirectoryTemplate=c:\wsp
    .Set CompressionType=MSZIP
    .Set UniqueFiles=Off
    .Set Cabinet=On

    ;Files to place into the CAB Root
    TEMPLATE\FEATURES\DELEGATIONTIMER\Manifest.xml

    ;Files to place intothe CAB white Direcotry
    .Set DestinationDir=SPTimerJob
    TEMPLATE\FEATURES\DELEGATIONTIMER\Feature.xml

    install.Targets.......

    ?xml version="1.0" encoding="utf-8" ?>
    Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets ="install">

    PropertyGroup>
    MakeCabPath>"C:\Windows\System32\MAKECAB.EXE"

    /PropertyGroup >

    Target Name="install">
    Exec Command="C:\Windows\System32\MAKECAB.EXE /F install.ddf /D CabinetNameTemplate=$(SPTimerJob).wsp /D DiskDirectory1=$(OutputPath)SpPackage\"/>
    Exec Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"
    Command="$(MakeCabPath) /F install.ddf /D CabinetNameTemplate=$(SPTimerJob).cab /D DiskDirectory1=$(OutputPath)SpPackage\"/>
    /Target>

    /Project>


    finally am getting one error,,

    Error 2 The "Exec" task needs a command to execute. SpTimerJob


    do u have any idea ?

    ReplyDelete
  77. Mansoor

    There is some problem when you post comment with "<" contents.

    Can you please refer this link for your error?
    http://www.kenegozi.com/blog/2007/05/24/the-quotexecquot-task-needs-a-command-to-execute-the-poor-thing.aspx

    Hope this helps!!!
    Disha Shah

    ReplyDelete
  78. Hi Disha,

    I wrote below timerjob code ,its sucessfully updated the value if we run in the console application.

    But if i am using timer job is not updated.when i debug the code ,mylist.items.count=0 ,but items are available in a list. Anything i have add the code.?

    public override void Execute(Guid targetInstanceId)
    {
    //base.Execute(targetInstanceId);
    SPSecurity.RunWithElevatedPrivileges (delegate()
    {
    try
    {
    SPWebApplication webApplication = this.Parent as SPWebApplication;
    SPContentDatabase contentDb = webApplication.ContentDatabases[targetInstanceId];

    SPList myList = contentDb.Sites[2].RootWeb.Lists["test"];
    SPListItem item = myList.Items.Add();
    item["Title"] = DateTime.Now.ToString();
    item.Update();

    }
    catch (Exception Ex)
    {
    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("Exception Occurred: {0} || {1}", Ex.Message, Ex.StackTrace);
    }

    });

    }

    ReplyDelete
  79. Mansoor

    If it works inside console application then there must be a problem when you get list from site.

    You have written this statement and I have doubt in this statement which causes problem
    SPList myList = contentDb.Sites[2].RootWeb.Lists["test"];

    List is inside which Site? You can also pass the name of your site to get that list.

    Please check with this line.

    Thanks
    Disha Shah

    ReplyDelete
  80. Disha,

    There is no doubt on the site and list name. both are correct , i check when debugging its taking correct url and list.

    thats way i am not understand, if any other line of code have to add for the timejob execute method.

    ReplyDelete
  81. Mansoor

    Have you registered your timejob with FeatureActivated?

    You need to register your timer job with FeatureActivated then and only then it adds a item inside the list

    For example,
    public override void FeatureActivated (SPFeatureReceiverProperties properties) {
    SPSite site = properties.Feature.Parent as SPSite;

    // make sure the job isn't already registered
    foreach (SPJobDefinition job in site.WebApplication.JobDefinitions) {
    if (job.Name == TASK_LOGGER_JOB_NAME)
    job.Delete();
    }

    // install the job
    TaskLoggerJob taskLoggerJob = new TaskLoggerJob(TASK_LOGGER_JOB_NAME, site.WebApplication);

    SPMinuteSchedule schedule = new SPMinuteSchedule();
    schedule.BeginSecond = 0;
    schedule.EndSecond = 59;
    schedule.Interval = 5;
    taskLoggerJob.Schedule = schedule;

    taskLoggerJob.Update();
    }

    Hope this helps!!!
    Disha Shah

    ReplyDelete
  82. Disha,

    i added the Feature receiver code ,using WSPBuilder. there is no doubt.

    ReplyDelete
  83. Mansoor

    Have you followed these steps to deploy the solution?

    1> Deploy the strongly named assembly to the GAC of your timerJob.
    2> Reset IIS (required for SharePoint to "see" the new timer job in the GAC).
    3> Deploy the strongly named assembly to the GAC of your FeatureReceiver.
    4> Create a feature specifying the receiver class and assembly that contains the event receivers.
    5> Install the feature.
    6> Activate the feature

    Thanks
    Disha Shah

    ReplyDelete
  84. Disha,

    Yes,I think u know WSPBuilder. its automatically created feature and all those things.
    i build the wsp and deploy into the solution. its auctomatically added into the GAC.

    ReplyDelete
  85. Mansoor

    I know about the Wsp Builder !!!

    Please go through this link
    http://wspbuilder.codeplex.com/
    http://www.zimmergren.net/archive/2009/04/08/wspbuilder-walkthrough-of-the-visual-studio-add-in.aspx

    Please Read,You should not bother about these things which I have listed below but you should create fature files.

    "No more manually creating the manifest.xml file.
    No more manually specifying the DDF file.
    No more using the makecab.exe application."


    Hope this helps!!!
    Disha Shah

    ReplyDelete
  86. Mansoor

    If you want to check that all Feature Files has been added to your .wsp package or not, just copy that .wsp file and make it that file as .zip file. Now extract that zip file.You will see inside the extract folder whether all features , resources files has been created or not.

    Try it out an check it!!!

    Hope this helps!!!
    Disha Shah

    ReplyDelete
  87. Disha,

    As you said, i added the zip and extract the files ,its all are avilalble .

    ReplyDelete
  88. Mansoor

    As you said you added Feature receiver code through WSPBuilder. Can you please send me FeatureActivatedCode?

    You just send me TimerJob Execute code.Please send me FeatureActivated code that you have written .

    Thanks
    Disha Shah

    ReplyDelete
  89. Disha,

    below are the feature reciver code :

    class ListUpdate : SPFeatureReceiver
    {
    const string LIST_JOB_NAME = "ListLoggerNew";
    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
    //throw new Exception("The method or operation is not implemented.");
    try
    {
    SPSite site = properties.Feature.Parent as SPSite;
    foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
    {
    if (job.Name.Equals(LIST_JOB_NAME))
    {
    job.Delete();
    }
    }
    //install the job...
    CustomJobDefination listLoggerJob = new CustomJobDefination(LIST_JOB_NAME, site.WebApplication);
    SPMinuteSchedule schedule = new SPMinuteSchedule();
    schedule.BeginSecond = 0;
    schedule.EndSecond = 59;
    schedule.Interval = 1;
    listLoggerJob.Schedule = schedule;
    listLoggerJob.Update();
    }
    catch (Exception Ex)
    {
    Microsoft.Office.Server.Diagnostics.PortalLog.LogString("Exception Occurred: {0} || {1}", Ex.Message, Ex.StackTrace);
    //SPLoggingService.DiagnosticAreaName = "SP2010TimerJob";

    //SPLoggingService.LogError(SPLoggingService.CategoryName = SPLoggingService.GetAvilebleCategories("TimerJobs"), ex.Message, (uint)100);
    }


    }

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
    //throw new Exception("The method or operation is not implemented.");

    SPSite site = properties.Feature.Parent as SPSite;
    foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
    {
    if (job.Name.Equals(LIST_JOB_NAME))
    {
    job.Delete();
    }

    }

    }


    Help me on that , its taking very long time ..........

    ReplyDelete
  90. Disha,

    Below is the windows eventlog which am getting..

    The Execute method of job definition Microsoft.Office.Server.Search.Administration.IndexingScheduleJobDefinition (ID df02102b-a149-42a0-b4f5-f2c14adf71ab) threw an exception. More information is included below.

    Retrieving the COM class factory for component with CLSID {3D42CCB1-4665-4620-92A3-478F47389230} failed due to the following error: 8007042d.

    ReplyDelete
  91. Mansoor

    This link also refers for your error

    http://my-sharepointexperience.blogspot.com/2009/08/issue-retrieving-com-class-factory-for.html

    Thanks
    Disha Shah

    ReplyDelete
  92. Mansoor

    Thanks for providing me Error Description from Event Viewer.
    It clears that There is no problem inside your code.The Problem is with the search Configuration of Sharepoint.

    So please refer these links to solve your problem
    http://social.technet.microsoft.com/Forums/en-US/sharepointgeneral/thread/dc1db06b-ac78-4547-b28d-a0d1efab3b80
    http://www.shannonbray.com/2008/03/search-error-com-8007042d.html

    The fix was to start Component Services (Under Administration Tools).
    Under DCOM config, you will find the OSearch component.
    First find out what the credentials are by using the Identity tab. If the Service is using a system account, you can either elevate the system account or supply a user with significant rights.


    Hope this Helps!!
    Disha Shah

    ReplyDelete
  93. Hi Disha,

    Good Day !

    I have a sharepoint list[Managers] with groupby sector column. like below

    1)Sector1
    a)Dep1
    b)Dep2

    2)Sector2
    a)Dep3

    3)Sector3
    a)Dep4
    b)Dep4
    c)Dep4

    These each Sector group by column data i want to display in label or panel control.

    How to do that ? Do u have any idea?

    REgards
    mansoor

    ReplyDelete
  94. Hi.

    Actually, i want to display each sector group data wiht look in feel .by using custom control or webpart.

    because this is client needs.So for display group by data , how can i read that data and stored in any webcontrols.



    Usercontrol look like this:

    Sector1: Sector2:

    depa1 depa2

    depa1 depar2

    --------------

    -------- and so on..

    Regard

    manosor

    ReplyDelete
  95. Mansoor

    You can do same thing with out of the box , follow these steps to do
    1> Create a view and give Sector field as "Group field"
    2> Create a new page and add the listview webpart.
    3> In that ListView webpart , modify that webpart and select current view as "Group View" that you have created

    Second Option is
    Create a webpart and use SPGridView which gives exact look and feel like Sharepoint!!!

    Hope this helps!!
    Thanks & Regards
    Disha Shah

    ReplyDelete