How to set values to a multi choice field using SPServices in SharePoint ?
This Code worked
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
listName: "Projets",
ID: 53,
valuepairs: [
["ProjectName", "Project"],
["ProjectType", "OPPS"],
["ConcernedServices", JSON.stringify($('#select-multiple-optgroups').val())],
["Cible", "Résidentiel"],
["DateRFF", "2014-12-31"],
["DateLancementPrevisionnelle", "2014-12-31"],
["DateDeFin", "2014-12-31"],
["Priorite", "PA"],
["Concept", "dfsf"],
["Reference", "FDF"],
],
completefunc: function (xData, Status) {
}});
But if I want to add multiple choice doesn't work
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
webURL: "/sites/ep/",
listName: "Projets",
ID: 53,
valuepairs: [
["ProjectName", "Project"],
["ProjectType", "OPPS"],
["ConcernedServices", JSON.stringify($('#select-multiple-optgroups').val())],
["Cible", "Résidentiel, Business"],
["DateRFF", "2014-12-31"],
["DateLancementPrevisionnelle", "2014-12-31"],
["DateDeFin", "2014-12-31"],
["Priorite", "PA"],
["Concept", "dfsf"],
["Reference", "FDF"],
],
completefunc: function (xData, Status) {
}});
Cible is a Multiple Choice field in a sharepoint List.
Since SPServices is calling the OOB webservices behind the scenes, in theory the standard means of updating multiple choice values should come into play: Delimit the values with ;#
E.g.
";#Résidentiel;#Business;#"
Note: Order matters. Make sure values are specified in the same order they're defined in the column
I came across this post while trying to achieve the same thing, however this answer didn't work for me. I was eventually able to save multiple values in the lookup field using the following format:
"6;#;#8;#"
Where the numbers are the ID of the list items (to save formatting issues)
With the ID and the title of the list item it looked like this:
"6;#Alcohol:Reports;#4;#Alcohol: News"
Both of these methods successfully inserted the values into the list.
Related
I have two lists:
Clientes-Canal: TITLE
Clientes-Subsegmentacion: TITLE - CANAL (Lookup to Clientes-Canal)
Clientes: where I save all the information
My code:
$(document).ready(function () {
$().SPServices.SPCascadeDropdowns({
relationshipList: "Clientes-Subsegmentacion",
relationshipListParentColumn: "Clientes-Canal",
relationshipListChildColumn: "Title",
parentColumn: "Canal",
childColumn: "Subsegmentacion",
debug: true
});
});
In my Clientes' list I have two columns, Canal (Lookup to Clientes-Canal), and Subsegmentacion (Lookup to Clientes-Subsegmentacion)
But it's not working.
Error: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Here are the docs:
relationshipList The name or GUID of the list which contains the
parent/child relationships. If you choose to use the GUID, it should
look like: "{E73FEA09-CF8F-4B30-88C7-6FA996EE1706}". Note also that if
you use the GUID, you do not need to specify the relatedWebURL if the
list is in another site.
relationshipListParentColumn The StaticName of the parent column in
the relationshipList
relationshipListChildColumn The StaticName of the child column in the
relationshipList
parentColumn The DisplayName of the parent column in the form
childColumn The DisplayName of the child column in the form
So, in your case:
$(document).ready(function(){
$().SPServices.SPCascadeDropdowns({
relationshipList: "Clientes-Subsegmentacion",
relationshipListParentColumn: "Canal",
relationshipListChildColumn: "Title",
parentColumn: "Canal",
childColumn: "Subsegmentacion",
debug: true
});
});
Make sure you don't have spelling mistakes, you can also try using Id of your Clientes-Subsegmentacion list.
Take a look at my answer here on similar question if my answer doesn't help you.
I need to retrieve the inventory summary for all Stock Items so that I can update an external site's inventory according to the "Available For Shipment" field on the inventory summary. I have attempted running the inventory summary via the rest API using the following method after logging in:
URL: https://mycompany.acumatica.com/entity/Default/6.00.001/InventorySummaryInquiry
Method: PUT
Request Body:
{
"InventoryID": "CW-500-MC-30"
}
However I receive this response:
{
"message": "The request is invalid.",
"modelState": {
"": [
"Error reading JObject from JsonReader. Current JsonReader item is not an object: String. Path 'InventoryID', line 2, position 30."
]
}
}
If there is a way to run the inquiry and have it return ALL stock items in an array, that would be ideal.
If that's not possible, what do I need to change to get the individual stock item inventory summary to work?
UPDATE:
After modifying my request body as #samol518 suggested, the request worked, but returned a very limited set of data (below). I'm looking to get to the "quantity available for shipment". Do I need to provide additional parameters to get more data returned?
{
"id": "bf8e0bbc-63dc-4491-802d-090367af203a",
"rowNumber": 1,
"note": null,
"ExpandByLotSerialNumber": {},
"InventoryID": {
"value": "CW-500-MC-30"
},
"LocationID": {},
"WarehouseID": {},
"custom": {},
"files": []
}
If I am not mistaken the correct structure for the Request Body should resemble the following :
Request Body :
{
"InventoryID": {"value": "CW-500-MC-30"}
}
Though if you want to retrieve all Stock Item, you could try and customize the inquiry in order to do so.
Update:
in order to retrieve all record, you might notice that the result fields are in a sub entity in the endpoint definition on the Web Service Endpoint screen (SM207060).
in order to return the data for these detail type sub entities, you must add the expand key word to your URL in the following format.
$expand=results
So your final URL should look like :
https://mycompany.acumatica.com/entity/Default/6.00.001/InventorySummaryInquiry?$expand=Results
Let's say I have 1000 items like this:
{ "_id": "12345", "type": "item", "name": "whatever", "timestamp": 1481659373 }
And I have a view that grabs only a specific type.
View
function (doc) { emit([doc.type], doc._id); }
Parameters
startkey: ["item"]
endkey: ["item"]
include_docs: true
I know I can use offset and limit for pagination. But I'm trying to grab the most recent timestamps first in descending order. I see that there is a descending option but it looks like you only set it to true so I'm not sure of its functionality.
Does anyone have any guidance on how I could do accomplish this?
If you modify your Map function to read:
function (doc) { emit([doc.type, doc.timestamp], doc._id); }
Then the keys in the view will be sorted by type and then by timestamp.
We can then query the view like so:
startkey: ["itemz"]
endkey: ["item"]
descending: true
include_docs: true
To get the most recent docs first. The descending flag indicates you want the items in reverse order, but you also have to ensure that your startkey has large value.
I tried to insert the following test document:
db.documents.write(
{
uri: "/test/doc1.json",
contentType: "application/json",
collections: "test",
content: {
name : "Peter",
hobby: "Sleeping",
other: "Some other info",
"triple": {
"subject": {
"datatype": "http://example.com/name/",
"value": "Peter"
},
"predicate": {
"datatype": "http://example.com/relation/",
"value": "livesin"
},
"object": {
"datatype": "http://example.com/location/",
"value": "Paris"
}
}
}
}
).
result(function(response){
console.log("Done loading");
});
Then I queried as follows:
var query = [
'SELECT ?s ?p ?o' ,
'WHERE { ?s ?p ?o }' ,
];
db.graphs.sparql('application/sparql-results+json', query.join('\n')
).result(function (result) {
console.log(JSON.stringify(result, null, 2));
}, function(error) {
console.log(JSON.stringify(error, null, 2));
});
The results showed me the values of the triple, but what if I also want to get the entire document where the triple was embedded? Is it also possible to filter by other fields in the document?
There isn't a way to retrieve the document that contains the result of a SPARQL query, because those results may not be a triple that exists within a particular document (instead, it returns a "solution" consisting of 1 or more values).
If you know you are looking for a particular triple, and you want the document that holds that triple, I would normally say to use a cts:triple-range-query; however, I don't see a way to do that through the Node.js API (or through REST, for that matter). With that in mind, I see two choices:
insert a triple that includes the document's URI as the subject or object, then make a request for that document (as #grtjn suggested)
make a REST API extension (using either JavaScript or XQuery) that calls cts:search with cts:triple-range-query as part of the query; call that extension from Node
I'd recommend doing it in two stages:
Run a sparql that will return document uris.
Run a document search to return those documents, optionally further constrained with extra criteria.
For this you will need to embed triples in your documents listing the document uri of the documents themselves.
HTH!
I would like to search datagrid in Kendo UI during typing into input field above the grid.
How can I do it?
Thanks for any advice.
Here is example of columns:
$("#grid").kendoGrid({
dataSource: dataPacket,
filterable: true,
pageSize: 10,
pageable: true,
sortable: true,
reorderable: true,
resizable: true,
columnMenu: true,
height: 550,
toolbar: ["create", "save", "cancel"],
columns: ["id",
"username",
"name",
"surname",
"email",
{
field :"created",
title : "Created at",
format: "{0:M/d/yyyy}",
parseFormats: ["dd-MM-yyyy"],
type: "date"
},
Kendo make this thing really easy for you, what is needed is to create a filter and pass it to the DataSource.
http://docs.telerik.com/kendo-ui/api/framework/datasource#methods-filter
However, this problem must be divided into two different tasks:
a) Capture the key events in the search box, throttle it and start the search "operation".
b) Build a filter and pass it to the DataSource.
So for throttling the keyboard events, we need a timeout. Or use the throttle function from underscorejs. Why? We don't wanna trigger a search operation on each key press. Only 250 milliseconds (this number is up to you) after the last keystroke.
Here is your sample HTML
<input type="text" id="search" />
Here is your sample script. I wrap everything as a self calling function as you don't wanna create a mess declaring global variables.
(function($, kendo){
// ID of the timeout "timer" created in the last key-press
var timeout = 0;
// Our search function
var performSearch = function(){
// Our filter, an empty array mean "no filter"
var filter = [];
// Get the DataSource
var dataSource = $('#grid').data('kendoGrid').dataSource;
// Get and clean the search text.
var searchText = $.trim($('#search').val());
// Build the filter in case the user actually enter some text in the search field
if(searchText){
// In this case I wanna make a multiple column search so the filter that I want to apply will be an array of filters, with an OR logic.
filter.push({
logic: 'or',
filters:[
{ field: 'username', operator: 'contains', value: searchText },
{ field: 'name', operator: 'contains', value: searchText },
{ field: 'surname', operator: 'contains', value: searchText },
{ field: 'email', operator: 'contains', value: searchText }
]
});
}
// Apply the filter.
dataSource.filter(filter);
};
// Bind all the keyboard events that we wanna listen to the search field.
$('#search').on('keyup, keypress, change, blur', function(){
clearTimeout(timeout);
timeout = setTimeout(performSearch, 250);
});
})(window.jQuery, window.kendo);
Bottom-line: Make sure you are using the right DataSource configuration.
If you configured serverFiltering = true, this filtering logic will be part of your Ajax request, so your server will have to interpret and perform the filtering on server-side.
In case you configured serverFiltering = false all this filtering logic will be evaluated on client side using JavaScript (damn fast!). And in this case, the schema (what data-type is expected on each column) must be also well-configured.