How do you populate people picker column data with multiple values using email via JavaScript?

I’m using SharePoint 2013, my people picker column is set to accept multiple values.

I am able to post to a list item and add a single person to the column using the following method:

function updatePeopleColumn(listName, itemID) {     var siteUrl = _spPageContextInfo.webServerRelativeUrl,         clientContext = new SP.ClientContext(siteUrl),         currentWeb = clientContext.get_web(),         oList = currentWeb.get_lists().getByTitle(listName),         userObj = currentWeb.get_siteUsers().getByEmail('email@ddress.com');      this.oListItem = oList.getItemById(itemID);      oListItem.set_item('People', userObj);      oListItem.update();      clientContext.load(oListItem);     clientContext.executeQueryAsync(Function.createDelegate(this, this.onPeopleQuerySucceeded), Function.createDelegate(this, this.onQueryFailed)); }  function onPeopleQuerySucceeded(sender, args) {     console.log('Person added to People.', sender, args); }  function onQueryFailed(sender, args) {     console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); }  updatePeopleColumn('ListName', 99999); 

What I have not been able to do is gather multiple people using currentWeb.get_siteUsers().getByEmail(’email@ddress.com’), adding those to an array and passing that value to the column, like so:

function updatePeopleColumn(listName, itemID, emailAddresses) {         var siteUrl = _spPageContextInfo.webServerRelativeUrl,             clientContext = new SP.ClientContext(siteUrl),             currentWeb = clientContext.get_web(),             oList = currentWeb.get_lists().getByTitle(listName),             users = [],             i;          for (i = 0; i < emailAddresses.length; i++) {             var userObj = currentWeb.get_siteUsers().getByEmail(emailAddresses[i]);              users.push(userObj);         }          this.oListItem = oList.getItemById(itemID);          oListItem.set_item('People', users);          oListItem.update();          clientContext.load(oListItem);         clientContext.executeQueryAsync(Function.createDelegate(this, this.onPeopleQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));     }      function onPeopleQuerySucceeded(sender, args) {         console.log('People added to People.', sender, args);     }      function onQueryFailed(sender, args) {         console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());     } updatePeopleColumn('ListName', 99999, ['email@ddress.com', 'email2@ddress.com']); 

So how do I pass multiple values to the people column using emails?

Sharepoint: Pulling String information from a list item to populate external URL

I am working with Sharepoint 2013, and I have a list of items that have a client id. These client ids are references to a database referenced by another group. I am wanting to pull the string information from a list item to populate a variable in a URL for a Custom Action. Please see example for clarification.

enter image description here

I want to extract the actual ClientID to insert into a URL when clicked. (i.e. https://mywebsite.com/customerno=[ClientID_from_List_1]/showall.aspx

So if I clicked CASABONITAS ClientID in Sharepoint it would open a new page with the URL being https://mywebsite.com/customerno=123456/showall.aspx

I have done some searching and cannot find any customized tokens that can be used for extracting this information, any assistance would be greatly appreciated.

Populate Fields when Clicking “Save” on Custom List

I have a SP 2013 Custom List with 2 automatically generated numbers. Currently, they are queried and populated upon selection of input values for the first 2 fields. The form works great for a single user, but I’d like to accommodate simultaneous users if possible. As is, having simultaneous users can create duplicate tracking numbers.

I tried running the queries and populating the 2 fields which are each a portion of the tracking number (calculated field) within the PreSaveAction function, which does populate the fields on the new item form, however, the values do not get saved within the list item on the AllItems page.

Any ideas on a way to make this work? Here’s my code:

// Query item ID for most recent item with the selected associated tracking number var collListItems; function QueryExistingLastID() {     var rvID = $  ("input:text[title='Associated Tracking Number']").val();     var clientContext = new SP.ClientContext();     var TrackerList = clientContext.get_web().get_lists().getByTitle('Tracker');     var query = new SP.CamlQuery();     query.set_viewXml("<View><RowLimit>1</RowLimit><Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy><Where><Eq><FieldRef Name='Status'/><Value Type='Text'>" + rvID + "</Value></Eq></Where></Query></View>");     collListItems = TrackerList.getItems(query);     clientContext.load(collListItems);     clientContext.executeQueryAsync(Function.createDelegate(this, this.ExistingQuerySucceed), Function.createDelegate(this, this.ExistingQueryFailed)); }  // Populate subject number by adding 1 to the previous subject number for the selected associated tracking number function ExistingQuerySucceed(sender, args) {     var listItemEnumerator = collListItems.getEnumerator();     while (listItemEnumerator.moveNext()) {         var oListItem = listItemEnumerator.get_current();            }     if ($  ("select[id^='Status']").val() == "Existing")     {     $  ("input[id^='Subject_x0020_Num']").val(oListItem.get_item("Subject_x0020_Num")+1);     } }  function ExistingQueryFailed(sender, args) {     // Alert error message if list item above fails to load     alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace()); }  // Query last list item where Status = "New" var collListItem; function QueryLastNewItem() {     var clientContext = new SP.ClientContext();     var TrackerList = clientContext.get_web().get_lists().getByTitle('Tracker');     var query = new SP.CamlQuery();     query.set_viewXml("<View><RowLimit>1</RowLimit><Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy><Where><Eq><FieldRef Name='Status' /><Value Type='Text'>New</Value></Eq></Where></Query></View>");     collListItem = TrackerList.getItems(query);     clientContext.load(collListItem);     clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));         }  // Populate new tracking number by adding 1 to the most recent tracking number function onQuerySucceeded(sender, args) {     var listItemEnumerator = collListItem.getEnumerator();     while (listItemEnumerator.moveNext()) {         var oListItem = listItemEnumerator.get_current();            }     if ($  ("select[id^='Status']").val() == "New")         {         $  ("input[id^='Tracking_x0020_Numbe']").val(oListItem.get_item('Tracking_x0020_Numbe')+1);         } }   function onQueryFailed(sender, args) {     // Alert error message if list item above fails to load     alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace()); }  // Validate that an appropriate Associated Tracking Number has been selected if the first field says existing function PreSaveAction() {     var q = document.getElementById('Status$  DropDownChoice');     var question = q.options[q.selectedIndex].text;      var rvtracking = $  ("input:text[title='Associated Tracking Number']").val();     var re_rvtracking = /^RVFUF[0-9]{2,2}-[0-9]{4,4}$  /;      if((!re_rvtracking.test(rvtracking)) && question == "Existing")     {     $  (".ms-metadata:contains('You must search and select the associated tracking number from the drop down options.')").css("color", "FireBrick");     return false;     }      else     {     $  (".ms-metadata:contains('You must search and select the associated tracking number from the drop down options.')").css("color", "DimGray");     // Run the queries and populate the fields as indicated above     QueryLastNewItem();     QueryExistingLastID();     return true;     } } 

Populate de un array de IDs anidada en mongoose

Tengo el modelos de los usuarios y el modelos de los post. En el modelo de los post, cuando un usuario hace like a un post, hago referencia a la id de ese usuario.

En el modelo de los user hago lo mismo, cuando el user da like a un post, añado la id del post al que le ha dado like.

Cuando se cargan los posts, necesito obtener la data de los usuarios que han dado like a ese post y he hecho lo siguiente:

Modelo user:

const userSchema = new Schema({  name: {     type: String,     required: [ true, 'El nombre es necesario' ] }, avatar: {     type: String,     default: `av-1.png` }, email: {     type: String,     unique: true,     required: [ true, 'El email es necesario' ] }, password: {     type: String,     required: [ true, 'La contraseña es necesaria' ] }, likes: [{     type: Schema.Types.ObjectId,//String      ref: 'Post' }]}); 

Modelo post:

const postSchema = new Schema({   created: {     type: Date }, message: {     type: String }, imgs: [{     type: String }], coords: {     type: String }, user: {     type: Schema.Types.ObjectId,     ref: 'User',     required: [ true, 'Debe existir una relación con un usuario' ] }, info: {     likes: {         number: {             type: Number         },         usersId: [{             type: Schema.Types.ObjectId,             ref: 'User'         }]     } }    }); 

Obtención de los post con los usuarios que han dado like populados:

const posts = await Post.find()                         .sort({_id: -1})                 // Orden descendente                         .skip( skip )                         .limit(10)                       // Maximo 10 por petición                         .populate('user', '-password')                         .populate( {                              path: 'metrics',                             populate: {                                 path: 'likes',                                 populate: {                                     path: 'userId',                                   }                                }                            } )  // Obtener datos user -pass                         .exec();   res.json({     ok: true,     page,     posts }); 

Error: (node:8216) UnhandledPromiseRejectionWarning: CastError: Cast to ObjectId failed for value “{ usersId: [] }” at path “_id” for model “Post”

¿Como puedo hacer para obtener la data de todos los usuarios que hay en el array userId?

Magento 2 – How to use dynamic row system to populate form in custom shipping module

I built a Magento 2 custom module for shipping that has a select drop down field for users to choose an option. I want to be able to set those options in the admin for the module using the dynamic row system. I have the form built and working. This is the section for the select box using:

frontend>layout>checkout_index_index.xml

<item name="checkout_building_address" xsi:type="array">         <item name="component" xsi:type="string">Magento_Ui/js/form/element/select</item>         <item name="config" xsi:type="array">             <item name="customScope" xsi:type="string">customCheckoutForm</item>             <item name="template" xsi:type="string">ui/form/field</item>             <item name="elementTmpl" xsi:type="string">ui/form/element/select</item>         </item>         <item name="options" xsi:type="array">             <item name="0" xsi:type="array">                 <item name="label" xsi:type="string">Please select value</item>                 <item name="value" xsi:type="string"></item>             </item>             <item name="1" xsi:type="array">                 <item name="label" xsi:type="string">Option 1</item>                 <item name="value" xsi:type="string">value_1</item>             </item>             <item name="2" xsi:type="array">                 <item name="label" xsi:type="string">Option 2</item>                 <item name="value" xsi:type="string">value_2</item>             </item>         </item>         <item name="value" xsi:type="string">Please Select Value</item>         <item name="provider" xsi:type="string">checkoutProvider</item>         <item name="dataScope" xsi:type="string">customCheckoutForm.checkout_building_address</item>         <item name="label" xsi:type="string">Select Building Address</item>         <item name="sortOrder" xsi:type="string">2</item>     </item> 

I also followed the Mage docs for getting the dynamic rows in the admin. That is working fine and saves the information to the core_config_data table as a serialized array.

{"_1564590939871_871":{"addresses":"123 Amy Street Any Town, CA 92234"},"_1564593462830_830":{"addresses":"1475 Main St. Any Town, CA 90210"}} 

I cannot figure out how to get that data to populate the select box in my form.

Thanks in advance for the help!

* UPDATE * I am now using this in Helper>Data.php

public function getJsonConfigValue($  configPath, $  store = null)     {         $  value = $  this->getJsonConfigValue($  configPath, $  store);          if (empty($  value)) return false;          if ($  this->isSerialized($  value)) {             $  unserializer = ObjectManager::getInstance()->get(\Magento\Framework\Unserialize\Unserialize::class);         } else {             $  unserializer = ObjectManager::getInstance()->get(\Magento\Framework\Serialize\Serializer\Json::class);         }          return $  unserializer->unserialize($  value);     } 

and I can see that data in a template using:

public function getJsonSerialized()     {            $  arrayItems = $  this->helper->getJsonConfigValue('carriers/dynamic/addresses/address_list');          return json_encode($  arrayItems);     } 

And this in a template file view>frontend>templates>array.phtml

<?php echo $  block->getJsonSerialized(); ?> 

And it appears like this on the page:

{"_1564763325005_5":{"addresses":"123 My Street, Bldg. 1, My Town, IA 00351"}} 

How do I turn it into something that I can use in a form I built in a custom module to populate the select drop down field?

It this my problem? – return json_encode($ arrayItems);

I can’t find what I think I am looking for.

Thanks!

Populate field onLoad Social feed SharePoint 2013

I am try to auto populate user e-mail,name,title on a sharepoint form. I can see the values when I inspect the page (F12) but they dont appear on the form onload. i obtain the input fields id via the developer tool, not 100% sure I am using the correct ID.

here is the code I am using:

$  (function () { getUserProfileInfo(); 

});

function getUserProfileInfo() {

var fullUrl = "https://sites/sites/dome/_api/social.feed/my";  $  .ajax({     url: fullUrl,     type: "GET",     headers: {         "accept": "application/json;odata=verbose",         "content-type": "application/json;odata=verbose",     },     success: onUserInfoQuerySucceeded,     error: onQueryFailed }); 

}

function onUserInfoQuerySucceeded(data) { var userInfoItemE = data.d.Me.EmailAddress; var userInfoItemN = data.d.Me.Name; var userInfoItemT = data.d.Me.Title;

document.getElementById('Email_a6570af6-8b72-4ab0-814d-93f50f26e185_$  TextField').innerHTML = userInfoItemE; document.getElementById('Name_b6023c0f-43be-45b4-b946-22ac2933bb77_$  TextField').innerHTML = userInfoItemN; document.getElementById('Title_fa564e0f-0c70-4ab9-b863-0177e6ddd247_$  TextField').innerHTML = userInfoItemT; 

} function onQueryFailed(sender, args) { alert(“Error”); }

Why would you populate a temp table for reporting?

I’m maintaining a legacy accounting application that runs nearly all of its reports by populating a temp table at runtime. The temp table is dropped on a daily basis and includes information about the report’s configuration (i.e. which terminal ran it, landscape vs. portrait etc…). Is there a reason to have the application do this rather than select the configuration view in real time and pull the data it needs from a custom view?