Powershell CSOM Sharepoint online list permission

I've been writing a script to connect to SharePoint online, create a document library and add some AD accounts to the permission. I've written all the code using snippets I have found through many searches but am having an issue with the permissions part.
All of the code is taken from this page:
http://jeffreypaarhuis.com/2012/06/07/scripting-sharepoint-online-with-powershell-using-client-object-model/
The only change is i'm using the get principal fun instead of the get group, but not sure if that's what has done it. I'm very new to powershell.
I keep getting an error when adding the user and permission type to roledefinitionbinding. The error is:
Collection has not been initialized at line 0 char 0.
The issue is when it runs $collRoleAssign.Add($principal, $collRdb) part and stop with the error above.
I would really appreciate a hand with this before my PC get launched out of the window.
Thanks Mark

Hi,
The following code snippet for your reference:
var login = "[email protected]";
var password = "xxxxxx";
var siteURL=”https://SharePointOnlineSiteUrl”;
ClientContext ctx = new ClientContext(siteURL);
var securePassword = new SecureString();
foreach (char c in password)
securePassword.AppendChar(c);
SharePointOnlineCredentials credentials = new SharePointOnlineCredentials(login, securePassword);
ctx.Credentials = credentials;
Web wsite = ctx.Web;
ctx.Load(wsite, w => w.HasUniqueRoleAssignments, w => w.RoleAssignments.Include(roleAssigned => roleAssigned.Member.Title,
roleAssigned => roleAssigned.RoleDefinitionBindings.Include(roleDef => roleDef.Name)));
ctx.ExecuteQuery();
RoleAssignmentCollection rac = wsite.RoleAssignments;
if (rac != null && rac.Count !=0)
Console.WriteLine("Unique Permissions: " + wsite.HasUniqueRoleAssignments);
foreach (RoleAssignment ra in rac)
Console.WriteLine("Group Name: " + ra.Member.Title);
foreach (RoleDefinition rd in ra.RoleDefinitionBindings)
Console.WriteLine("Permission: " + rd.Name);
Console.ReadKey();
More information:
http://social.technet.microsoft.com/wiki/contents/articles/24087.associate-permission-levels-with-sharepoint-user-groups-using-the-client-side-object-model-in-netc.aspx
Thanks,
Dennis Guo
TechNet Community 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]
Dennis Guo
TechNet Community Support

Similar Messages

  • How to set security group as primary site collection admin and secondary site collection admin using powershell in sharepoint online site - office 365?

    How to set security group as primary site collection admin and secondary site collection admin using powershell in sharepoint online site - office 365?

    Hi,
    According to your description, my understanding is that you want to set security group as admin of primary and secondary site collection using PowerShell command in office 365.
    I suggest you can use the command below to set the group to site owner, then it will have the site collection admin permission.
    Set-SPOSite -Identity https://contoso.sharepoint.com/sites/site1 -Owner [email protected] -NoWait
    Here are some detailed articles for your reference:
    https://technet.microsoft.com/en-us/library/fp161394(v=office.15)
    http://blogs.realdolmen.com/experts/2013/08/16/managing-sharepoint-online-with-powershell/
    Thanks
    Best Regards
    Jerry Guo
    TechNet Community Support

  • Not able to set security group without mail enabled as site collection admin using powershell in sharepoint online site - office 365

    not able to set security group without mail enabled as site collection admin using powershell in sharepoint online site - office 365?
    Any idea?

    after few days test in my lab, I can see that only email enabled group can be added as site collection admin using POWERSHELL.
    hope this helps who stuck like me!! :-)

  • SharePoint Online list view threshold issues: "because it exceeds the list view threshold enforced by the administrator"

    SharePoint Online list view threshold issues: "because it exceeds the list view threshold enforced by the administrator"
    Office 365 SharePoint Online can be problematic when it comes to exceeding the list item threshold (e.g. 5,000).
    Examples of what happens after exceeding the threshold (e.g. 5,000 items):
    You can’t create new forms for the list in SharePoint Designer.
    You may have challenges with metadata fields in the forms (e.g. adding metadata values, editing metadata values, deleting the metadata column from the list).
    Cannot save the list as a template (i.e. you get the threshold error).
    Issue I'd like assistance with: how can I create a custom NewForm in SharePoint Designer
    when the list exceeds the threshold limit, given this is Office 365 SharePoint Online and I don't have access to increase that limit?
    As a control for my testing, I created another list with just a few custom columns with no list items --it worked fine for that list.
    I also tried clearing local AppData cache which didn't solve it. I'd need Central Admin on O365 SharePoint Online to increase the threshold which I don't have access
    to do. Errors received in SharePoint Designer:
    "Could not save the list changes to the server." After getting this, I tried to work around
    the create new forms issue by saving a copy of the original NewForm as NewForm2 and got the root error that I suspected was underlying it all:
    “Server error: the attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator”.
    Any ideas for how to create a new list form in SD?

    Thanks Alex.
    I just found a couple new workarounds instead of using SharePoint Designer:
    Method 1: Add web parts to the form pages on the client side:
    Go to the list and execute one of these actions depending what form you want to edit: create a new item (NewForm), edit an item (EditForm), or display an item (DispForm).
    With the form you want to edit displayed, go to the gear icon and click "Edit Page".
    You should now see the web part page show up with "Add a Web Part" as an option.
    Add a Content Editor or Script Editor web part.
    Add your custom code to either one to manipulate the HTML objects using your favorite web languages.
    Method 2: Use InfoPath 2013.
       The InfoPath 2013 route appears to work.

  • Send a link via email that will start a workflow on a sharepoint online list

    I am trying to send a hyperlink in an email that will start a workflow on a sharepoint online list. I am unable to use javascript because the end-user will be clicking this link on their mobile device. I have found many articles that get me almost there
    but none of them will actually start the workflow.
    here is one that is very close to what i am looking to do. http://sharepointerz.blogspot.com/2012/05/run-workflow-from-hyperlink-in.html
    Is it possible to start a workflow using a URL with out using javascript?
    Any help would be much appreciated. Thanks 

    you can use ECMA script to Start the workflow.  However you need to redirect to a sharepoint page and there on Load you can do this. Directly from Email I don't know.
    You can use http://www.codeproject.com/Articles/607127/Using-SharePoint-Workflow-Services-JS-API
    SP.WorkflowServices.WorkflowServicesManager
    From other blog http://www.vrdmn.com/2014/08/start-sharepoint-2013-workflows-with.html
    Thanks and Regards
    Er.Pradipta Nayak
    Visit my Blog
    Xchanging

  • How to install app using powershell in sharepoint online - office 365?

    How to install app using powershell in sharepoint online - office 365?

    Hi
    check this similar post
    https://social.msdn.microsoft.com/Forums/sharepoint/en-US/1f0cd45a-00e1-4452-bafe-83c6ee3a59db/can-i-deploy-a-sharepointapp-to-office-365-using-powershell?forum=appsforsharepoint
    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.

  • Managing Query Suggestions through CSOM (C#) or PowerShell for Sharepoint Online.

    Hello everybody.
    I am currently working with Sharepoint Online search and am trying to find information about managing Query suggestions (CRUD operations).
    Would anybody have any information as to how I could do this in CSOM or PowerShell ? I truely am having a hard time on this.

    Hi,
    Please check below. This should help you. You can REST APIs
    Retrieving query suggestions using the Search REST service
    https://msdn.microsoft.com/en-us/library/office/dn194079.aspx
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Add a list and column to about 200 sites using powershell in SharePoint online

    
    I have a sitecollection with about 200 identical sites. However I need to add a new list to each site and a lookup column (referring to this list) to two other lists. I'm not a developer so I struggle a bit. I found this as a starting point:
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null
    $WebUrl = 'https://yourtenant.sharepoint.com/sites/somesite'
    $EmailAddress = "[email protected]"
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($WebUrl)
    $Credentials = Get-Credential -UserName $EmailAddress -Message "Please enter your Office 365 Password"
    $Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($EmailAddress,$Credentials.Password)
    $List = $Context.Web.Lists.GetByTitle("YourList")
    $FieldXml = "<Field Type='Text' DisplayName='New_Field_Display_Name' />"
    $Option=[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView
    $List.Fields.AddFieldAsXml($fieldxml,$true,$option)
    $Context.Load($list)
    $Context.ExecuteQuery()
    $Context.Dispose()
    Can someone help me out or is there a better solution?
    Thanks.
    

    Hi,
    According to your post, my understanding is that you wanted to add a list and a lookup column in about 200 identical sites.
    Per my knowledge, there is no out of the box way to achieve it in SharePoint Server, however, I’m not sure whether it is in SharePoint online.
    As this is the forum for SharePoint Server, you can post your question in the forum for SharePoint online.
    http://community.office365.com/en-us/forums/154.aspx.
    However, as you had known, we can achieve it programmatically.
    Besides the PowerShell command, we can also use the Client Object Model to achieve your scenario.
    If all the 200 sites in one site collection, we can first retrieve all the sites in the site collection, then add the list in every site.
    To retrieve all the sites in a site collection, you can refer to the following code snippets.
    static string mainpath = "SiteURL";
    static void Main(string[] args)
    getSubWebs(mainpath);
    Console.Read();
    public static void getSubWebs(string path)
    try
    ClientContext clientContext = new ClientContext( path );
    Web oWebsite = clientContext.Web;
    clientContext.Load(oWebsite, website => website.Webs, website => website.Title);
    clientContext.ExecuteQuery();
    foreach (Web orWebsite in oWebsite.Webs)
    string newpath = mainpath + orWebsite.ServerRelativeUrl;
    getSubWebs(newpath);
    Console.WriteLine(newpath + "\n" + orWebsite.Title );
    catch (Exception ex)
    http://chennaisharepointtraining.blogspot.in/2011/11/get-all-subwebs-using-client-object.html
    To create a list, you can have a look at the following article.
    http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
    Thanks,
    Jason
    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].
    Jason Guo
    TechNet Community Support

  • Export sharepoint online list in powershell

    Hi,
    is there any commandlet to export content of sharepoint list to csv? I need some script witch does it automaticaly. Is it possible?
    Thanks for help
    JD

    Hi Tian-An,
    SharePoint contents (e.g. document files, list items, pages) are stored in SQL database, it may if you want to use the contents without SharePoint environment, I think you can click "Open with Exporer" from library ribbon and then copy them to
    the file system(e.g. a network dirve fileshare), note that the library columns value would be unable to be copied/exported; for the list items you can click "Export to Excel" button form list ribbon to export list itmes to
    excel file, or as you have done with connecting to Outlook.
    And we have a dedicated Office365 SharePoint online forum, I would recommand you post there for getting a better assistance redarding this SharePoint online contents exporting.
    https://community.office365.com/en-us/f/154.aspx
    Thanks,
    Daniel Yang
    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]
    Daniel Yang
    TechNet Community Support

  • Issue in adding new items to a O365 SharePoint Online List having lookup columns (Client Object Model)

    I have two Lists i.e. Publisher and Products in my SharePoint Online site. They are having the following structures:
    1. Publisher:
    Publisher (Single line of txt)
         A1
         A2
         A3
         A4
         A5
         A6
    2. Products:
    Publisher (lookup to the above column)       
    ProductName (Single line of txt)
         A1                                                                   Apple
         A2                                                                   Samsung
         A3                                                                   Nokia
    And I have an excel file named Products.xlsx in my local machine which has the following data:
    Publisher        ProductName
         A1                   Apple
         A2                   Samsung
         A3                   Nokia
         A4                   Motorola
         A5                   LG
         A6                   HTC
    Now I have written the below client-side (CSOM) code to fetch the data from the Excel and update the corresponding fields in the Products table:
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Web;
    using System.IO;
    using System.Data;
    using System.Data.OleDb;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Client;
    using File =
    Microsoft.SharePoint.Client.File;
    using System.Security;
    namespace ExcelToSP
        public class
    ExcelToSP
            //Main function to get the command line values and invoke the getSPList function to pull SP List data
            public
    static void Main(string[] args)
                //Instantiate Class object
                ExcelToSP p
    = new ExcelToSP();
                try
                    p.LoadExcelData();
    //Exit with Sucess code
    Environment.Exit(0);
                catch
    (Exception ex)
    //Invoke writeErrorLog function to log the exception details
    //p.WriteErrorLog(ex);
            public
    void LoadExcelData()
                try
                string fileName
    = @"E:\Products.xlsx";
                string fileExtension
    = Path.GetExtension(fileName).ToUpper();
                string connectionString
    = "";
                 if
    (fileExtension == ".XLS")
                    connectionString
    = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"
    + fileName + "'; Extended Properties='Excel 8.0;HDR=YES;'";
                else
    if (fileExtension ==
    ".XLSX")
                    connectionString
    = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='"
    + fileName + "';Extended Properties='Excel 12.0 Xml;HDR=YES;'";
                if
    (!(string.IsNullOrEmpty(connectionString)))
    string[] sheetNames =
    GetExcelSheetNames(connectionString);
    if ((sheetNames !=
    null) &&
    (sheetNames.Length
    > 0))
    DataTable dt = null;
    OleDbConnection con =
    new OleDbConnection(connectionString);
    OleDbDataAdapter da =
    new OleDbDataAdapter("SELECT * FROM ["
    + sheetNames[0]
    + "]", con);
                        dt
    = new DataTable();
                        da.Fill(dt);
    InsertIntoList(dt,"Products");
                catch
    (Exception ex)
    throw ex;
            private
    string[] GetExcelSheetNames(string strConnection)
                var connectionString
    = strConnection;
                String[] excelSheets;
                using
    (var connection =
    new OleDbConnection(connectionString))
                    connection.Open();
    var dt = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
    null);
    if (dt ==
    null)
    return null;
                    excelSheets
    = new String[dt.Rows.Count];
    int i = 0;
    // Add the sheet name to the string array.
    foreach (DataRow row
    in dt.Rows)
                        excelSheets[i]
    = row["TABLE_NAME"].ToString();
                        i++;
                return excelSheets;
            private
    void InsertIntoList(DataTable listTable,
    string ListName)
                try
    string username = "[email protected]";
    string pwd = "contoso@1234";//this.Dts.Variables["password"].Value.ToString();
    ClientContext clientContext =
    new ClientContext("https://contoso.sharepoint.com/teams/myPOC/");
    SecureString password =
    new SecureString();
    char[] decryptpwd = pwd.ToCharArray();
    foreach (char c
    in decryptpwd)
                        password.AppendChar(c);
                    clientContext.Credentials
    = new SharePointOnlineCredentials(username, password);
                    clientContext.ExecuteQuery();
    //Setting SiteURL Client context
    Web web = clientContext.Web;//
                    clientContext.Load(web);
                    clientContext.ExecuteQuery();
    List lstProductFamily = web.Lists.GetByTitle("Products");
    for (int iRow
    = 0; iRow < listTable.Rows.Count; iRow++)
    ListItemCreationInformation itemCreateInfo =
    new ListItemCreationInformation();
    ListItem newItem = lstProductFamily.AddItem(itemCreateInfo);
    //FieldLookupValue flv = newItem["Publisher"] as FieldLookupValue ;
    //string lkup = flv.LookupValue;
    //int valueid = 0;
    //valueid = flv.LookupId;
                        newItem["Publisher"]
    = Convert.ToString(listTable.Rows[iRow][0]);
                        newItem["ProductName"]
    = Convert.ToString(listTable.Rows[iRow][1]);
                        newItem.Update();
                        clientContext.ExecuteQuery();
                catch
    (Exception ex)
    throw ex;
    But I'm getting the following error on running the above code "Invalid data has been used to update the list item. The field you are trying to update may be read only." 
    Can anybody please help me out?

    Hi,
    According to your description, my understanding is that you want to update data to look up field.
    I have a test about updating look up field using Client Object Model in my environment. lookup field will accept an array to set the field value.
    Here is the code snippet:
    Microsoft.SharePoint.Client.ClientContext ctx = new ClientContext("http://sp2013sps/sites/test/");
    if (ctx != null)
    List list = ctx.Web.Lists.GetByTitle("List3");
    ListItem itemToUpdate = list.GetItemById(1);
    ctx.Load(itemToUpdate);
    ctx.ExecuteQuery();
    FieldLookupValue newLookUpField = new FieldLookupValue();
    newLookUpField.LookupId = 3;
    FieldLookupValue newLookUpField1 = new FieldLookupValue();
    newLookUpField1.LookupId = 4;
    FieldLookupValue[] newarr = { newLookUpField, newLookUpField1 };
    itemToUpdate["lookup"] = newarr;
    itemToUpdate.Update();
    ctx.Load(itemToUpdate);
    ctx.ExecuteQuery();
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to use sharepoint online lists in different subsites as a datasource to powerpivot

    My customer has sharepoint online + project online.
    As you might know each project has a site, and in each site there are lists with the same name on each site.
    We need a pivot table where we can aggregate all that list data, is this possible? Do I need powerbi, or can I do it without power bi?
    Can u guide me in the right direction?
    Follow me on Twitter
    levalencia Blog

    I opened a ticket with MS support on this.  They concluded that there is no means of scheduling an auto-refresh when you are aggregating more than one SharePoint list as your data source.  They recommended buying a third party product to accomplish
    this.  Below is the relevant text I received from MS tech support for my ticket....
    CAUSE: This is by design. The functionality needed for this is not currently implemented.
    RESOLUTION: We were able to find a 3<sup>rd</sup> party tool that may be able to schedule refresh for these
    reports (http://www.powerpivotpro.com/2015/02/introducing-power-update/)
    TROUBLESHOOTING:
    We assessed the report. It seemed that a Power Query data source needed to be created within Power BI, so we attempted to create that:
    We were prompted to create a default gateway, even though the data was O365 data
    We were only able to find references directly related to on-premise data sources and the default gateway
    We attempted to find a workaround for this particular situation. We attempted the following configurations:
    PowerPivot report populated by SharePoint lists
    Excel report implementing SharePoint lists with the Data tab
    Connecting the report to a SharePoint Document Library data source
    Using OData feed for report
    *All of the above configurations were unsuccessful
    Additional Information
    Even if a gateway could be created for the report, it would require Anonymous or Windows Authentication. O365 data sources require Claims Authentication.
    Scheduled refresh can be made for SQL Azure data sources. However, this would require configuring some type of automatic refresh for the SQL Azure data source itself to populate with the SharePoint list
    data.

  • Get user manager in workflow SharePoint Designer 2013 for SharePoint online list item

    Hello,
    I would like to create a workflow in SharePoint Designer 2013 for a list in a site on SharePoint online and one of the action would be to send an e-mail to the manager of the user that created an item in a list.
    How can I get the manager of the user and then use it to send an e-mail?
    Thanks!

    In SP Designer there's the following action that I use.
    Find Manager for this user (then output to variable:manager) Action
    This is for SPD 2010 not sure if it's still available in SPD 2013
    Thanks,
    KP
    KP

  • Create list item in sharepoint online list throws error in iPhone

    Hi all :
    I have got a piece of JS code where I am creating multiple list items. So first I am creating an Expense item and then each of the expense line item( 5 of those ) in a different list. It creates the Expense item successfully and then when it tries to
    create the line items, I am getting the following error :
    Request failed. Unexpected response from server. null
    However when I go to the line items list, I can see all the items being created!!! I am also inserting my code below.
    clientContext.executeQueryAsync(function (sender, args) {
                    var createdExpenseID = viewModel.listItem.get_id();
                    //Now create the expense line items - one by one
                    clientContext = SP.ClientContext.get_current();
                    web = clientContext.get_web();
                    list = web.get_lists().getByTitle("Expense Items");
                    var expenseIDLookup = new SP.FieldLookupValue();
                 expenseIDLookup.set_lookupId(createdExpenseID);
                    /*for (i = 1; i <= 5; i++) {
                        var descriptionField = "description"+i;
            alert(viewModel.model.window[descriptionField]);
                    itemCreateInfo = new SP.ListItemCreationInformation();
                 this.listItem = list.addItem(itemCreateInfo);           
                 //alert(list);
                 this.listItem.set_item('Title', viewModel.model.description1());
                 this.listItem.set_item('Date', $('#date1').val());
                 this.listItem.set_item('ProjectNumber', viewModel.model.projectNumber1());
                 this.listItem.set_item('ClientToPay', viewModel.model.selectedClienttopay1());
                 this.listItem.set_item('Amount', viewModel.model.amount1());
                 this.listItem.set_item('ExpenseCurrency', viewModel.model.selectedExpenseCurrency1());
                    this.listItem.set_item('ExchangeRate', viewModel.model.exchange1());
                    this.listItem.set_item('ConvertedAmount', viewModel.model.converted1());
                    this.listItem.set_item('Expense', expenseIDLookup);
                    this.listItem.update();
                    clientContext.load(this.listItem);
                    clientContext.executeQueryAsync(function (sender, args) {
        function (sender, args) {
                     alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
                    itemCreateInfo = new SP.ListItemCreationInformation();
                 this.listItem = list.addItem(itemCreateInfo);           
                 //alert(list);
                 this.listItem.set_item('Title', viewModel.model.description2());
                 this.listItem.set_item('Date', $('#date2').val());
                 this.listItem.set_item('ProjectNumber', viewModel.model.projectNumber2());
                 this.listItem.set_item('ClientToPay', viewModel.model.selectedClienttopay2());
                 this.listItem.set_item('Amount', viewModel.model.amount2());
                 this.listItem.set_item('ExpenseCurrency', viewModel.model.selectedExpenseCurrency2());
                    this.listItem.set_item('ExchangeRate', viewModel.model.exchange2());
                    this.listItem.set_item('ConvertedAmount', viewModel.model.converted2());
                    this.listItem.set_item('Expense', expenseIDLookup);
                    this.listItem.update();
                    clientContext.load(this.listItem);
                    clientContext.executeQueryAsync(function (sender, args) {
        function (sender, args) {
                     alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
       //Now redirect to the newly created item edititem.aspx page for attaching attachments
                    window.location.replace("/sites/process/Lists/Expense/EditForm.aspx?ID="+createdExpenseID+"&Source=/sites/process");
    function (sender, args) {
        alert('Expense creation failed');                
    The outermost executeQueryAsync creates the Expense item and on being successful, I create the line items.
    Any help will be much appreciated.
    Thanks and regards,
    developer_melbourne

    Ok so I resolved the issue and thought to provide the answer. It was caused by the line where it is doing redirection using window.location.replace. Somehow it works in IE, not in Safari in iPhone.
    Anyways you can do the redirection after all the items get created in the last success  method of the last item creation OR you can use deferred/promise of jQuery to achieve the same.
    Thanks

  • Unable to save lookup field data in SharePoint 2013 online list

    Dear Support,
    I had successfully created provider hosted app and deployed on SharePoint 2013 online site, in my project I created orderservice.asmx.cs web service and write a code for save record on SharePoint
    2013 online list as I mentioned below and calling on App1.js file.
    But I am unable to save lookup field value as mentioned below code
    Customer is a lookup field I want to save data in SharePoint 2013 online list( Order)where I had successfully
    inserted text field  data (Title &
    Special_x0020_Instruction).
    i am getting error as mentioned below
    500 Internal Server Error {"Message":"Invalid web service call, missing value for parameter: \u0027Title1\u0027.","StackTrace":"   at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2
    parameters)\r\n   at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n   at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData,
    IDictionary`2 rawParams)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
    Please let me know the code how to insert lookup field value (Customer)
    in SharePoint online list.
    OrderService.asmx.cs
    Public
    int InsertOrder (Order
    orderRecord)
                pwd.MakeReadOnly();
                clientContext.Credentials =
    new
    SharePointOnlineCredentials (myUserName, pwd);
    try
                  Web
    oWeb = clientContext.Web;
    ListCollection lists = oWeb.Lists;
    List oOrderlist = clientContext.Web.Lists.GetByTitle("Order");
                    clientContext.Load<ListCollection>(lists);
                    clientContext.Load<List>(oOrderlist);
                    ListItemCreationInformation
    itemCreateInfo = new                 ListItemCreationInformation();
    ListItem oListItem = oOrderlist.AddItem(itemCreateInfo);
                    oListItem["Title"]
    = Title;                        listItem["Special_x0020_Instruction"]
    = orderRecord.Instruction;
                        listItem ["Customer"]
    = orderRecord.CustomerId;
                        listItem.Update();
                        clientContext.ExecuteQuery();
    return 1;
    catch
    return -1;
    App1.JS
    $("#Save").click(function
    debugger;
    var OrderProfile = $('#orderprofile').val();
    var CustomerId = $('#exCustomerlist').jqxComboBox('getItem',
    $('#exCustomerlist').val());
    //var Instruction = $('#instruction').val();
            alert(OrderProfile);
            alert(CustomerId);
    var obj = {
    'Title': OrderProfile,
    'Customer': CustomerId }
            $.ajax({
                url:
    "OrderService.asmx/InsertOrder",
                type:
    "POST",
                dataType:
    "json",
                data: JSON.stringify(obj),
                contentType:
    "application/json; charset=utf-8",
                beforeSend:
    function (XMLHttpRequest) {
    //Specifying this header ensures that the results will be returned as JSON.
                    XMLHttpRequest.setRequestHeader("Accept",
    "application/json");
                success:
    function (response) {
                    $(".errMsg ul").remove();
    var myObject = response.d;
                    alert(myObject);
                error:
    function (response) {
                    alert(response.status +
    ' ' + response.statusText +
    ' ' + response.responseText);
    Regards,
    Akhilesh

    Hi Alex Brassington,
    Thanks for your reply.
    I am having the Site Administrator Permission of the public site.
    I am having the permission of Company Administrator of that site but still unable to find
    Device Channel on Site Setting. still I gave the user full control from Site Permission but nothing is happening.
    What should I do next?

  • SharePoiunt List Datasheet view cell alignment in SharePoint Online

    Hi Team,
    Is it possible to align cell data to top-aligned in SharePoint Online list datasheet view? 
    Cheers, Badal

    I have spent two days to resolve this issue. Microsoft has released two KBs with reference to this issue...but are not appearing in search results at the top.
    I am sharing my finding.
    1. First install the
    KB2552989 (Hopefully you might have already installed it. The KB detetcts it and informs the user.)
    2. Then update registry by adding new key for data fetch timeout as mentioned in
    KB2553007 
    These two steps resolved the issue in our environment. Hope it might help others as well.
    Pradip T. ------------- MCTS(SharePoint 2010/Web)|MCPD(Web Development) https://www.mcpvirtualbusinesscard.com/VBCServer/paddytakate/profile

Maybe you are looking for

  • How to disable or change the value of h:commandlink jsf component

    Hi, I am a student. I am using h:commandlink. I need to change the value of the component once it is clicked by the user. How do i do that? If i cannot change the displayed value of the commandlink. I am thinking of atleast disabling the link once th

  • My iPod is Stuck on the Reset Screen

    It had been a while since I used my iPod Touch because I didn't have I lost the charger. I recently bought a new charger and once I plugged in the iPod, it started to charge normally. But the apple logo and the dead battery screen would go back and f

  • Oracle Quality Module - Collection Plan name

    The collection Plan name field in Orcale quality module - collection plan form (QLTPLMDF) does not accept special characters. Why is this so and what is the rationale behind this? Here is the wording from Oracle Quality user Manual Collection plan na

  • Do different things on separate displays

    So i've got my MB pro connect to a tv via dvi-hdmi. Is there any way that I can work on my MB pro while watching a movie or something else on the tv? All i can do is mirror...when i turn mirroring off, i just get a blank desktop on my tv....

  • How can I run a XControl without wire Input/Output?

    Hello! I'm trying to developped some XControls. I want that these XControls run automatically without to wire him an Input/ooutput. I tried to do this, but the XControl only executes once, and then never entry again. I think that it is possible to do