How do I add web part in the event receiver after the site is provisioned in SP 2010?

How do I add web part in the event receiver after the site is provisioned in SP 2010?

You try the below steps:
1. Use long operation to provision the site, so that it does not time out in process.
2. After provisioning, you can add a page or add the web part directly to landing page of site.
For each of the above steps you can find the sample code pieces.
if you couldn't get that, let me know. I will share with you.
Thanks, Ashish If my response has helped you, please mark as answer.

Similar Messages

  • Search for records in the event viewer after the last run (not the entire event log), remove duplicate - Output Logon type for a specific OU users

    Hi,
    The following code works perfectly for me and give me a list of users for a specific OU and their respective logon types :-
    $logFile = 'c:\test\test.txt'
    $_myOU = "OU=ABC,dc=contosso,DC=com"
    # LogonType as per technet
    $_logontype = @{
        2 = "Interactive" 
        3 = "Network"
        4 = "Batch"
        5 = "Service"
        7 = "Unlock"
        8 = "NetworkCleartext"
        9 = "NewCredentials"
        10 = "RemoteInteractive"
        11 = "CachedInteractive"
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0""
    or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>" -ComputerName
    "XYZ" | ForEach-Object {
        #TargetUserSid
        $_cur_OU = ([ADSI]"LDAP://<SID=$(($_.Properties[4]).Value.Value)>").distinguishedName
        If ( $_cur_OU -like "*$_myOU" ) {
            $_cur_OU
            #LogonType
            $_logontype[ [int] $_.Properties[8].Value ]
    #Time-created
    $_.TimeCreated
        $_.Properties[18].Value
    } >> $logFile
    I am able to pipe the results to a file however, I would like to convert it to CSV/HTML When i try "convertto-HTML"
    function it converts certain values . Also,
    a) I would like to remove duplicate entries when the script runs only for that execution. 
    b) When the script is run, we may be able to search for records after the last run and not search in the same
    records that we have looked into before.
    PLEASE HELP ! 

    If you just want to look for the new events since the last run, I suggest to record the EventRecordID of the last event you parsed and use it as a reference in your filter. For example:
    <QueryList>
      <Query Id="0" Path="Security">
        <Select Path="Security">*[System[(EventID=4624 and
    EventRecordID>46452302)]]</Select>
        <Suppress Path="Security">*[EventData[Data[@Name="SubjectLogonId"]="0x0" or Data[@Name="TargetDomainName"]="NT AUTHORITY" or Data[@Name="TargetDomainName"]="Window Manager"]]</Suppress>
      </Query>
    </QueryList>
    That's this logic that the Server Manager of Windows Serve 2012 is using to save time, CPU and bandwidth. The problem is how to get that number and provide it to your next run. You can store in a file and read it at the beginning. If not found, you
    can go through the all event list.
    Let's say you store it in a simple text file, ref.txt
    1234
    At the beginning just read it.
    Try {
    $_intMyRef = [int] (Get-Content .\ref.txt)
    Catch {
    Write-Host "The reference EventRecordID cannot be found." -ForegroundColor Red
    $_intMyRef = 0
    This is very lazy check. You can do a proper parsing etc... That's a quick dirty way. If I can read
    it and parse it as an integer, I use it. Else, I just set it to 0 meaning I'll collect all info.
    Then include it in your filter. You Get-WinEvent becomes:
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624 and EventRecordID&gt;$_intMyRef)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0"" or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>"
    At the end of your script, store the last value you got into your ref.txt file. So you can for example get that info in the loop. Like:
    $Result += $LogonRecord
    $_intLastId = $Event.RecordId
    And at the end:
    Write-Output $_intLastId | Out-File .\ref.txt
    Then next time you run it, it is just scanning the delta. Note that I prefer this versus the date filter in case of the machine wasn't active for long or in case of time sync issue which can sometimes mess up with the date based filters.
    If you want to go for a date filtering, do it at the Get-WinEvent level, not in the Where-Object. If the query is local, it doesn't change much. But in remote system, it does the filter on the remote side therefore you're saving time and resources on your
    side. So for example for the last 30 days, and if you want to use the XMLFilter parameter, you can use:
    <QueryList>
    <Query Id="0" Path="Security">
    <Select Path="Security">*[System[TimeCreated[timediff(@SystemTime) &lt;= 2592000000]]]</Select>
    </Query>
    </QueryList>
    Then you can combine it, etc...
    PS, I used the confusing underscores because I like it ;)
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Unable to add web part in the web part zone

    We have a SharePoint 2010 site collection in which except the home page all other pages are working normally. When we try to click on 'Add a Web Part' button on the home page we won't get the web part gallery and hence we are unable to add any web parts
    on the home page.
    We checked the permissions, it is fine I have web application level full control. 
    Home page is not checkout to any body.  All other site collections have good home pages where we are able to add web parts.
    Please let me know how to fix this issue.
    Thank you,
    smith

    Hi Victoria Xia,
    Below are my answers to your questions
    Check the page in SharePoint Designer to see if there are any customization on the page.
               There are no customizations on the page. It just has Out of the Box web parts which are already      added.
         2. Did this issue occur with other user accounts?
               Yes, issue is there for all the user accounts.
         3. Set another page as home page to see if the issue still occurs.
             I have set another page as home page but didn't see any issue.
         4. Was there any error when editing the home page?
             No, I don't see any errors while editing the home page.
    smith

  • How to add web part zone?

    I am testing SP 2010 and trying to add a webpartzone to the page. So I go into SPD and edit the page. However I can only add new webparts not another webpartzone. The option is greyed out. So the only webpartzone I see is "Rich Content" when viewed on the
    web. The page is based on v4.master. But even if I try and edit v4.master, I do not have WebPartZone enabled....I guess I am still new and learning....can someone tell me what I need to do?
    Thanks in advance,
    Jacob. 

    Hi
    just add a new div in the page, then go to designer mode, now the button will be visible to add web part zone.
    Alternate is that, just copy and paste the following code in the aspx page
    <div>
    <WebPartPages:WebPartZone
    runat="server"
    FrameType="TitleBarOnly"
    ID="Left"
    Title="loc:Left"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>
    </div>
    It will work
    Muhammad Kamran Rafi
    [email protected]
    SharePoint Developer
    Xelleration LLC

  • How to force my Web part to run regardless of users permissions

    I have created the following custom permission , which will allow users to Create items without being able to view,edit them:-
    $spweb=Get-SPWeb -Identity "http://vstg01";
    $spRoleDefinition = New-Object Microsoft.SharePoint.SPRoleDefinition;
    $spRoleDefinition.Name = "Submit only";
    $spRoleDefinition.Description = "Can submit/add forms/files/items into library or list but cannot view/edit them.";
    $spRoleDefinition.BasePermissions = "AddListItems, ViewPages, ViewFormPages, Open";
    $spweb.RoleDefinitions.Add($spRoleDefinition);
    $spweb.Dispose();
    then inside my "Issue Tracking List" i stop inheriting permission from team site , and i define the following permission for all users:-
    now users can add items and they can not view them ,, which is perfect :).
    But now i wanted to add a custom web part to my Create form which will hide certain fields if the user is not within specific group ,the web part looks as follow:-
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    InitializeControl();
    using (SPSite site = new SPSite(SPContext.Current.Site.Url))
    using (SPWeb web = site.OpenWeb())
    web.AllowUnsafeUpdates = true;
    SPGroup group = web.Groups["Intranet Visitors"];
    bool isUser = web.IsCurrentUserMemberOfGroup(group.ID);
    if (!isUser)
    SPList myList = web.Lists.TryGetList("Issue List");
    SPField titleField = myList.Fields.GetField("Category");
    titleField.Hidden = true;
    titleField.ShowInEditForm = false;
    titleField.ShowInNewForm = false;
    titleField.ShowInDisplayForm = false;
    titleField.Update();
    myList.Update();
    // web.AllowUnsafeUpdates = false;
    else
    SPList myList = web.Lists.TryGetList("Issue List");
    SPField titleField = myList.Fields.GetField("Title");
    titleField.Hidden = false;
    titleField.Update();
    myList.Update();
    // //web.AllowUnsafeUpdates = false;
    web.AllowUnsafeUpdates = false;
    then i deploy the web part and i add it to the Create form. but after doing so user are not able to create items and they will get the following error:-
    Sorry this site has not been shared with you
    so can anyone advice how to force my web part to run , without checking the users permissions or with minimal permssions ?

    in this case, use the elevated privileges to read/add/edit items with elevated privileges with below code.
    but make sure the page which you add this web part have at least read access to all user.
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite site = new SPSite(web.Site.ID))
    // implementation details omitted
    More: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx
    Bistesh
    Ok after adding :-
    SPSecurity.RunWithElevatedPrivileges(delegate()
    users with the following permissions can create items:-
    "AddListItems, ViewPages, ViewFormPages, Open";
    and they can not edit/read them, which is great. but i am facing a caching problem , because if user is inside the "Intranet visitor" he will be able to see Category field as mentioned in my code, but if i remove him from the "Intranet Visitor"
    he still can see the field,, although in the web part i specify not to display the Category column if the user is not inside the "Intranet visitor " group... here is my current code:-
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    InitializeControl();
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite site = new SPSite(SPContext.Current.Site.Url))
    using (SPWeb web = site.OpenWeb())
    web.AllowUnsafeUpdates = true;
    SPGroup group = web.Groups["Intranet Visitor"];
    bool isUser = web.IsCurrentUserMemberOfGroup(group.ID);
    if (!isUser)
    SPList myList = web.Lists.TryGetList("Risk & Issue Management");
    SPField titleField = myList.Fields.GetField("Category");
    titleField.Hidden = true;
    titleField.ShowInEditForm = false;
    titleField.ShowInNewForm = false;
    titleField.ShowInDisplayForm = false;
    titleField.Update();
    myList.Update();
    // web.AllowUnsafeUpdates = false;
    else
    SPList myList = web.Lists.TryGetList("Risk & Issue Management");
    SPField titleField = myList.Fields.GetField("Category");
    titleField.Hidden = false;
    titleField.ShowInEditForm = true;
    titleField.ShowInNewForm = true;
    titleField.ShowInDisplayForm = true;
    titleField.Update();
    myList.Update();
    web.AllowUnsafeUpdates = false;
    so can you advice please ? is this a caching problem, or once the user add at-least single item he will be able to see all columns ?

  • Dynamically add web part in sandbox solution

    I've site in office 365. I want to add site page in /SitePages on feature activation. I also want to dynamically add web part in this site page.
    How can I do this?

    Hi,
    According to your description, you might want to add a page into the “Site Pages” library and add a web part into it in the FeatureActivated event in a Sandboxed solution.
    To add a site page, you can refer to the two links below:
    http://www.c-sharpcorner.com/blogs/4526/programmatically-create-wiki-page-in-sharepoint.aspx
    http://sharepoint2010mind.blogspot.ch/2012/06/add-publishing-page-to-sharepoint-site.html
    Then add a web part to the page:
    http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/
    Best regards
    Patrick Liang
    TechNet Community Support

  • Unable to add web part to SharePoint 2013 page

    hello,
    My account has full control on the site collection, and when I edit the page and click on the Add a Web Part, nothing happens.  I would expect to have a list of web parts that I can select from, but this does not appear.  What can I do to enable
    this or get web parts added to the page?
    Thanks
    Paul

    Hi Paul,
    We need to collect more information about your issue:
    1.Is there any customized script that might affect the issue?
    2.Could you please test the issue with another user account? Does it work before for your account?
    3.Please test the issue on other browsers and see if it works.
    Similar threads:
    https://social.technet.microsoft.com/forums/sharepoint/en-US/e4fc21d4-b703-454a-a135-6d28d23cb18a/unable-to-add-webpart-wpadder-is-missing
    http://sharepoint.stackexchange.com/questions/3883/cant-add-web-parts-to-a-page-as-a-user-with-full-control
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Is there a way to allow contributor users to add web parts to a page without granting them "Add and Customize Pages" permission?

    I am working on an enterprise wiki site collection, and when contributor users try to add web parts they will get the following error:-
    A Web Part or Web Form Control on this Page cannot be displayed or imported. You don't have Add and Customize Pages permissions required to perform this action.
    So I granted the Contribute Permission level an extra permission which is “Add and Customize Pages”. Now contributors will be able to add/edit/delete
    web parts. But they will have extra permissions that I do not want them to have , such as changing the design and customize some page layouts, also they can access the site settings and create site columns !!.
    So my question is basically if there is another way to allow users with contribute permission to be able to add web parts without granting any extra permission. In other words to treat adding web parts as normal content such as image, Text ,tables ?
    Thanks

    I dont think so.
    http://technet.microsoft.com/en-us/library/cc288074%28v=office.14%29.aspx
    Add and Customize Pages
    Add, change, or delete HTML pages or Web Part pages, and edit the Web site by using a Windows SharePoint Services-compatible editor.
    View Items, Browse Directories, View Pages, Open
    Design, Full Control 
    If this helped you resolve your issue, please mark it Answered. You can reach me through http://freeit-support.com/
    so there are not any workarounds or any custom settings which i can use to implement any of these:-
    - To force Contributor users to add web parts without granting them "Add and Customize Pages"
    - If i grant them "Add and customize Pages" permission, to stop the ability to access the site settings ?
    Please can any one advice on this , as it is causing a lot of confusion,,, and i can not live with the face that Contributor users can access and modify site settings. the other approach will be is that i will stop using web parts. but one of our main reasons
    we decide to use SharePoint is the ability to add web parts, especially the Visio & Excel web access web. thanks in advance for any advice ..

  • How to custom add web sites to Top 6/12/24 ?

    Hi all, how to custom add web sites to Top 6/12/24 ?

    Press and hold the + icon in the URL/Address bar and select "Top Sites".
    or
    Move the mouse pointer to the + icon and do a 3 finger touch on the trackpad, then select Top Sites from the dropdown.
    For more info:
    https://support.apple.com/kb/PH19263?locale=en_US

  • How can I add a field to a Repeating Frame in the body of a 9i Report

    How can I add a field to a Repeating Frame in the body of an Oracle 9i Report whose source is in a higher group?
    I want to change an Oracle 9i report. The report has no header or trailer but only a body. The body has the parent frame fields & a repeating frame with four fields, A, B, C & D. They all seem to be in one group. I want to add another field E to the repeating frame whose source is from the 'header'.
    I added the field & created a boiler plate & then added the new field, E to the original group A, B, C & D. In the Property Inspector for the field, I pointed the source to the source column in the main query. However, when I run the report, I receive the error "Invalid body size". Some notes on Metalink indicate that this could be due to margins being out of the printable area.
    Moreover, after making the changes & after having unsuccessfully run the report, when I try to open the Page Layout for the report, I get no details.
    Thanks,

    Hi,
    i also got same query can u pls tell me elaborately, if u can can u pls send some code.
    Thanks & Regards
    Jagadeeshwar.B

  • How do I add multiple songs to an existing playlist from the (no longer called) Library? Highlighting multiple songs and clicking the "Add to" button will only add the with the little arrow, not all the highlighted ones!

    How do I add multiple songs to an existing playlist from the (no longer called) Library? Highlighting multiple songs and clicking the "Add to" button will only add the one with the little arrow, not all the highlighted ones! I am using the "new" iTunes.

    For the moment there isn't a way for us end-users to control what is "matched" or "uploaded." That is purely a result of Apple's server-side algorithms.
    To re-add multiple songs at once simply highlight all the songs you want to re-add, then right-click (or Control+click) the list and choose "add to iCloud."

  • How can I add a new message(custom text message) to the holiday approval em

    How can I add a new message(custom text message) to the holiday approval email-notification sent to the manager?
    TIA

    The answer is 'not very easily', unless the information you want to display is the employee's leave balances. In 12.1.3 Oracle have delivered functionality that allows you to include the leave balances in the approval notifications out-the-box, ie, without customization.
    For any other information you're probably going to have to customize the standard delivered HRSSA workflow. Within this workflow, the Leave of Absence functionality uses the Notify Approver (Embedded) (HR_APPROVER_NTF) notification. The body of this notification is set to the Notify Approver (Embedded) (HR_NTF_EMBEDDED_REGION) attribute. This in turn defaults to:
    JSP:/OA_HTML/OA.jsp?OAFunc=-&HR_EMBEDDED_REGION-&NtfId=-&#NID-
    So essentially you can change the HR_APPROVER_NTF notification. The problem with changing this notification is that it's generic - it's used for all SSHR functions and not just Leave of Absence. That means you have to make other, more substantial, customizations to the workflow to ensure the changes you make only applies to LOA.
    The other option is to personalize the review page (ie, the region referenced in &HR_EMBEDDED_REGION) to include whatever messages you want. But that means they'll appear on the Review page and all LOA approval notifications and that might not be what you want.
    It's usually better to live with what Oracle deliver and find an alternative solution! What's the content of the message you want to include?

  • After creating a new playlist in iTunes, how can I add my entire music library --at once-- to the new playlist. I want to download all my music from Icloud at once on my Macpro

    After creating a new playlist in iTunes, how can I add my entire music library --at once-- to the new playlist. I want to download all my music from Icloud at once on my Macpro

    You have two separate questions here...
    To get all your music into one playlist, select Music in the sidebar and click the Songs view at the top. Then, highlight all the songs and drag them into your playlist.
    I don't know if it's possible to download all Purchased content (or do you mean iTunes Match content?) at once; try a few Google searches.

  • How can I add a language on pages (Greek) to check the spelling when that language is not on the list?

    how can I add a language on pages (Greek) to check the spelling when that language is not on the list?
    I can see other languages available for spelling check, but not Greek and I dont see how to add it.
    I have added the Greek keyboard on the Mac, so I can write in Greek , but I dont know how to check the spelling in Greek on pages

    You can try to add a 3rd party spellchecker
    http://milaraki.com/blog/2010/11/greek-spelling-at-pages-how-to/

  • How can I add a person to an event (and send that person an invite) without resending the meeting invitation to all participants?

    How can I add a person to an event (and send that person an invite) without resending the meeting invitation to all participants?

    Apple doesn't make it easy to do what you want.  However, here's how I do it. 
    Select the photo you want to move and create a new Event for it via the Event ➙ Create Event menu option.
    In the Event mode select the new Event with the one picture and drag it onto the Event you want to move the photo to.

Maybe you are looking for

  • UWL - I want to add the column "item type" in the UWL XML config file

    Hi, when personalizing a view in the default UWL iView, a user can add the column "Item Type", which shows the icon of the corresponding item. I want to add this column to a default view configuration in the XML file, so that all users have this colu

  • Is there any possible way I can download Microsoft powerpoint on my MacBook Pro OS X for free? I need it for lots of projects of my school.

    Dear Apple Inc.      I would like to know if there is any possible way I can download Microsoft Powerpoint on my MacBook Pro OS X for free? I hope you can reply as soon as you can so I can be able to do all the projects being presented to me from sch

  • Authentication Failed :  BPEL Console and BPEL Admin

    Hi , I am trying to log in to BPEL Console repeatedly. I am using the user oc4jadmin. I have logged in successfully previously using oc4jadmin. I read somewhere that a workaround is "Workaround is you take login_error.jsp off from URL http://<host>:<

  • Arabic pdf report

    hi we have uploaded a custom .rdf on the application, when we run this report with output text the arabic is shown fine but when we try to change the output to pdf the arabic is not readable (rubbish), is there a way to show arabic in pdf. we have re

  • Enhancement for ME21N and ME22N

    Hi Expert, I need to change the delivery priority in STO, according to the data entered in the header(EKKO). But i am not able to find an exit or BAdi which is having the parameter delivery priority. The table and field names: ( EKPV LPRIO). In case