Shortcut to mark up list item in DW CS5

Hi,
Forgive me if this is an easy one, but I have checked the knowledgebase without success. In my last version of DW I had a shortcut programmed so that I could type the text for a list item, highlight it, and use the shortcut to append opening and closing <li> tags to either end - much as you still can with CTRL+Shift+P for paragraph tags.
I used this a lot as I often receive long lists which need to be marked up and it's the quickest way - except I can't figure out how to do this now. I tried the advice here: http://help.adobe.com/en_US/dreamweaver/cs/using/WSc78c5058ca073340dcda9110b1f693f21-7cd9a .html but DW will only append <ul> tags to either end of the text, not <li> tags to each list item.
Any help very much appreciated.
Thanks
Katie

You can define a snippet to do that, and then create a shortcut to execute that snippet.  I believe that was how you had to do it before, too.
I'm assuming you want to change this -
here is a line of text
to this -
<li>here is a line of text</li>
right?

Similar Messages

  • Unable to populate list items with criteria

    Hi
    I want to populate some values based on condition in a text field.
    I tried the code wihtout condition in new form instance and its working fine but when i tried with an condition on when mouse click on list item and its working for first action.If list having more than 1 values in list its became blank and not working
    DECLARE
    group_name varchar2(40) :='LSTCUR';
    group_id RecordGroup;
    list_id item := Find_item('TB.LSTCUR');
    status NUMBER;
    begin
    IF Id_null(group_id) THEN
    group_id := Create_Group_From_Query('LSTCUR','select distinct curr,curr from REC_CURR_V where br =:TB.PSRCH');
    END IF;
    Clear_list(list_id);
    status := Populate_Group('LSTCUR');
    Populate_list(list_id,group_id);
    end;
    rgds
    soumya

    soumya,
    Try this code.
    DECLARE
         RG_Group_ID RECORDGROUP;
         Num_Status NUMBER;
    BEGIN
         RG_Group_ID := FIND_GROUP('LSTCUR');
      IF NOT Id_Null(RG_Group_ID) THEN
              DELETE_GROUP(RG_Group_ID);
      END IF;
         RG_Group_ID := CREATE_GROUP_FROM_QUERY('LSTCUR', 'SELECT DISTINCT CURR, CURR FROM REC_CURR_V WHERE BR = ''' || :TB.PSRCH || '''');
         CLEAR_LIST('TB.LSTCUR');
         Num_Status := POPULATE_GROUP('LSTCUR');
         POPULATE_LIST('TB.LSTCUR', RG_Group_ID);
    END;Regards,
    Manu.
    If my response or the response of another was helpful, please mark it accordingly

  • Open a SharePoint List item in Modal Pop up in SP 2013 fails after you filter or sort the list

    Sorry for the long post. This has been killing me. I had this script working perfectly fine in SharePoint 2010 (online) and basically i have a source custom list (list A) with a hyperlink column and a Destination List with say title and my name.
    Source List (list A) looks like this with these 2 columns
    Title    Test Link
    A         Link 1
    B         Link 2 
    C         Link 3
    Each of these links link to the actual list item in the destination list, so for example, link 1 is/sites/2013DevSite/Lists/Destination%20List/EditForm.aspx?ID=1
    So basically i want anytime the Link are clicked that point to another list's item to open in a modal dialog and the script below worked perfectly fine in SharePoint 2010 (online)
    <script language="javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
    <script language ="javascript" type="text/javascript">   
    jQuery(document).ready(function() {
    jQuery('a[href*="EditForm.aspx"]').each(function (i, e) {
    // Store the A tag's current href in a variable
    var currentHref = jQuery(e).attr('href');
    jQuery(e).attr({
    'href': 'javascript:void(0);', 
    // Use the stored href as argument for the ShowInModal functions parameter.
    'onclick': 'ShowInModal("' + currentHref + '");'
    function ShowInModal(href) {
    SP.UI.ModalDialog.showModalDialog({title: "Edit Item", url: href});    
    </script>
    All it does is find the href tags for that particular value Editform.aspx and the pop modal works in SP 2010 online. So the site page is designed in such a way there is a content editor web part with the reference to this javascript file and the sharepoint
    list is right beneath it and this worked perfectly opening in modal windows in SP 2010.
    Since migration to 2013, this is what exactly happens
    1.) when you come to the site page, the modal works,
    2.) If you filter or sort on say the Title or Test Link column in Source list (lets say you select the Value A), the script does not fire at all, if i hover over the hyperlink, the who hyperlink is shown and does not open the hyperlink in the modal pop up.
    - This is important because i want to be able to sort on a particular item...
    Could someone please let me know what am i doing wrong and why is this not working when i sort the list. Thanks for all the help.
    Once again i am trying to open a sharepoint list item in Sharepoint 2013 from another list using Jquery

    A ListItem has its own unique row id so in all likelihood, an insert with the same data will result in a new list entry. The Lists Web Service however, has an UpdateListItem method which will take an update request. [refer
    http://msdn.microsoft.com/en-us/library/office/websvclists.lists.updatelistitems(v=office.15).aspx ]
    There is another note in the conference (marked answered) to your List Item Update problem. Probably worth a try too. [refer
    http://social.msdn.microsoft.com/Forums/en-US/bee8f6c6-3259-4764-bafa-6689f5fd6ec9/how-to-update-an-existing-item-in-a-sharepoint-list-using-the-wss-adapter-for-biztalk?forum=biztalkgeneral ]
    Regards.

  • How do I change multiple list items at once in a SharePoint list with ribbon button

    Hi
    I have a sharepoint list and a ribbon button that open a dialog box with buttons to set color on a row
    The problem is that i can only selecet one item at once to set the color. 
    How can i do so it could set all or a couple items att once to the color i want 
    I want to do this with javascript
    here is the code i use to get the item id and the color code is in a seperate js file
    'use strict';
    var clientContext, hostweburl, parentContext, parentWeb, selectedItem, itemId, listId;
    clientContext = new SP.ClientContext.get_current();
    hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    listId = decodeURIComponent(getQueryStringParameter("SPListId"));
    itemId = decodeURIComponent(getQueryStringParameter("SPListItemId"));
    parentContext = new SP.AppContextSite(clientContext, hostweburl);
    parentWeb = parentContext.get_web();
    selectedItem = parentWeb.get_lists().getById(listId).getItemById(itemId);
    $(document).ready(function () {
    clientContext.load(selectedItem);
    clientContext.executeQueryAsync(OnSuccess, OnFail);
    function OnSuccess() {
    $("#Blue").click(function () {
    selectedItem.set_item('Color', 'Blue');
    selectedItem.update();
    clientContext.load(selectedItem);
    clientContext.executeQueryAsync(function () { window.parent.postMessage('CloseCustomActionDialogRefresh', '*'); }, function (sender, args) { alert('Error:' + args.get_message()); });
    $("#Green").click(function () {
    selectedItem.set_item('Color', 'Green');
    selectedItem.update();
    clientContext.load(selectedItem);
    clientContext.executeQueryAsync(function () { window.parent.postMessage('CloseCustomActionDialogRefresh', '*'); }, function (sender, args) { alert('Error:' + args.get_message()); });
    $("#Red").click(function () {
    selectedItem.set_item('Color', 'Red');
    selectedItem.update();
    clientContext.load(selectedItem);
    clientContext.executeQueryAsync(function () { window.parent.postMessage('CloseCustomActionDialogRefresh', '*'); }, function (sender, args) { alert('Error:' + args.get_message()); });
    $("#Transparent").click(function () {
    selectedItem.set_item('Color', 'No Color');
    selectedItem.update();
    clientContext.load(selectedItem);
    clientContext.executeQueryAsync(function () { window.parent.postMessage('CloseCustomActionDialogRefresh', '*'); }, function (sender, args) { alert('Error:' + args.get_message()); });

    Check if below can help you
    http://sp2010batchedit.codeplex.com/
    http://sharepoint.stackexchange.com/questions/35935/use-view-ribbon-custom-action-on-multiple-list-items
    http://webcache.googleusercontent.com/search?q=cache:XqMO-PRLHQIJ:dannyjessee.com/blog/index.php/2014/06/enabling-custom-ribbon-buttons-dynamically-based-on-multiple-selected-item-values-using-refreshcommandui-and-jsom/+&cd=1&hl=en&ct=clnk&gl=in
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <CustomAction Id="DannyJessee.TestCustomAction"
    Location="CommandUI.Ribbon"
    RegistrationId="100"
    RegistrationType="List">
    <CommandUIExtension>
    <CommandUIDefinitions>
    <CommandUIDefinition
    Location="Ribbon.ListItem.Actions.Controls._children">
    <Button Id="DannyJessee.MarkItemsFinishedButton"
    Command="cmdMarkItemsFinished"
    Image16by16="/_layouts/images/kpinormallarge-0.gif"
    Image32by32="/_layouts/images/kpinormallarge-0.gif"
    LabelText="Mark as Finished"
    TemplateAlias="o2" />
    </CommandUIDefinition>
    </CommandUIDefinitions>
    <CommandUIHandlers>
    <CommandUIHandler Command="cmdMarkItemsFinished"
    CommandAction="javascript:MarkItemsFinished();"
    EnabledScript="javascript:EnableFinishedButton();">
    </CommandUIHandler>
    </CommandUIHandlers>
    </CommandUIExtension>
    </CustomAction>
    <CustomAction Id="DannyJessee.TestScript"
    Location="ScriptLink"
    ScriptSrc="/_layouts/15/CustomRibbonButton/CustomAction.js" />
    </Elements>
    If this helped you resolve your issue, please mark it Answered

  • Auto-included link to list item not working in Workflow or email notification

    I made a workflow straight from my SharePoint site--NOT from SharePoint Designer. (My computer is still running on Windows XP, so I can't download Designer until my boss upgrades me to a newer system.) When creating the workflow, you have the option to include
    a link to the list item by clicking a checkbox. The links don't work in either the email notification or in the workflow properties. Extra characters are being added for some weird reason. (For example, the correct link looks like "https://www.w14b.comcast.net/sites/<yada
    yada>.docx" and the links in the workflow and email look like "http://www.w14spw-po-b1.com/sites/<yada yada>.docx")  I see no place to edit the URL. How do I fix the links???

    Hi,
    Please check if the http://www.w14spw-po-b1.com/sites/ is the url of default zone of the web application where this site resides.
    Here is a similar thread for your reference:
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/d17ad498-0b6f-4b12-9885-b8057fa04d88/sharepoint-2010-workflow-inserting-link-to-list-item?forum=sharepointgeneralprevious
    In addition, Windows XP SP3 is supported for SharePoint designer 2010:
    http://www.microsoft.com/en-in/download/details.aspx?id=16573
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Prevent multiple users from accessing a list item at the same

    Hi,
    I have a scenario where, if a list item is opened (in edit mode) by one user, no other user should able to access it. I mean to checkin/checkout kind of thing which is not possible with sharepoint lists.
    One thing that I have done through infopath 2010, by setting a rule on form load. On form load, set a field's value Assigned To to Current User and then submit data. In case I am getting value of Assigned To getting stored in the list as a new record
    along with all the values from previous fields.
    I want to update the same record not the duplicate record.
    Please suggest a solution for it. 

    Hi
    add a new column to your list COL_EDITING( type yes, no )
    Default value : NO
    Customize your editform.aspx attached to your form, when it open
    A. analyze if COL_EDITING=NO
    If it isn;t alert  an error message ( the item is in edit mode by another user  )  , and close the page
    if it is --->
    B to fill COL_EDITING=YES
    and next permit user to fill the fields in the form
    Also
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • How to delete to-do list items in 5800 XM

    I transfered the data from my old PDA to Nokia 5800 XM. Now there are hundreds of to-do list items with showing up every day at the top of to-do list. I would like to delete lots of them. So, i can delete only one at a time. How do I select and delete a group of them on the phone? No, I am not using MS Outlook.
    I hope this state-of-the-art phone can do something basic as this.
    Thank you.

    Try installing Ovi Suite on a PC, connecting the phone up by USB, and selecting "PC Suite" mode. There should be a section in Ovi Suite for managing the calendar, and it'll let you get through it much quicker.
    An alternative (I'm not familiar with that model) would be to look in "options" for a "Mark/unmark" menu, which should give you "mark many" as an option.
    Help I'm trapped in a sig factory.

  • Retrieving list items from a specific view using CSOM

    How can I query a specific view of a SharePoint List using the C# CSOM? I am dealing with SharePoint Online, so the only option is to use SharePoint.Client.
    I have done this using Javascript, and I know how to do this with SharePoint On-Premises, but I haven't found a way to do with for SharePoint online using C#.

    hi Dkhouri,
    thanks for posting your issue, you can create a specific view of a list using CSOM and C#.
    Kindly find the code snippet below fort he same.
    Code for CSOM :- 
    // Starting with ClientContext, the constructor requires a URL to the
    // server running SharePoint.
    ClientContext context = new ClientContext("http:SiteUrl");
    // Assume the web has a list named "Announcements".
    List announcementsList = context.Web.Lists.GetByTitle("Announcements");
    // This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll"
    // so that it grabs all list items, regardless of the folder they are in.
    CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
    ListItemCollection items = announcementsList.GetItems(query);
    // Retrieve all items in the ListItemCollection from List.GetItems(Query).
    context.Load(items);
    context.ExecuteQuery();
    foreach (ListItem listItem in items)
    // We have all the list item data. For example, Title.
    label1.Text = label1.Text + ", " + listItem["Title"];
    For C# 
    public CamlQuery CreateInventoryQuery(string searchSku)
    var qry = new CamlQuery();
    qry.ViewXml =
    @"<View>
    <Query>
    <Where>
    <BeginsWith>
    <FieldRef Name='SKU' />
    <Value Type='Text'>" + searchSku + @"</Value>
    </BeginsWith>
    </Where>
    </Query>
    </View>";
    return qry;
    Also, checkout below mentioned URLs for more details
    http://www.c-sharpcorner.com/UploadFile/sagarp/sharepoint-2013-caml-query-for-item-id-with-jquery/
    http://msdn.microsoft.com/en-us/library/ff798388.aspx
    I hope this is helpful to you, mark it as Helpful.
    If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Is there any option for voting on a list item in SharePoint 2013?

    Dear All,
    I am looking for a feature vote a for list item from multiple users and need to show consolidated results on that.
    for SharePoint 2013 we have "like", "rating" by using these can we show the consolidated results.
    otherwise is there any alternative for this.
    Thanks & Regards,
    Jithendar

    I haven't seen any OOB vote feature in sharepoint list. It's better to go with "like" or "ratting" options.
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer :)

  • "SharePoint list itme update error : Invalid data has been used to update the list item. The field you are trying to update may be read only."

    Hi Everyone,
    i am facing one problem ...
    when i am updating an SharePoint List item, it is throwing above error....
    This is my code......
     try
                    tbl = getListDateTable("NCR");
                    DataTable dt = tbl;
                    oWebsite = mysite.OpenWeb();
                    oList = oWebsite.Lists["NCR"];
                    SPListItem itemToUpdate = null;
                    foreach (SPListItem listItem in oList.Items)
                        listItem.Update();
                        workOrderID = Convert.ToInt32(txtTitle.Text);
                        itemToUpdate = listItem;
                    //SPListItem itemToUpdate = oList.GetItemById(workOrderID);
                    //itemToUpdate.Fields["Title"].ReadOnlyField = false;
                    //string str = ddlStatus.SelectedValue;
                    itemToUpdate["Title"] = txtTitle.Text;
                    itemToUpdate["JobNumber"] = txtJobNumber.Text;
                    itemToUpdate["PartNumber"] = txtPartNumber.Text;
                    itemToUpdate["PartDescription"] = txtPartDescription.Text;
                    //itemToUpdate["RequiredBy"] = txtRequiredBy.Text;
                    itemToUpdate["ReportedBy"] = txtReportedBy.Text;
                    itemToUpdate["WrittenBy"] = txtWrittenBy.Text;
                    //itemToUpdate["DateOpened"] = txtDateOpened.SelectedDate;
                    //itemToUpdate["DateClosed"] = txtDateClosed.SelectedDate;
                    itemToUpdate.Update();
                    oList.Update();
                   // bind();
                catch (Exception ex)
                    throw ex;
    Thanks
    viswanath

    Hi Viswanath,
    If you are using People/User Type Field Column then use below code methord
    SPUser user = web.EnsureUser(loginName);
    item["UserTypeFieldName"] = user;
    Lookup Type Field Column then use below code methord
    public static SPFieldLookupValue GetLookupFieldFromValue(string lookupValue,string lookupSourceColumn, SPList lookupSourceList)
    SPFieldLookupValue value = null;
    SPQuery query = new SPQuery();
    query.Query = "<Where><Eq><FieldRef Name='" + lookupSourceColumn + "'/><Value Type='Text'>" + lookupValue + "</Value></Eq></Where>";
    SPListItemCollection listItems = lookupSourceList.GetItems(query);
    if(listItems.Count > 0 )
    value = new SPFieldLookupValue(listItems[0].ID,lookupValue);
    return value;
    item["LookupField"] = GetLookupFieldFromValue(lookupfieldValue, lookupSourceColumn, listName);
    Please mark the replies as answers if they help or unmark if not.

  • How to restrict user rights so they can add list items but cannot edit them once saved?

    I appreciate if you can help me with this. My beloved company uses SP2010, and I got the task to solve this issue using it, though I am not a programmer (basic html is still ok).
    I need a simple annual leave list with the following capabilities:
    1. Group of users (~100 members) should be able to create list items in a list that contains annual leave data. Columns are: Name, Leave start date, Leave end date, Team leader, etc.
    2. Once they fill in the new item form, a workflow notifies the team leader to visit the item and set a column "approval status" to approved or rejected.
    3. Based on this column value, another workflow notifies the requestor about the decision.
    4. After approval, users should be able to see their items in the list, but they should not be able to edit it.
    Sounds so simple, but I have big issues with point 4. as Sharepoint does not differentiate create and edit rights to a list item. As a result, requestor can edit dates of the approved items.
    Any hints how to solve this? Can impersonation help with this? Or should I add a new permission level to the site?

    Hello
    We are going to do the following things to accomplish your task
    create a new security permission level that will allow submit only
    create your annual leave list
    assign everyone the submit only permission
    add a workflow to send the email and modify the item permissions
    Ok first things first, on the sharepoint server open a powershell window and type the following powershell:
    $spweb=Get-SPWeb -Identity "<site url>";
    $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();
    Now in your site you will have a new permission level called 'Submit Only'.
    Create your annual leave list and give all users read and submit only permissions.
    Now create a workflow against this list in sharepoint designer.
    Add a new step which should be an impersonization step
    1st action
    add permission: give the user and their manager (i am presuming you are capturing this information in your list so it will be recorded against the item) whatever control you wish, i.e. full control, contribute, etc.
    2nd action
    remove list permission: remove the group you initially gave read and submit only permission to and select the read and submit only permissions to remove from them, i.e. if you added the 'All Users' group, then when performing this action choose to remove
    the read and submit only permissions for the users 'All Users'.
    3rd Action
    Send an Email: Email Manager with notification.
    Regards
    Sergio Giusti
    http://sergioblogs.blog.co.uk/
    Whenever you see a reply and if you think is helpful, click " Vote As Helpful". And whenever you see
    a reply being an answer to the question of the thread, click "
    Mark As Answer".
    i just face the same issue and i create a new Permission level named "Submit Only". but i also have a custom web part that is added to my Create form . so when users tried to access the Create form they will get Access Defined. so is there a way to
    modify the permission level to be able to read web parts ?

  • List item display in Oracle forms 10g

    hi,
    I have created the list item with pop-list in forms.When i retrieve the data using record group in the list item ,i need to display two column data in single list item i.e emp id , emp name .
    select emp_id,emp_name from emp where mgr_id = 100;
    i tried this query in record group but its coming emp id only, not name .
    Can u tell the solution as soon as possible

    Hi,
    In List Item, the First column will show in the list, and the Second column will be stored. To show both columns in list, u have to concatenate both fields and make it as first column. And i think you have to save the EMP_CODE, not EMP_NAME in database.
    So the record group will be
    SELECT EMP_ID || ' - ' || EMP_NAME EMP_NAME, EMP_ID FROM EMP WHERE MGR_ID = 100; Or you can use LOV to display multiple columns.
    Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

  • How to display the count of a list item in Sharepoint Designer?

    How to display the count of a list item in Sharepoint Designer? please reply with the proper code line to add for this.

    Hello,
    What version of sharepoint you are using? Try below approach:
    http://sharepointlogics.com/2010/03/total-count-of-items-in-list-in.html
    Hope it could help
    Hemendra: "Yesterday is just a memory,Tomorrow we may never see"
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer
    Please feel free to unmark answer if does not resolves your problem.

  • Setting Item level access rights on sharepoint list item in ItemAdding event handler

    Hi ,
    I am using sharepoint 2013. I am trying to set item level access rights when a list item is added using the following code snippet,
    public override void ItemAdding(SPItemEventProperties properties)
    base.ItemAdding(properties);
    ConfigureItemSecurity(properties);
    private void ConfigureItemSecurity(SPItemEventProperties properties)
    var item=properties.ListItem;
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite site = new SPSite(properties.SiteId))
    using (SPWeb oWeb = site.OpenWeb())
    item.ParentList.BreakRoleInheritance(true);
    oWeb.AllowUnsafeUpdates = true;
    var guestRole = oWeb.RoleDefinitions.GetByType(SPRoleType.Reader);
    var editRole = oWeb.RoleDefinitions.GetByType(SPRoleType.Editor);
    SPGroup HRGroup = oWeb.SiteGroups.Cast<SPGroup>().AsQueryable().FirstOrDefault(g => g.LoginName=="HR Team");
    SPRoleAssignment groupRoleAssignment = new SPRoleAssignment(HRGroup);
    groupRoleAssignment.RoleDefinitionBindings.Add(guestRole);
    SPUserCollection users = oWeb.Users;
    SPFieldUserValueCollection hm = (SPFieldUserValueCollection)item["HiringManager"];
    SPFieldUserValueCollection pm = (SPFieldUserValueCollection)item["ProjectManager"];
    SPFieldUserValueCollection pmChiefs = (SPFieldUserValueCollection)item["ProjectManagerChief"];
    item.BreakRoleInheritance(true);
    item.RoleAssignments.Add(groupRoleAssignment);
    foreach (SPFieldUserValue staffMember in hm)
    SetRightsOnItem(item, staffMember, editRole);
    foreach (SPFieldUserValue staffMember in pm)
    SetRightsOnItem(item, staffMember, guestRole);
    foreach (SPFieldUserValue staffMember in pmChiefs)
    SetRightsOnItem(item, staffMember, guestRole);
    item.Update();
    private void SetRightsOnItem(SPListItem item, SPFieldUserValue staffMember, SPRoleDefinition role)
    SPUser employeeUser = staffMember.User;
    var userRoleAssignment = new SPRoleAssignment(employeeUser);
    userRoleAssignment.RoleDefinitionBindings.Add(role);
    item.RoleAssignments.Add(userRoleAssignment);
    Nothing is happening though... Is the event handler the right place to do this?
    thank you

    Hi ,
    You can refer to the code working in my environment:
    using System;
    using System.Security.Permissions;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Utilities;
    using Microsoft.SharePoint.Workflow;
    namespace ItemLevelSecurity.ItemSecurity
    /// <summary>
    /// List Item Events
    /// </summary>
    public class ItemSecurity : SPItemEventReceiver
    /// <summary>
    /// An item was added.
    /// </summary>
    public override void ItemAdded(SPItemEventProperties properties)
    SPSecurity.RunWithElevatedPrivileges(delegate()
    try
    using (SPSite oSPSite = new SPSite(properties.SiteId))
    using (SPWeb oSPWeb = oSPSite.OpenWeb(properties.RelativeWebUrl))
    //get the list item that was created
    SPListItem item = oSPWeb.Lists[properties.ListId].GetItemById(properties.ListItem.ID);
    //get the author user who created the item
    SPFieldUserValue valAuthor = new SPFieldUserValue(properties.Web, item["Created By"].ToString());
    SPUser oAuthor = valAuthor.User;
    //assign read permission to item author
    AssignPermissionsToItem(item,oAuthor,SPRoleType.Reader);
    //update the item
    item.Update();
    base.ItemAdded(properties);
    catch (Exception ex)
    properties.ErrorMessage = ex.Message; properties.Status = SPEventReceiverStatus.CancelWithError;
    properties.Cancel = true;
    public static void AssignPermissionsToItem(SPListItem item, SPPrincipal obj, SPRoleType roleType)
    if (!item.HasUniqueRoleAssignments)
    item.BreakRoleInheritance(false, true);
    SPRoleAssignment roleAssignment = new SPRoleAssignment(obj);
    SPRoleDefinition roleDefinition = item.Web.RoleDefinitions.GetByType(roleType);
    roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
    item.RoleAssignments.Add(roleAssignment);
    Thanks,
    Eric
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected].
    Eric Tao
    TechNet Community Support

  • Changing the Modified Date of a List Item using the SharePoint Client Object Model (C#) with Contribute Permission

    I have a small snippet of code that I use to update the Modified Date of a list item and it works great for users with Full Control permissions.  However, for users with just Contribute access to the site the code doesn't work.  Instead, SharePoint
    just updates the Modified Date to now.
    I did some testing, and narrowed down the specific permission level that allows updating of Modified dates and oddly enough, it's the "Manage Permissions" level.
    Has anyone run into this issue? If so, how do I work around this and update the Modified date as a user with only Contribute access to a site/library?
    Here's the code:
    DateTime Test = new DateTime(2012, 5, 4);
    ListItem li = list.GetItemById(itemID);
    li["Modified"] = Test;
    li.Update();
    ct.ExecuteQuery();
    Thanks,
    Max

    Hello,
    As a workaround you can pass admin credential in your code because as per my knowledge contributor can't update default columns like: created by, modified by, modified, created.
    ClientContext clientContext = newClientContext(siteUrl);
    ClientContext.Credentials = newNetworkCredential(UserName, Password, Domain);
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

Maybe you are looking for