Item based security on List

Hi,
I have a list with 3 columns
Column Name| Column Type
Employee | Person/Group
First Name | Single Line Text
Last Name | Single Line Text
As the Employee column is of type "Person/Group", I want to apply item based security on this list. For example if Person A is logged in, he MUST NOT be able to update record of others, But yes, he should have rights to update his own Row (Item).
Please let me know how can i achieve such item based security in list ?

Hi,
From your description, I know you want to restrict users to edit items when he is the owner of current item.
You can try these codes below:
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace VisualWebPartProject1.VisualWebPart1
[ToolboxItemAttribute(false)]
public partial class VisualWebPart1 : WebPart
// Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
// the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
// for production. Because the SecurityPermission attribute bypasses the security check for callers of
// your constructor, it's not recommended for production purposes.
// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
public VisualWebPart1()
protected override void OnInit(EventArgs e)
base.OnInit(e);
InitializeControl();
protected void Page_Load(object sender, EventArgs e)
SPSecurity.RunWithElevatedPrivileges(delegate()
SPWeb currentWeb = SPContext.Current.Web;
String currentUserName = currentWeb.CurrentUser.LoginName;
SPSite site = new SPSite("http://sp/sites/sharepoint2013");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["ListA"];
web.AllowUnsafeUpdates = true;
foreach (SPListItem item in list.Items)
string username = GetUser(item, item.Fields["Employee"]).LoginName;
//break from parent permissions
item.BreakRoleInheritance(false);
//delete any existing permissions in the
//case that this is an update to an item
SPRoleAssignmentCollection currentRoles = item.RoleAssignments;
foreach (SPRoleAssignment role in currentRoles)
role.RoleDefinitionBindings.RemoveAll();
role.Update();
if (username.Equals(currentUserName))
//create"contributor" role
SPRoleDefinition roleDef = web.RoleDefinitions.GetByType(SPRoleType.Contributor);
SPRoleAssignment roleAssignment =
new SPRoleAssignment(
currentUserName,
string.Empty,
string.Empty,
string.Empty);
roleAssignment.RoleDefinitionBindings.Add(roleDef);
//update list item with new assignment
currentRoles.Add(roleAssignment);
item.SystemUpdate();
else
//create"reader" role
SPRoleDefinition roleDef = web.RoleDefinitions.GetByType(SPRoleType.Reader);
SPRoleAssignment roleAssignment =
new SPRoleAssignment(
currentUserName,
string.Empty,
string.Empty,
string.Empty);
roleAssignment.RoleDefinitionBindings.Add(roleDef);
//update list item with new assignment
currentRoles.Add(roleAssignment);
item.SystemUpdate();
private SPUser GetUser(SPListItem item, SPField userField)
string currentValue = item[userField.Title].ToString();
SPFieldUser field = (SPFieldUser)userField;
SPFieldUserValue fieldValue = (SPFieldUserValue)field.GetFieldValue(currentValue);
return fieldValue.User;
The screenshot below is my result:
Vincent Han
TechNet Community Support

Similar Messages

  • Display list items based on another list item

    Hi All
                I want to display the list item based on another list item, but its not working.
    This is my code:
    /*WHEN-NEW-FORM-INSTANCE*/---Its working.
    DECLARE
       rg_district   recordgroup;
       rg_name       VARCHAR2 (40) := 'district';
       vtemp         NUMBER;
    BEGIN
       rg_district := FIND_GROUP (rg_name);
       IF ID_NULL (rg_district)
       THEN
          rg_district :=
             CREATE_GROUP_FROM_QUERY (rg_name,
                                      'select dist,dist from district_mas'
          vtemp := POPULATE_GROUP (rg_district);
          POPULATE_LIST ('BLOCK3.DISTRICT', rg_name);
       END IF;
       END;
    */WHEN-LIST-CHANGED*/---Not working. Cannot populate the list based on the List
       DECLARE
       rg_branch   recordgroup;
       rg_name1     VARCHAR2 (1000) := 'branch';
       vtemp       NUMBER;
    BEGIN
       rg_branch := FIND_GROUP (rg_name1);
       IF NOT ID_NULL (rg_branch)
       THEN
          DELETE_GROUP (rg_name1);
          rg_branch :=
             CREATE_GROUP_FROM_QUERY
                ('rg_branch',
                    'SELECT branch FROM dist_branch WHERE district IN (SELECT DIST FROM DISTRICT_MAS WHERE DISTRICT ='
                 || :BLOCK3.DISTRICT
          vtemp := POPULATE_GROUP (rg_branch);
          POPULATE_LIST ('BLOCK3.BRANCH', rg_branch);
       END IF;
       END;
    Table:
    CREATE TABLE DISTRICT_MAS
      DIST  VARCHAR2(100 CHAR)
    CREATE TABLE DIST_BRANCH
      DISTRICT  VARCHAR2(100 CHAR),
      BRANCH    VARCHAR2(100 CHAR)
    Values:
    insert into district_mas values('chennai');
    insert into district_mas values('coimbatore');
    insert into dist_branch values('chennai','chennai_north');
    insert into dist_branch values('coimbatore','Podanur');
    Regards
    Shagar M

    Hmm, not tested.
    try this..
    --*/WHEN-LIST-CHANGED*/
       DECLARE
       rg_branch       recordgroup;
       rg_name1     VARCHAR2 (1000) := 'branch';
       vtemp        NUMBER;
       QT            VARCHAR2(10) :='''';
    BEGIN
       rg_branch := FIND_GROUP (rg_name1);
       IF NOT ID_NULL (rg_branch)
       THEN
          DELETE_GROUP (rg_name1);
          rg_branch :=
             CREATE_GROUP_FROM_QUERY
                ('rg_branch',
                    'SELECT branch FROM dist_branch WHERE district IN (SELECT DIST FROM DISTRICT_MAS WHERE DISTRICT ='
                 || QT||:BLOCK3.DISTRICT||QT||')'
          vtemp := POPULATE_GROUP (rg_branch);
          POPULATE_LIST ('BLOCK3.BRANCH', rg_branch);
       END IF;
    END;
    Hope this works..
    Hamid

  • Dynamically changing the list item based on another list item

    Hi all,
    I have two fields that are list items.
    First list item contain two list values: Regular and One-time
    In second list item if user select the Regular then below values should appear:
    Daily wages
    Activity Linked
    Fixed Contracts.
    Contract Staff
    Outsourced
    if user select the one-time then below values should appear:
    Projects
    Repairs & Maint.
    Please do the needful.

    First list item contain two list values: Regular and One-timeYou simply need to add a conditional check to the When-List-Changed (WLC) trigger to see which value was selected. Then, as Manu suggests, you will populate the Poplist based on the selected value.
    For an example of how to dynamically populate a Poplist item, take a look at: Forms: How to Dynamically Populate a Poplist.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Filter list items based on security groups o365

    How to filter list items based on security groups in o365.

    Hi,
    According to your description, my understanding is that you want to filter list items based on the Office 365 security groups.
    If that is the case, I suggest you can create a data view to filter the list items with CAML Query like below:
    <Where>
    <Membership Type="CurrentUserGroups">
    <FieldRef Name="VisibleToGroup"/>
    </Membership>
    </Where>
    For more information, please refer the detailed article below:
    SharePoint - Filtering a View by Group Membership
    Thanks
    Best Regards
    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]

  • Auto Creation of new requisitions based on a list of items

    Auto Creation of new requisitions based on a list of items
    We are starting discussions to determine how we could auto-create requisitions based on a list of servers in order to perform periodic health checks. 
    One approach we thought about was creating one service request that could spawn multiple requests, again based on a list and using a set schedule (weekly, monthly, quarterly, yearly, etc.)
    Has anyone implemented this and can provide some guidance/tips?

    You can check this article for more references on how to use sp_helptext object_name stored procedure:
    http://blog.sqlauthority.com/2007/05/25/sql-server-stored-procedure-to-display-code-text-of-stored-procedure-trigger-view-or-object/
    I also suggest trying commercial tools to sync and compare the stored procedures between two databases. We used
    ApexSQL Diff, but I've also heard some good things about
    Devart's tools.

  • Workflow to grant access to each List item based on a column value

    Hi,
    I have 2 lists Risks and RisksLookup.
    In Risks, I have Title, Description, service impacted and status columns.
    In RisksLookup, I have service impacted, AD1, AD2, AD3, AD4 and AD5.
    I have a requirement where in I have to write a Workflow to provide access to each List item based on the value of service impacted. i.e. If service impacted in Risks List is Client A, I have to lookup what all AD groups are present for Client A in RisksLookup
    List and provide access to only those groups for that item.
    Regards, Shreyas R S

    Hi
    another approach
    create 5 more lists, dedicated to each impacted service. for  Each one these lists apply needeed right ( based onAD groups )Keep you main list where first level will add new items . Attach a workflow to this main list, which will start when an item
    is added and which will add specific item's value to his new list ( based on impacted service value )
    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.

  • Get Item price based on Price List

    Hi all,
    anyone has some sample of how to get the price for an item based on a specified price list, selected by the user, following the SAP's rules for assigning item price?
    I've used the GetItemPrice method, but it doesn't need a price list reference and i think it gives back the basic price of the item.
    I'm able to get the price list and the item code. How can i get the correspondig price (unit price) for that item?
    Thanks in advance.
    Nick

    Thanks Rasmus,
    i've done. I get the PriceList currently selected by the combo box and update the price list used by the BP, and after that i use the getitemprice.
    So it should work now, i get the correct prices related to the pricelist selected and i think that using the getitemprice the price that i obtain follows the sap B1 logic in assigning prices.
    After that i'm considering to set back the pricelist on the BP to the one that is originally stored in the BP.
    Thanks for your help

  • Listing Items based on criteria e.g. High Priority Items First.

    Hi,
    One of our customers have a need to List High Priority Items first on the WebTools site.
    Let's take two ItemCodes for example: Printer001, and, Monitor001.
    >> If these two items are included in the same category then Monitor001 will appear before Printer001 as WebTools sorts in alphabetic ascending order;
    >> But, our customer wants Printer001 to appear before Monitor001 as it is an Item higher in priority that Printer001.
    I can think of two possible solutions:
    1/2) Prefix Items with a number or letter to have it appear first in the WebTools default sort order. E.g. Rename "Monitor001" as "AMonitor001". This will not be possible for existing Items in SAP, so it doen't solve the issue,
    Or,
    2/2) Customize the Default WebTools Item List block to sort Items based on a User Define field called "pririty". Which might require a lot of effort.
    Please advise if anyone else has solved similar issue and how.
    Thanks very much for your replies in advance.

    Hey Kafil ... I think you may be stuck modifying the parts list page or creating something from scratch. I'm not aware of an easy way to do this out of the box.

  • In system settings 15 item are not accessible, get the message: cannot open it, is not possible on intel based MAC. Items like security, i cloud user and groups network and more

    in system settings 15 item are not accessible, get the message: cannot open it, is not possible on intel based MAC. Items like security, iCloud user and groups network and more.
    Genius bar told me to erase the harddisk and install OSX Maverick again. This has not changed the problems with the system settings

    You need to Repartition the drive as One partition which will erase all data from it and then reinstall OS X. then with the initial setup system you chose the language on the first screen that comes up. That sets the language for the whole system.
    There is no other way of completely removing certain information created by a previous owner. this hold strue whether you are selling or give a Mac to someone.
    To do the repartitioning you need to use the Online Internet Recovery system, if the Mac came with Lion 10.7 or above, or from the original system reinstall discs that came with it when it was new.

  • CAML Query to Sort SharePoint list items based on Modified date

    hi ,
    can we sort sharePoint list items based on 'Modified' column, the sorting should be done up to milliseconds level.
    currently i am using CAML query as below
    <OrderBy><FieldRef Name='Modified' Type='DateTime' IncludeTimeValue='TRUE' Ascending='False'/></OrderBy>but its not considering milliseconds while sorting.
    Thanks and Regards,
    venkatesh.

    Veda, thanks but I'm not really a hardcore C# coder.
    We found more elegant solution was to create a List View which returns all records that should be deleted, based on our own custom deletion criteria, and then create an very simple SSIS Package in Visual Studio using the
    Sharepoint Connectors for SSIS to delete all Sharepoint List Items returned from that List View. The Sharepoint Destination Connector has a delete operation.
    This worked for us and didn't require any coding.

  • Populate the values  to  list item based on a check box

    Hi,
    How can i populate the values from a field on the form to one list item based on a check box,
    the pseudo code is like,
    if checkbox = checked then
    populate the particular field value to the list item;
    checkbox = unchecked;
    next_record;
    end if;
    Thanks
    Bcj

    To populate a Tlist item, do the following:
    1. Create a TLIST item in the EMP block. and give it a height to accommodate several names.
    2. Using the TLIST property pallete:
    a. Set the Column Name property to EMPNO
    b. Click on the Elements in List property. Delete each List Element and delete each List Item Value. If you don't do this you will get an error when you compile.
    3. Create a record group using this query:
    select ename, to_char(empno) from emp
    4. Create a WHEN-NEW-FORM-INSTANCE trigger, and place this code inside the trigger:
    Declare
    err_num number;
    Begin
    clear_list('YOUR_TLIST');
    err_num := populate_group('YOUR_RECORD_GROUP');
    If err_num = 0 Then
    populate_list('YOUR_TLIST', 'YOUR_RECORD_GROUP');
    Else
    message('Error populating Tlist');
    message('Error populating Tlist');
    End If;
    End;
    5. Compile and run the form. The ENAMEs will appear in the TList, and each ENAME will have a value equal to its EMPNO.

  • Want 2 populate value in 2nd list item based on value selected in 1st list?

    Want 2 populate value in 2nd list item based on value selected in 1st list?

    Gaurav -
    The 3rd list will not populate because nothing has been selected yet in list 2. The value in list 2 is null, so the loop to populate list (3) has nothing to load. Try the following below. This should seed your 2nd list so the 3rd list will populate.
    You will have to declare first_record boolean and first_value to match DESCC.
    first_record := true; -- NEW *****
    Clear_List('BLOCK2.ITEM2');
    FOR CurRec IN (SELECT UNIQUE DESCC DESCC FROM LUTT where LUTT.IDD = :BLOCK2.ITEM1)
    LOOP
    if first_record = true then -- NEW SECTION *****
    first_value := CurRec.DESCC;
    first_record := false;
    end if;
    Add_List_Element('BLOCK2.ITEM2',1,CurRec.DESCC,CurRec.DESCC);
    END LOOP;
    :block2.item2 := first_value; -- NEW *****
    Clear_List('BLOCK2.ITEM3');
    FOR CurRec2 IN (SELECT UNIQUE DESCC DESCC FROM LUTT where LUTT.DESCC = :BLOCK2.ITEM2)
    LOOP
    Add_List_Element('BLOCK2.ITEM3',2,CurRec2.DESCC,CurRec2.DESCC);
    END LOOP;
    My name is Ken, 1990 is when I started using Oracle Forms 3.0, character based in the Unix environments. And you are very welcome.

  • Form based security in WebLogic 7.0 - back button quirk

    I have an application comprised of several JSPs that are protected via Form based
    security and enforce an SSL connection via the appropriate declarations in the
    web.xml. This aspect of the application seems to be working with the exception
    of one small quirk.
    If a user presses that back button until such time as the receive the container
    provided login page once again, and subsequently provide a valid user id and password,
    they are NOT successfully logged in. Rather, they receive the ugly 403 Forbidden
    error that states that the server understood the request, but is refusing to fufill
    it. This only seems to happen given the above course of events involving the
    use of a back button in the browser (or selection of an item from the history
    list). I suspect that this has something to do with the session id being cached
    or something, but I'm not sure? Can anyone offer any assistance on this one?
    Also, does anyone know of a way of preventing the user from bookmarking this container
    provided login page as this also seems to be causing problems for users. If they
    bookmark the first protected page of the application all is fine, but if they
    bookmark the login page they receive the 403 error.
    Thanks in advance!

    The cure for the symtops described below was to simply add a welcome-file-list
    element with appropriate welcome pages to the web.xml descriptor. It makes sense
    now that I have worked it out.
    Todd
    "Todd Gould" <[email protected]> wrote:
    >
    I have an application comprised of several JSPs that are protected via
    Form based
    security and enforce an SSL connection via the appropriate declarations
    in the
    web.xml. This aspect of the application seems to be working with the
    exception
    of one small quirk.
    If a user presses that back button until such time as the receive the
    container
    provided login page once again, and subsequently provide a valid user
    id and password,
    they are NOT successfully logged in. Rather, they receive the ugly 403
    Forbidden
    error that states that the server understood the request, but is refusing
    to fufill
    it. This only seems to happen given the above course of events involving
    the
    use of a back button in the browser (or selection of an item from the
    history
    list). I suspect that this has something to do with the session id being
    cached
    or something, but I'm not sure? Can anyone offer any assistance on this
    one?
    Also, does anyone know of a way of preventing the user from bookmarking
    this container
    provided login page as this also seems to be causing problems for users.
    If they
    bookmark the first protected page of the application all is fine, but
    if they
    bookmark the login page they receive the 403 error.
    Thanks in advance!

  • Adding an External Application that uses J2EE Form Based Security

    I'm trying to add an External application that uses the J2EE Form based security. i.e. uses j_username, j_password and posts to j_security_check.
    I don't really see how Oracle SSO will support this. The container needs to take control of a clients request and determines when the "Login" page is presented to establish credentials. Posting directly to j_security_check isn't working for me.
    I'm using Sybase EAServer 4.12 as the external application.
    Is this supported in Oracle SSO?
    Do I need to provide a different mechanism for logging user's in?
    Also, can someone explain what the benefit would be if I configured the EAServer app as a "Partner" app? I would still have to provide an interface for login. The input would be different but the end result would be the same I guess. What advantages does a Partner app have?
    Lastly, is there an NNTP server for these forums?
    Thanks.
    Darrell

    The cure for the symtops described below was to simply add a welcome-file-list
    element with appropriate welcome pages to the web.xml descriptor. It makes sense
    now that I have worked it out.
    Todd
    "Todd Gould" <[email protected]> wrote:
    >
    I have an application comprised of several JSPs that are protected via
    Form based
    security and enforce an SSL connection via the appropriate declarations
    in the
    web.xml. This aspect of the application seems to be working with the
    exception
    of one small quirk.
    If a user presses that back button until such time as the receive the
    container
    provided login page once again, and subsequently provide a valid user
    id and password,
    they are NOT successfully logged in. Rather, they receive the ugly 403
    Forbidden
    error that states that the server understood the request, but is refusing
    to fufill
    it. This only seems to happen given the above course of events involving
    the
    use of a back button in the browser (or selection of an item from the
    history
    list). I suspect that this has something to do with the session id being
    cached
    or something, but I'm not sure? Can anyone offer any assistance on this
    one?
    Also, does anyone know of a way of preventing the user from bookmarking
    this container
    provided login page as this also seems to be causing problems for users.
    If they
    bookmark the first protected page of the application all is fine, but
    if they
    bookmark the login page they receive the 403 error.
    Thanks in advance!

  • [Forum FAQ] A content management tool with dashboard based on SharePoint List

    1. 
    Scenario:
    The SharePoint OOTB List has saved us a lot of time on managing mess data. It provides three forms to create/view/edit items, the ability to save the views we want with some specific filtering and sorting condition, versioning for easy restoring, and we
    can make it advanced with workflow contains the specific business logic.
    However, if there is a need for better user experience, interacting with the public APIs and a bit of script to customize the web page would be required.
    Suppose there is a requirement like this:
    We need a content collection tool which collects ideas from contributors, the newly ideas will be reviewed by reviewers.
    We may need to filter the list in a convenient way, get the wanted result with the data from the list and display in a chart or rank list. 
    We can add some buttons in Metro style to display the counting result of the data from the list dynamically. When we click them, the list will be filtered and sorted to display a friendly set of items. Also, we need to display a trend of the mess data graphically
    in some beautiful charts.  If we want to find out some outstanding contributors, top contributor board would be more comfortable than the top N items in the OOTB list view.
    The page would look like this:
    2. 
    Introduction:
    Engineers will come up with some ideas in the daily job and write a content to enlighten others. Reviewers will help to review ideas or contents and publish the contents if qualified.
    The complete process looks like this:
    As we can see, only the approved idea can be written as a content and only the approved content can be published.
    2.1
    How it works
    We build the whole tool in one page. All ideas and contents will be saved in a custom list. This is how it looks like:
    There are three parts in this page:
    1       
    2       
    2.1       
    2.1.1       
    Top menu
    The top menu contains three elements:
    A Drop Down menu for filtering data by team, it will refresh the other two parts with the filtered data:
    A hyperlink “STATISTIC” links to a PowerBI report whose data source is the custom list.
    A hyperlink “FEEDBACK” for collecting feedbacks:
    The feedbacks will be saved in another list:
    2.1.2       
    Information menu
    This part will display the calculated data retrieved from the list within tiles, chart and ranking list.
    The tiles can be clicked to filter and refresh the list view.
    2.1.3       
    List view
    A list stores all ideas and contents with the properties needed. It can be filtered by the Top menu and Information menu.
    The customization on the OOTB custom list template makes it more powerful and more suit for this scenario:
    1. An item leveled comment feature (based on OOTB Tags & Notes feature) for other users make comments to an idea or content:
    2. Title column: When there is no attachment in the current item, it redirects to the default DisplayForm page. If there is, it will open the attachment (usually a .docx file) in Word Online in a new tab.
    3. ECB menu: Add some custom shortcuts for popular actions:
    4. A hyperlink column stores the hyperlink points to the website where the content is published to.
    3.   
    How to achieve it
    This solution will be hosted in SharePoint Online environment, so we do all the job using JavaScript, REST API and Client Object Model.
    The Drop Down menu, tiles, rank list are generated with some HTML+CSS.
    The Trend Chart, we take advantage of the Combo chart in the Google chart library.  
    The list view is hosted in a <iframe> which can be easily filtered and refreshed by just passing a generated URL with query string.
    For the customization on the list view and the ECB menu, JSLink with Client Object Model would be OK.
    3.1
    Specific to every part
    3.1.1       
    Top menu
    3.1.1.1 
    Drop Down menu for retrieving filtered data and refreshing the display of the related controls
    When user selects a team here, there will be a request sent out for retrieving items of the list. By default, the limit is 100 when using REST API to get list items, so we can append a “$top=1000” to require more items from server.
    Code snippet like this:
    $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items?$top=1000",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
    console.log("getListItems succ");
    console.log(data);
    error: function (data) {
    alert("getListItems error");
    //failure(data);
    Then we will get the “data” as a JSON format string, it contains all the values we need from the list:
    We can get the values we want like this:
    //get item Count
    var arr = [], len;
    for(key in data.d.results)
    arr.push(key);
    len = arr.length;
    for(var ii=0; ii<len; ii++)
    var team = data.d.results[ii].Team;
    var month = data.d.results[ii].Month;
    As we need to know the counts of each type of ideas or contents, we use an array for saving the counters:
    //ary to store all counters for tiles: all/pendingIdea/pendingContent/my/approvedIdea/approvedContent
    var aryAllCounters = [0,0,0,0,0,0];
    for(var ii=0; ii<len; ii++)
    //get pendingIdeaCount
    if(data.d.results[ii].Statuss === 'Pending')
    aryAllCounters[1]++;
    Once all the numbers are ready, we can do the refreshing.
    As the list view page is hosted in a <iframe>, all we need to do is passing a constructed URL with query string:
    url_team = URL + "?FilterField1="+FIELD_MYTEAM+"&FilterValue1=" + sel_val;
    $iframe.attr('src', url_team);
    3.1.1.2 
    Hyperlink for popping up a dialog to collect feedbacks
    The feedback dialog hosts another page which contains two buttons and one text area.
    The HTML code of the FEEDBACK button:
    <a id="feedback" href="#" onclick="javascript:openDialogBox('../SitePages/Feedback.aspx');">FEEDBACK</a>
    The openDialogBox() function:
    function openDialogBox(url){
    var options = SP.UI.$create_DialogOptions();
    options.url = url;
    options.height = 130;
    options.width = 425;
    options.title = "Feedback";
    SP.UI.ModalDialog.showModalDialog(options);
    In the Feedback.aspx page, when user click submit button, we will save the content of the text area into the feedback list:
    function addListItem()
    this.clientContext = new SP.ClientContext.get_current();
    this.oList = clientContext.get_web().get_lists().getByTitle('Feedback');
    var itemCreateInfo = new SP.ListItemCreationInformation();
    this.oListItem = this.oList.addItem(itemCreateInfo);
    //set person field
    var userValue = new SP.FieldUserValue();
    //userValue.set_lookupId(this.currentUser.get_id());
    userValue.set_lookupId(_spPageContextInfo.userId);
    oListItem.set_item('Provider', userValue);
    //Sets the specified field value
    oListItem.set_item('Title', str);
    //datetime field
    var currDate = new Date();
    oListItem.set_item('Submit_Time',currDate);
    oListItem.update();
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded_add), Function.createDelegate(this, this.onQueryFailed));
    3.1.2       
    Information menu
    3.1.2.1 
    Tile shortcut
    In the click event of the tiles, the code will pass a generated URL with query string to the <iframe>:
    //filter list only
    $tile.click(function(){
    //distinguish tiles by id
    var v = $(this).attr('id');
    switch(v)
    case S_MY_CONTENT:
    url_team1 = URL + "?FilterField1="+FIELD_COMPOSER+"&FilterValue1=" + currentUsername;
    break;
    case S_PENDING_IDEA:
    url_team1 = url_team + "&FilterField2="+FIELD_STATUS+"&FilterValue2=Pending&FilterField3="+FIELD_IDEATYPE+"&FilterValue3=Idea";
    break;
    $iframe.attr('src', url_team1);
    3.1.2.2 
    Trend chart
    The chart will be initialized with the numbers by month stored in a 3D array:
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawVisualization);
    function drawVisualization(ary)
    // Some raw data (not necessarily accurate)
    var data = google.visualization.arrayToDataTable(ary);
    var view = new google.visualization.DataView(data);
    view.setColumns([0, 1,
    { calc: "stringify",
    sourceColumn: 1,
    type: "string",
    role: "annotation"
    2]);
    // Create and draw the visualization.
    var ac = new google.visualization.ComboChart(document.getElementById('chart1'));
    ac.draw(view, {
    //legend: 'top',
    legend: {
    title : '',
    //width: 0,
    //height: 285,
    vAxis: {title: "", format:'#',viewWindowMode:'explicit',
    viewWindow:{
    min:0
    },ticks: ticks
    //hAxis: {title: ""},
    lineWidth: 4,
    bar: {groupWidth: "60%"},
    seriesType: "bars",
    series: {1: {type: "line"}},
    chartArea:{
    colors: ['#A4C400', '#F9A13B']
    3.1.2.3 
    Top contributors rank list
    When retrieving list items, we can get the “AuthorId” which represents the id of the user in the siteUserInfoList. We run another request to retrieve all items in the siteUserInfoList which stores the username with the URL of profile.
    Then we can use a hash table(provided by jshashtable.js) to store the user id, username and profile URL:
    $.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/siteUserInfoList/Items",
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
    console.log(data);
    //get item Count
    var arr = [], len;
    for(key in data.d.results)
    arr.push(key);
    len = arr.length;
    var ht_authors = new Hashtable();
    for(var ii=0; ii<len; ii++)
    if(authorSet.contains(data.d.results[ii].Id))
    if(data.d.results[ii].Picture != null)
    ht_authors.put(data.d.results[ii].Id, data.d.results[ii].Title+'|'+data.d.results[ii].Picture.Url);
    else
    ht_authors.put(data.d.results[ii].Id, data.d.results[ii].Title+'|');
    console.log("ht_authors.keys(): "+ht_authors.keys());
    console.log("ht_authors.values(): "+ht_authors.values());
    error: function (data) {
    alert("error");
    //failure(data);
    3.1.3       
    List view
    For the Comment button, custom title link and the custom published link of each item, we can use JSLink to achieve.
    Comment button: It is supposed to be the OOTB “Type” column, I change the icon and modify the click event of it to pop up a comment dialog which take advantage of the OOTB “Tags&Notes” feature;
    Custom Title link: As there will be two situations of an item: has attachment or not. We will need to run a request to get the URL of attachment and change the hyperlink of the Title field accordingly:
    (function () {
    // Create object that have the context information about the field that we want to change it output render
    var linkFiledContext = {};
    linkFiledContext.Templates = {};
    linkFiledContext.Templates.Fields = {
    //"Attachments": { "View": AttachmentsFiledTemplate }
    "LinkTitle": { "View": TitleFieldTemplate },
    "Published_x0020_Link": { "View": PublishedLinkFieldTemplate },
    "DocIcon": { "View": DocIconFieldTemplate },
    "MyTeam": { "View": MyTeamFieldTemplate }
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(linkFiledContext);
    function DocIconFieldTemplate(ctx)
    var htmlStr = "";
    var listId = ctx.listName;
    var itemId = ctx.CurrentItem.ID;
    var s = listId + "," + itemId;
    htmlStr += "<img width='16' height='16' class=' ms-draggable' alt='Comment' src='"+_spPageContextInfo.webAbsoluteUrl+"/Shared%20Documents/img/comment-icon.png' border='0' ms-draggableragId='0' onclick='CommentIcon(\""+ s +"\")'></img>";
    return htmlStr;
    function CommentIcon(s)
    var listId = s.split(',')[0];
    var itemId = s.split(',')[1];
    var url=_spPageContextInfo.webAbsoluteUrl+"/_layouts/15/socialdataframe.aspx?listid="+listId+"&id="+itemId+"&mode=1";
    console.log(url);
    openCustomDialog(url,"Comment",650,520);
    function openCustomDialog(pageUrl,title,width,height)
    SP.UI.ModalDialog.showModalDialog({
    url: pageUrl,
    width: width,
    height: height,
    title: title,
    dialogReturnValueCallback: function (result){
    if(result== SP.UI.DialogResult.OK)
    parent.window.location.href=parent.window.location.href;
    function PublishedLinkFieldTemplate(ctx)
    //console.log(ctx);
    var htmlStr = "";
    var itemPublishedLink = "";
    var itemPublishedLinkDesc = "";
    if((ctx.CurrentItem.Published_x0020_Link != ''))
    itemPublishedLink = ctx.CurrentItem.Published_x0020_Link;
    itemPublishedLinkDesc = ctx.CurrentItem["Published_x0020_Link.desc"];
    htmlStr = "<a href='" + itemPublishedLink + "' target='_blank'>" + itemPublishedLinkDesc + "</a>";
    return htmlStr;
    function MyTeamFieldTemplate(ctx)
    var htmlStr = "";
    var itemMyTeam = "";
    if((ctx.CurrentItem.MyTeam[0] != undefined) && (ctx.CurrentItem.MyTeam[0] != null))
    itemMyTeam = ctx.CurrentItem.MyTeam[0].lookupValue;
    htmlStr = itemMyTeam;
    return htmlStr;
    function TitleFieldTemplate(ctx) {
    console.log(ctx.CurrentItem);
    var itemId = ctx.CurrentItem.ID;
    var itemTitle = ctx.CurrentItem.Title;
    var listName = ctx.ListTitle;
    var siteUrl = _spPageContextInfo.webAbsoluteUrl;
    var listUrl = _spPageContextInfo.webAbsoluteUrl + "/Lists/" +listName;
    var fileNames = getAttachmentsNames(listName, itemId);
    console.log(fileNames);
    var fileNameAry = fileNames.split("|");
    var htmlStr = "";
    //check the attachment existence
    if(fileNameAry[0] != '')
    for(var j = 0; j < fileNameAry.length; j++)
    var fileName = fileNameAry[j];
    var s1 = "<a class=\"ms-listlink ms-draggable\" onmousedown=\"return VerifyHref(this, event, '1', 'SharePoint.OpenDocuments.3', '1";
    //1``https://microsoft.sharepoint.com/teams/spfrmcs
    var s2 = "/_layouts/15/WopiFrame.aspx?sourcedoc=";
    //2``/teams/spfrmcs/Lists/Content%20Pool
    var s3 = "/Attachments/";
    //3``137
    var s4 = "/";
    //4``[Forum FAQ] Highlight the list tab in Quick Launch when the list view changes.docx
    var s5 = "&action=default'); return false;\" href=\"";
    //5``https://microsoft.sharepoint.com/teams/spfrmcs/Lists/Content Pool
    var s6 = "/Attachments/";
    //6``137
    var s7 = "/";
    //7``[Forum FAQ] Highlight the list tab in Quick Launch when the list view changes.docx
    var s8 = "\" target=\"_blank\" DragId=\"1\">";
    //8``Highlight the list tab in Quick Launch when the list view changes
    var s9 = "</a>";
    var s = s1+siteUrl+s2+listUrl+s3+itemId+s4+fileName+s5+listUrl+s6+itemId+s7+fileName+s8+itemTitle+s9;
    htmlStr += s;
    //console.log(htmlStr);
    if (j != fileNameAry.length - 1)
    htmlStr += "<br/>";
    //if no attachments, set the <a> point to displayForm
    else
    htmlStr += "<a class='ms-listlink ms-draggable' onclick='EditLink2(this,28);return false;' onfocus='OnLink(this)' href='" + siteUrl + "/_layouts/15/listform.aspx?PageType=4&ListId=%7BE54A4FBB%2DDDC2%2D4F7E%2D8343%2D8A1C78757CF4%7D&ID=" + itemId + "&ContentTypeID=0x010079A1D928FF77984C80BFEF1D65C3809F' target='_blank' DragId='0'>" + itemTitle + "</a>";
    return htmlStr;
    function getAttachmentsNames(listName,itemId) {
    var url = _spPageContextInfo.webAbsoluteUrl;
    var requestUri = url + "/_api/web/lists/getbytitle('" + listName + "')/items(" + itemId + ")/AttachmentFiles";
    var str = "";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
    for (var i = 0; i < data.d.results.length; i++)
    if(i != 0)
    str += "|";
    str += data.d.results[i].FileName;
    error: function (err) {
    //alert(err);
    return str;
    3.2
    How to make them work together
    When selecting an option in the Drop Down menu, the Information menu and the List view will be refreshed separately.
    When clicking the tiles, only the list view will be filtered and refreshed, the other parts will not be influenced.
    When items created/modified, the whole page will be refreshed to keep all the numbers in each part updated.  A workflow will also be triggered to inform engineers or reviewers the progress of an item or content.
    3.3
    Other customizations
    3.3.1       
    ECB menu and permission control
    As we need to refresh the page when new item or modify item, we put all the form pages in a custom modal dialog and execute the refresh in the success callback function.
    There are three roles: Site owner, reviewer and engineer. They have limited privileges according to the roles they are:
    Site owner: Full control on the list, can see all the buttons in the ECB menu;
    Reviewer: There is another list which stores the names of each team and reviewers’ names of each team. The reviewer has limited full control only on the team they belong to. To other teams, the role can be seen as a visitor;
    Composer
    (create owner): The one who contribute an idea. For the ideas\contents from other teams, this role can be seen as visitor.
    The ECB menu they can see is:
    For the visitor, the ECB menu will only display a few buttons:
    The code:
    (function () {
    var viewContext = {};
    viewContext.Templates = {};
    viewContext.OnPostRender = OnViewPostRender;
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(viewContext);
    function OnViewPostRender(ctx) {
    $("a[title='More options']").removeAttr("onclick");
    $(".ms-list-itemLink").removeAttr("onclick");
    $("a[title='More options']").attr("onclick", "showMenuList(this);return false;");
    function showMenuList(obj) {
    var itemId = $(obj).parents("tr").attr("id").split(",")[1];
    //show ECB menu
    CoreInvoke('ShowECBMenuForTr', obj, event);
    var teamId = getCurrentTeamId("Content Pool", itemId);
    var styles = "";
    if (isSiteOwner("Technet SharePoint Team Owners")) {
    styles = "li[text='Delete Item ']{display:block;} li.ms-core-menu-separator:last-child{display:block;} ul.ms-core-menu-list > li:nth-last-child(5){display:block;} li[text='Edit Item ']{display:block;} li[text='Upload Document']{display:block;} li[text='Approve']{display:block;} li[text='Reject']{display:block;} li[text='Add Publish Link']{display:block;}";
    } else if (isReviewer("List1_FAQ_team", teamId, "Reviewers")) {
    styles = "li[text='Delete Item ']{display:block;} li.ms-core-menu-separator:last-child{display:block;} ul.ms-core-menu-list > li:nth-last-child(5){display:block;} li[text='Edit Item ']{display:block;} li[text='Upload Document']{display:block;} li[text='Approve']{display:block;} li[text='Reject']{display:block;} li[text='Add Publish Link']{display:block;}";
    } else if (isComposer(obj)) {
    styles = "li[text='Delete Item ']{display:block;} li.ms-core-menu-separator:last-child{display:block;} ul.ms-core-menu-list > li:nth-last-child(5){display:block;} li[text='Edit Item ']{display:block;} li[text='Upload Document']{display:block;} li[text='Approve']{display:none;} li[text='Reject']{display:none;} li[text='Add Publish Link']{display:none;}";
    } else {
    styles = "li[text='Delete Item ']{display:none;} li.ms-core-menu-separator:last-child{display:none;} ul.ms-core-menu-list > li:nth-last-child(5){display:none;} li[text='Edit Item ']{display:none;} li[text='Upload Document']{display:none;} li[text='Approve']{display:none;} li[text='Reject']{display:none;} li[text='Add Publish Link']{display:none;}";
    includeStyleElement(styles);
    //get current team id
    function getCurrentTeamId(listName,itemId){
    var teamId="";
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
    "/_api/Web/Lists/getByTitle('"+listName+"')/items("+itemId+")?$select=MyTeamId";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
    if(data.d.MyTeamId!=null){
    teamId=data.d.MyTeamId;
    }else{
    teamId="0";
    error: function () {
    //alert("Failed to get details");
    return teamId;
    //check whether is owner
    //Technet SharePoint Team Owners
    function isSiteOwner(groupName) {
    var flag = false;
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/Web/effectiveBasePermissions";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
    var permissions = new SP.BasePermissions();
    permissions.fromJson(data.d.EffectiveBasePermissions);
    flag = permissions.has(SP.PermissionKind.managePermissions);
    error: function () {
    //alert("Failed to get details");
    return flag;
    function isComposer(obj) {
    var flag = false;
    var userId = _spPageContextInfo.userId;
    var composerId = $(obj).parents("tr").find("a[href*='userdisp.aspx']").attr("href").split("ID=")[1];
    if (composerId == userId) {
    flag = true;
    return flag;
    //check whether is reviewer
    function isReviewer(listName,teamId,peopleColumn){
    var flag=false;
    var userId=_spPageContextInfo.userId;
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
    "/_api/Web/Lists/getByTitle('"+listName+"')/items?$select=ID&$filter=(ID eq '"+teamId+"' and "+peopleColumn+"Id eq '"+userId+"')";
    // execute AJAX request
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: { "ACCEPT": "application/json;odata=verbose" },
    async: false,
    success: function (data) {
    if(data.d.results.length>0){
    flag=true;
    error: function () {
    //alert("Failed to get details");
    return flag;
    //insert style into page
    function includeStyleElement(styles) {
    var style = document.createElement("style");
    style.type = "text/css";
    (document.getElementsByTagName("head")[0] || document.body).appendChild(style);
    if (style.styleSheet) {
    //for ie
    style.styleSheet.cssText = styles;
    } else {
    //for w3c
    style.appendChild(document.createTextNode(styles));
    3.3.2       
    Workflow email customization
    The email will only be sent to engineer or team reviewer in the three scenarios:
    When engineer uploads an idea or content, reviewer will receive an email;
    When engineer uploads a content to an existing idea, reviewer will receive an email;
    When reviewer approve/reject an idea or content, engineer will receive an email;
    The design of the workflow process  :
     The email design like this:
    Email to engineer
    Email to reviewer
    Let us know if you are interested in it. Happy coding!
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    A good solution. Liked it very much. Can you please make it a technet blog for others.
    [email protected]

Maybe you are looking for

  • Can I use 2 TV's as secondary displays from Macbook Air?

    Here is what I need to be able to do: In one large room, I need to display my keynote presentation from my Macbook Air 11" (Mid 2012) onto 2  50" Flat-Screen TV's simultaneously that are on the walls on the left and right sides of the room. I have se

  • Is it me? Snow Leopard is ruining my Mac experience.

    I am using a Blackbook 2.16 Ghz 2 duo with 2Gb ram, and since my upgrade a couple of weeks ago everything just seems wrong. When i first installed i lost my iphoto application and had to have a service provider reinstall it. OK not a big problem. But

  • Why JTextArea.select(int,int) not Highlight in java 1.4

    Hi guys Does anybody know why JTextArea.select(int, int) not Highlight the selected text in java 1.4. But java 1.3 works. Does java 1.4 change to use other method to hightlight the selected text in JTextArea? Thanks in advance. Regards, Mark.

  • Is there any system object can save the cost time of package?

    Guys, i have one question. Usually I get the execute update time of package in JAVA to know the performance, but there is time lost in the network, right? So I suppose to get the cost time in DB and cost time in Weblogic, two parameters together. In

  • ORACLE Forms Run Time error FRM -92050 failed to connect to server

    server name: osfsun.oklaXXX:9000 Details: Java Exception Java.netNoRouteToHostException: operation timed out at java.net.plainsocketImpl.doConnect(Compiled Code) at java.net.plainsocketImpl.connectToAddress(plainsocketImpl:124) There is more.... I ha