How to update a People and group field using a sandbox solution

Hi,
I am creating a sandbox solution for office 365 and creating a custom form using visual web part, which will allow users to enter data in a custom list.
And that list also have a user field. I am able to get SharePoint user field on the form (using javascript) which is searching for the user and get a value (working fine).
Issue: But I am not able to save the user value. Because to save user value I require web, UserID and login name, to construct SPFieldUserValue object or string in "111;#TestUser" format. Moreover that user should be present in
SiteUserInfoList. 
I tried web.EnsureUser() but did not work under sanbox solution.
Can you please provide any pointer or workaround to the problem? I may be missing something here.
Thanks,
Himanshu

Hi,
According to your description, my understanding is that you want to update the people and group field in Sandbox solution.
In the sandbox solution, you can still use the web.EnsureUser() function to get the user information, see the thread below:
EnsureUser in sandboxed solution
In additional, there is a demo with your similiar requirement for your reference:
Using the People Picker Control in Sandbox Solutions / Office 365
Thanks
Best Regards,
Jerry Guo
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]

Similar Messages

  • How to Update PO(ekko and ekpo) by using Bapi

    Hi Experts,
    I am very new in Abap ,I want to update some fields of Purchase order through Bapi.
    In  Selection screen  i need these things,
    PO Number ,  material, Delivery date
    and i want to update the below fields of  Purchase order(PO)
    1.   Street/House number  ,Postal Code/City  in header level (Give any dummy values for street/house number city  and postal code)
    2.  PO quantity, Delivery date , net price  for all items which has matching material as in selection screen
    and i am not giving data from excel sheet ,,i am giving data directly or through selection screen for the above mentioned fields.
    please give me some solution or sample code so that i can do it.
    Thankx in advance..
    Ritesh

    First declare the header and item structure to pass the values to FM. Now the values that you enter in selection screen are captured in internal table. So you can loop this internal table and pass the values to function module item and header details.
    EX:
    Decleration
    DATA: PO_HEAD TYPE BAPIMEPOHEADER,
               PO_HEADX TYPE BAPIMEPOHEADERX,
               PO_ITEM TYPE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
               PO_ITEMX TYPE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,
               COUNT TYPE I VALUE 1,
               RETS TYPE BAPIRET2 OCCURS 0 WITH HEADER LINE.
    Pass the values to po_head po_headx po_item po_itemx.
    loop. selection screen internal tables
    append . Append the internal tables
    endloop.
    now call the bapi and pass the values.
    CALL FUNCTION 'BAPI_PO_CHANGE'
       EXPORTING
         PURCHASEORDER                = PO_NUM
    *   POHEADER                     =
    *   POHEADERX                    =
    *   POADDRVENDOR                 =
    *   TESTRUN                      =
    *   MEMORY_UNCOMPLETE            =
    *   MEMORY_COMPLETE              =
    *   POEXPIMPHEADER               =
    *   POEXPIMPHEADERX              =
    *   VERSIONS                     =
    *   NO_MESSAGING                 =
    *   NO_MESSAGE_REQ               =
    *   NO_AUTHORITY                 =
    *   NO_PRICE_FROM_PO             =
    * IMPORTING
    *   EXPHEADER                    =
    *   EXPPOEXPIMPHEADER            =
      TABLES
        RETURN                       =  RETS
        POITEM                       = ITEM
        POITEMX                      = ITEMX
    *   POADDRDELIVERY               =
    *   POSCHEDULE                   =
    *   POSCHEDULEX                  =
    *   POACCOUNT                    =
    *   POACCOUNTPROFITSEGMENT       =
    *   POACCOUNTX                   =
    *   POCONDHEADER                 =
    *   POCONDHEADERX                =
    *   POCOND                       =
    *   POCONDX                      =
    *   POLIMITS                     =
    *   POCONTRACTLIMITS             =
    *   POSERVICES                   =
    *   POSRVACCESSVALUES            =
    *   POSERVICESTEXT               =
    *   EXTENSIONIN                  =
    *   EXTENSIONOUT                 =
    *   POEXPIMPITEM                 =
    *   POEXPIMPITEMX                =
    *   POTEXTHEADER                 =
    *   POTEXTITEM                   =
    *   ALLVERSIONS                  =
    *   POPARTNER                    =
    *   POCOMPONENTS                 =
    *   POCOMPONENTSX                =
    *   POSHIPPING                   =
    *   POSHIPPINGX                  =
    *   POSHIPPINGEXP                =
    *   POHISTORY                    =
    *   POHISTORY_TOTALS             =
    *   POCONFIRMATION               =
       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    * EXPORTING
    *   WAIT          =
    * IMPORTING
    *   RETURN        =
    Hope it helps.
    Regards,
    K.Srikanth Reddy.

  • Known limit for how many characters can be entered in the To field when adding People and Groups ?

    I am running MOSS 2007 SP1. I browse to site settings > People and groups and a group which has more than 60 members. I select all > Click Actions > Email Users. Nothing happens. I select less users, new outlook window comes up as it should. I am running outlook 2007. I first thought that the limit was 50 users, but different user selections let me select 51 users as well. I then concentrated on the character limit and I noticed that there were about 1580 characters in the To field when I selected 50/51 users.
    Is there a known limit in sharepoint/outlook client for this function on how many characters can be entered in the To field?

    Hello Amar,
    This is a by-design behavior, not from SharePoint side, but Internet Explorer. The limitation by the 2083 characters in IE for the Max URL length is described in the following KB article:
    (KB208427) Maximum URL length is 2,083 characters in Internet Explorer
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;208427
    As a workaround, you may need to divide the list up and not send all the email at the same time. Hope it helps!
    Best Regards,
    Lionel

  • How to Remove Treeview in people and group dialog window

    I need to remove the treeview in people and group dialog window in sharepoint online. Any suggesstions?

    Hello,
    For those still looking, you should ask on the
    SharePoint forums.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • How to Insert Sharepoint 2013 Person or Group Field using VBA

    Hello,
    How to Insert Sharepoint 2013 Person or Group Field using VBA , I tried set the field with ID / ID;Name / Name
    but all failed, Please advice 
    Function SetSP_Field(F_Yer As Single, F_WekNo As Single, F_ProjectNum As String, strField As Variant, strFieldValue As Variant) As String
    ' test code
        Dim rst         As Recordset
        Dim strSQL      As String
        Dim SP_RecSet   As ADODB.Recordset
        Set SP_RecSet = New ADODB.Recordset
        SetSP_Field = False
        strSQL = "Status Report"
        On Error Resume Next
        Call SP_Connect(2)
        strSQL = "select " & SP_List & ".* From  " & SP_List _
               & " Where [Year] = " & CInt(F_Yer) _
               & "   and [WeekNo] = " & CInt(F_WekNo) _
               & "   and [Compass_Code] = '" & F_ProjectNum & "' ; " _
    '           & " Set " & strField & " = " & strFieldValue
        'Debug.Print strSQL
        'Debug.Print SP_CN
        SP_RecSet.Open strSQL, SP_CN, adOpenStatic, adLockOptimistic
        If SP_RecSet.RecordCount = 0 Then
            Debug.Print "Record for project: " & F_ProjectNum & " not found"
            LogFile.WriteLine ("Record " & strID & " not found")
        End If
        If Not SP_RecSet.EOF Then
            'SP_RecSet.Edit
            SP_RecSet.Fields(strField) = strFieldValue
            SP_RecSet.Update
            If Err.Number <> 0 Then
                MsgBox ("SP Update Error: " & Err.Description)
                GoTo Exit_Fun
            End If
            SetSP_Field = True
        End If
    Exit_Fun:
        SP_RecSet.Close
        Set SP_RecSet = Nothing
    End Function

    Hi Tim,
    Let’s verify the followings:
    Whether this issue occurred for other lists in the same site.
    Whether this issue occurred for all users who don’t have full control.
    Whether this issue occurred on other sites.
    When you created the people & group column, which show field did you used? Please try to use a different show field for the people & group column, compare the result.
    In addition, please check if the link is useful:
    http://www.learningsharepoint.com/2013/08/21/empty-value-in-people-picker-after-saving-the-list-form-in-sharepoint/
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • People and Groups not appearing in Address List

    We have an Exchange 2013 deployment running on Windows 2012 Standard servers. Some of our people and all our groups are not showing up in the Outlook Address Book on people's client application. This despite the fact that "hide name from address book"
    is unchecked on these people and groups.
    This affects both those running Outlook and OWA.
    Any idea how I can go about troubleshooting this?
    ----------- Ron E Biggs Chief Tech Officer Entertainment Studios

    Hi,
    From your description, I would like to clarify the following things:
    1. Outlook in cached mode automatically updates the offline address book on the client every 24 hours. The 24-hour time period is measured from the time that the offline address book was last downloaded successfully. So sometimes new users can't be displayed
    immediately on Outlook.
    2. If you would like to show the dynamic distribution groups in “All Groups”, you can use the following cmdlet.
    Set-AddressList -Identity "all groups" -RecipientFilter "(RecipientType -eq 'MailUniversalDistributionGroup' -or RecipientType -eq 'MailUniversalSecurityGroup' -or RecipientType -eq 'MailNonUniversalGroup' -or RecipientType -eq 'DynamicDistributionGroup')"
    Here is a helpful thread for your reference.
    Let the dynamic distribution groups be shown in “All Groups”
    https://social.technet.microsoft.com/Forums/en-US/d32a94af-eb46-407e-9129-c977c32d2a48/let-the-dynamic-distribution-groups-be-shown-in-all-groups?forum=exchangesvrgeneral
    Hope this can be helpful to you.
    Best regards,
    If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Amy Wang
    TechNet Community Support

  • How to send emails to Multiple Users from a Single People Picker lookup field using Sharepoint designer workflow

    Hi All,
    I am working with SharePoint 2013 designer workflow. we are using office 365.
    Our requirement to send email to multiple users, get the user groups from lookup list people and groups column.
    But SP designer sending emails to the first user alone.
    Please guide me to proceed.
    Advance Thanks.
    Regards
    Jenkins NS
    Thanks and Regards Jenkins

    finally I got a solution
     Identified a workaround to solve the issue using SharePoint designer.
    Step 1
    Create a lookup list Example department
    Columns
    Title (by default) – Single line of text
    Users – Person or Group
    Emails – Multiple lines of text
    hidden the Emails column (go to content type and set the column as hidden)
    Create a SharePoint designer Workflow
    Start Workflow automatically when an item is created
    Also Start Workflow automatically when an item is changed
    Workflow Stage 1
    Set Emails to current Item: Users
    The workflow will get all users email ids and add in the Emails column delimiter as semicolon.
    Step 2
    Create a custom list to get the email ids and send email
    Create a lookup column ex: analysis and refer department list, Allow multiple values
    Then Create a SharePoint designer workflow
    full details workflow steps please follow below
    URL
    http://jenkinsblogs.com/2015/04/30/how-to-send-emails-to-multiple-users-from-lookup-list-people-picker-field-using-sharepoint-designer-workflow/
    Thanks and Regards Jenkins

  • Reg:: People and Groups Permission reports in sharepoint 2013

    Hi Techys,
    We have one SharePoinr 2013 team site, The total number of users for the site is 3200 members. Now my customer requirement is, they requested a report for people and groups and its permissions along with member names by group wise.
    Example: I'm having one SharePoint 2013 team site named as "My Auditions", it contains 28 groups with different permission levels. Each group having minimum 70 users. Now we need a report for each group permission along with group members.
    Kindly help me to getdown from the customer concern.
    Many Thanks,
    Madhu

    I would suggest a tool like Metalogix ControlPoint. It can quickly produce nice looking reports for this type of information.
    Trevor Seward
    Follow or contact me at...
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
    Hi Trevor,
    I have decided to say very big thank for your great suggestion, I have installed the Control-point trial version in my personal Lab environment. It's working as i'm expected. But, I have to do the same task for my customer. How can i install the control-point
    in prod server without customer permission. even i'm having all uid and password as administrator.
    Could you please suggest me is there any scripting or ootb features.
    Many Thnaks,
    Madhu

  • How to Update Business Place & Sec.Code Field in Posted Document

    Dear All,
    Pls suggest how to update Business Place & Section Code field in documents which are posted without entering Business Place & Section Code. Pls tell me how to achieve this without using Validations & Substitutions. Any table entries can be maintained for this? Kindly guide.
    Regards
    Abhijeet

    Hi,
         Thanks for sending the replay,
         I had already update the Material document through the J1INPP T. code. but it not use for update FI
         Document and i want to update Business Place & Section Code in FI document.
         Please suggest,
    Regards
    Abhijeet

  • People and group column become empty on EDIT ITEM

    Hi,
    I have 3 people and group columns(Peopleonly type) in my custom content type and list definition from the content type. When I EDIT an item from the list , the values in the 3 people and group column dissappear(meaning the fields are shown empty). Has
    anybody come across this behaviour. Any solution/workaround ?

    Hi Vipul,
    Did this only happen to the EditForm.aspx page of that custom list ? 
    Is this EditForm.aspx page customized ?
    Please also check whether there are some related errors in 14\LOGS.
    Please re-create another new EditForm.aspx page using the SharePoint Designer 2010, then check result again.
    Thanks
    Daniel Yang
    TechNet Community Support

  • Site administration link "people and groups" link breaks if you delete the excel services viewers group

    Creating a HNSC using powershell, the default groups are not created.  Used the UI method of creating the default groups.
    However, if I delete the "excel services viewers" group, the site administration link "people and groups" breaks.  I have attempted to "set the default group" again, after creating the "site default groups" as
    mentioned above, but still no luck.
    Anyone seen this?  Should it be reported as a bug?
    Joshua Fuente

    Hi Joshua,
    For troubleshooting your issue, you can create the default groups using the following PowerShell script and see the result:
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    $currentUser = "$env:USERDOMAIN\$env:USERNAME"
    $siteCollectionUrl = "http://manasbhardwaj.net"
    $siteCollectionName = "Manas Dev Site"
    $webApplicationUrl = "http://manas"
    New-SPSite -Url $siteCollectionUrl -OwnerAlias $currentUser -Name $siteCollectionName -Language 1033 -HostHeaderWebApplication $webApplicationUrl -Template sts#0
    $web = Get-SPWeb $siteCollectionUrl
    $web.EnsureUser($currentUser)
    $web.CreateDefaultAssociatedGroups($currentUser, "", "")
    Reference:
    http://www.codeproject.com/Articles/790726/How-to-create-default-groups-in-SharePoint-Host-Na
    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

  • Set "peoples or groups" field with current user "login name" in sharepoint list form using javascript

    hi friends
    i am trying to set peoples or groups field in sharepoint  list form with current user login name
    here my code
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
    <script type="text/javascript">
    $(document).ready(function NewItemView () {
    var currentUser;
        if (SP.ClientContext != null) {
          SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
        else {
          SP.SOD.executeFunc('sp.js', null, getCurrentUser);
        function getCurrentUser() {
          var context = new SP.ClientContext.get_current();
          var web = context.get_web();
          currentUser = web.get_currentUser();
          context.load(currentUser);
          context.executeQueryAsync(onSuccessMethod, onRequestFail);
        function onSuccessMethod(sender, args) {
          var account = currentUser.get_loginName();
          var accountEmail = currentUser.get_email();
          var currentUserAccount = account.substring(account.indexOf("|") + 1);
        SetAndResolvePeoplePicker("requester",account);
    // This function runs if the executeQueryAsync call fails.
        function onRequestFail(sender, args) {
          alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
     function SetAndResolvePeoplePicker(fieldName, userAccountName) {
       var controlName = fieldName;
        var peoplePickerDiv = $("[id$='ClientPeoplePicker'][title='" + controlName + "']");
        var peoplePickerEditor = peoplePickerDiv.find("[title='" + controlName + "']");
        var spPeoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[peoplePickerDiv[0].id];
        peoplePickerEditor.val(userAccountName);
        spPeoplePicker.AddUnresolvedUserFromEditor(true);
    </script>
    but it is not working
    please help me

    Hi,
    According to your post, my understanding is that you wanted to set "peoples or groups" field with current user "login name" in SharePoint list form using JavaScript.
    To set "peoples or groups" field with current user "login name”,  you can use the below code:
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.js"></script>
    <script type="text/javascript">
    function SetPickerValue(pickerid, key, dispval) {
    var xml = '<Entities Append="False" Error="" Separator=";" MaxHeight="3">';
    xml = xml + PreparePickerEntityXml(key, dispval);
    xml = xml + '</Entities>';
    EntityEditorCallback(xml, pickerid, true);
    function PreparePickerEntityXml(key, dispval) {
    return '<Entity Key="' + key + '" DisplayText="' + dispval + '" IsResolved="True" Description="' + key + '"><MultipleMatches /></Entity>';
    function GetCurrentUserAndInsertIntoUserField() {
    var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    this._currentUser = web.get_currentUser();
    context.load(this._currentUser);
    context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
    Function.createDelegate(this, this.onFailure));
    function onSuccess(sender, args) {
    SetPickerValue('ctl00_m_g_99f3303a_dffa_4436_8bfa_3511d9ffddc0_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_ctl00_UserField', this._currentUser.get_loginName(),
    this._currentUser.get_title());
    function onFaiure(sender, args) {
    alert(args.get_message() + ' ' + args.get_stackTrace());
    ExecuteOrDelayUntilScriptLoaded(GetCurrentUserAndInsertIntoUserField, "sp.js");
    </script>
    More information:
    http://alexeybbb.blogspot.com/2012/10/sharepoint-set-peoplepicker-via-js.html
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • I updated to ios8 and tried to use Health Application. In Sources I get a message that other applications will show up on the list as they request permission to update your data. How does it happen? No apps are listed on my Sources section

    I updated to ios8 and tried to use Health Application. In Sources I get a message that other applications will show up on the list as they request permission to update your data. How does it happen? No apps are listed on my Sources section

    I have an answer to my question. There is a bug in IOS8 that prevents third party applications to talk to the Health Application. Apple is trying to fix it ASAP

  • How to compare table data and table field

    Hi buddy,
        I have some question about how to compare table data and table field.
       1. I know there is one method:   CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS  , it use in unit test to compare the table data(A and B) , you can loop table A into structure A1, then use this mehtod it can compare whether table B contain structure A1.  but when I try to use this in main program it will dump.
              CL_ABAP_UNIT_ASSERT=>ASSERT_TABLE_CONTAINS(
                                                                                                        LINE    = A1
                                                                                                        TABLE = B ).
           Is there any method or FM can be used to compare the table data ?
        2. I also want to compare two table field , try to find out the different. How to realize this.
    Thank you for your sincerely answer.

    Hi Zongjie,
    What`s the difference, if you using loop A into wa_A, read table B into wa_B with all field, then compare with wa_A and wa_B.
    The question 2, seems no standard FM available here.
    Loop A into wa_A.
       Loop B into wa_B.
           if wa_A-field1 eq wa_B-field1.
           endif.
            if wa_A-field2 eq wa_B-field2. 
           endif.
       endloop.
    endloop.
    regards,
    Archer

  • Urgent!! How to update Planning book and change when planning will start

    Hi Gurus,
                 I had configured the system and we can initilize planning area every month and my question is 
    1. How to update planning book and change planning start date every month?
    Thanks a Lot
    Regards,
    Raj

    Hi,
    In the planning book-dataview, you will assign the time bucket profile, and will be on rollling basis. if you want the forecast profile on rolling basis, maintain the forecast and history horizon as periods then that will also be on rolling basis.
    Regards,
    Raj

Maybe you are looking for

  • While activating the ODS i'm getting these errrors

    Hi All, While activating the ODS i'm getting these errrors, 1) The creation of the Export Datasource failed 2) RFC Connection to the source system is damaged --- no metadata upload 3) Error when activating ODS object What would be the reasons........

  • How do i turn off iMessage on my macbook pro

    How do i turn off imessage on my Macbook pro, or at least change the phone number

  • Where can i find the XI benefit documents

    Dear SIr, Where can i find the XI  documents with related to the Business benefit , ROI Thank you and best regards, Vimol

  • Pages won't let me open a document, says "unable to open document"

    Pages for my iPad 2 is preventing me from opening one specific file. I reaaally need that file back but I can't open it or transfer it anyway. Every time I click on it it says "unable to open document." Pleaaaase help!

  • Firefox 36 Problem

    After upgrading to Firefox 36 I can't watch Youtube videos on other sites, while other type of flash players take longer than usual to load. When I downgrade to Firefox 35, I don't have any of this problems, so these problems are definitely caused by