How to save multi people picker values using angularjs? - sharepoint

How to save the multipeople picker values in sharepoint list using angularjs and rest api?

visit http://matthewyarlett.blogspot.in/2015/04/using-microsoft-client-side-people.html
and costruct your metadata in this way
var taskProperties = {
'__metadata' : { 'type': 'SP.Data.TasksListItem' },
'Title': 'Order approval',
'AssignedToId' : { 'results': [10] }
};

For inserting multiple values to person or group column, we have to specify the ids of people or group.
var taskProperties = {
__metadata: { "type": "SP.Data.TasksListItem" },
Title: "Order approval",
AssignedToId: { 'results': [11,22] }
}
http://www.codeproject.com/Articles/990131/CRUD-Operation-to-List-Using-SharePoint-Rest-API

Related

How can I filter mongodb documents saved using checkboxes?

I am building an app using node.js MongoDB and express.
I have a collection that specifies both countries and deposit methods.
Right now I input the data using checkboxes when the name is "country[country]" and the [country] represents a loop of an array called country with the whole world. the same for deposit options.
and the outcome looks like :
{ "_id" :
ObjectId("),
"country" : [ { "Germany" : "on" , "France" : "on, etc} ],
"deposit" : [ { "paypal" : "on", "visa" : "on" etc } ],
},
"__v" : 0 }
Eventually what I need is for someone to be able to use filters to select multiple countries, deposit options, and other things to filter results.
So far I managed to use /location?country=Germany&dm=paypal
router.get("/location", function(req, res) {
var country = req.query.country;
var depositMethod = req.query.dm;
if (country === undefined) {
country = ''
} else {
country = 'country.'+country;
};
// check if there is deposit query
if (depositMethod === undefined) {
depositMethod = ''
} else {
depositMethod = 'deposit.'+depositMethod;
};
db.casinos.find( { $and: [ { [country] :"on" }, { [depositMethod] :"on" } ] } )
In order to find documents that have both queries, also managed to get each one separately using $or.
What I really need is to be able to do both, and also be able to scale countries and deposit methods to many more options, prices or whatever...
without writing dozens of routes.
Hope someone could help.
And sorry if this question was already asked I tried my best to find an answer before submitting this question

Decrement value in mongodb

I am creating a shopping application. Each user have wallet.
Structure is like :
{
"userName" : "Gandalf the Grey",
"wallet" : 100,
"orderHistory" : []
}
Say this user buys something that costs 50 units. Is there a better way Instead of fetching its wallet value with findOne, then making substraction and updating new wallet value? Right now, I am making it with 2 different operations that looks like
dbo.collection('users').findOne({'userName': controller.userName})
.then(function(doc) {
updateWallet(doc);
}
then
let newWalletBalance = doc.wallet - product.cost;
dbo.collection('users').updateOne(
{'userName':controller.userName},
{ $set: {wallet: newWalletBalance } }
);
Is it possible to merge them into one?
You can use $inc operator
db.collection('users').updateOne(
{ 'userName': controller.userName },
{ '$inc': { 'wallet': -product.cost } }
)

To generate dynamic List in Action on Google

In my Action on Google #AOG App, based on the use input the number of items in the List is dyanmic. Can you please let me know how to generate the List Dynamically in "actions-on-google"
My Data Structure : "filteredKural" is array of objects with parameters "kuralNumber" and "tamilKural". created an itemsObject and assigned it to the List items parameter but it is not working. Can you please suggest any alternate ways through which i can generate the items value dynamically.
The below code is not working.
for (i=0; i<filteredKural.length;i++)
{
let keyName = `Kural ${filteredKural[i].kuralNumber}`;
itemsObject[keyName] = { title:filteredKural[i].kuralNumber, description:filteredKural[i].tamiKural};
}
/* console.log(itemsObject) // Output of the itemsObject
{ 'Kural 11':
{ title: '11',description:'வான்நின்று உலகம் வழங்கி வருதலால் தான்அமிழ்தம் என்றுணரற் பாற்று.' },
'Kural 12':
{ title: '12',description:'துப்பார்க்குத் துப்பாய துப்பாக்கித் துப்பார்க்குத் துப்பாய தூஉம் மழை.' },
'Kural 13':
{ title: '13',description:'விண்இன்று பொய்ப்பின் விரிநீர் வியனுலகத்து உள்நின்று உடற்றும் பசி.' },
'Kural 14':
{ title: '14',description: 'ஏரின் உழாஅர் உழவர் புயல்என்னும் வாரி வளங்குன்றிக் கால்.' },
'Kural 15':
{ title: '15',description:'கெடுப்பதூஉம் கெட்டார்க்குச் சார்வாய்மற் றாங்கே எடுப்பதூஉம் எல்லாம் மழை.' },
*/
conv.ask('The list of Kural');
conv.ask ( new List ({
title: 'kural List',
items : itemsObject, // this is not working
}));

How to do nested search with custom variable in ealsticsearch using nodejs?

This is my data saved in elastic search:
{
index: productName,
type: 'users',
body: {
name:'xyz',
subject:{
12:{
id:12,
name:Maths
count:3
},
13:{
id:13,
name:Physics
count:7
}
}
}
}
Is There a way to somehow search and get total number of users whose count in maths is greater than 0. Where 12 will be in a variable say subject_id.
I tried searching in the docs but coudn't find any one example to use.
I am new to elastic search any help would be appreciated thanks.
Create an object first, like this:
var queryObj = {
"query":{
"range":{
}
}
};
queryObj.query.range['subjects.'+data.subject_id+'.opened']={
"gte":1
};
then pass this object in the body of elastic search like this
elasticClient.search({
index: indexName,
type: type,
body: {
queryObj
}
}).then(promiseFunc)

Define advanced criteria for join tables in smartclient grid component for Openbravo ERP

I'm newbie in a OpenBravo ERP system, so I'm sorry if I posted an obvious question.
I have created a custom MDI view in Openbravo ERP, added some input field for filtering product's name in Smarclient's listgrid which contains Orders. I have created a Order datasource and bind it to the Smartclient grid. What I want to achieve is to filter a Order list in the grid by product name which is added in the input text field. I tried with several approaches but without success.
So I came to question is it possible to add join table in AdvancedCriteria in the grid's fetchData function?
Here is a snippet of my code:
isc.ELB_MainView.addProperties({
form: null,
grid: null,
initWidget: function () {
this.grid = isc.OBGrid.create({
setDataSource: function (ds, fields) {
var selectedFields = [],
fs = OB.Constants.FIELDSEPARATOR,
ident = OB.Constants.IDENTIFIER,
fieldNames = ['documentNo', 'documentStatus', 'orderDate', 'accountingDate', 'businessPartner'+fs+ident, 'currency'+fs+ident],
i, j;
for(i = 0; i < fieldNames.length; i++) {
for(j in ds.fields) {
if(ds.fields.hasOwnProperty(j) && j === fieldNames[i]) {
selectedFields.push(ds.fields[j]);
}
}
}
this.Super('setDataSource', [ds, selectedFields]);
this.fetchData();
}
});
this.form = isc.DynamicForm.create({
fields: [{name : "productName",
title: "Product Name",
type : "text",
width: '100%',
change: function(form, item, value, oldValue){
form.main.grid.invalidateCache();
form.main.grid.fetchData({
_constructor: 'AdvancedCriteria',
operator: 'and',
criteria: {
'fieldName': 'orderLineList.product.name',
'operator': 'equals',
'value': value
}
});
this.Super('change', arguments);
}}],
main: this
});
OB.Datasource.get('Order', this.grid, null, true);
this.addMember(this.form);
this.addMember(this.grid);
this.Super("initWidget", arguments);
}
});
Tnx in advance.
Similar question is posted on SmartClient Forum about Joining tables for listgrid datasource.
Here is my solution that will definitely solve your problem:
Create a view that is created by joining tables required for grid and use it as data source

Resources