I got the data from the sharepoint but can't read the tables or the data because in JSON how can I get the value inside the metadata
spauth.getAuth(url, {
username:username,
password:password
})
.then(function(options){
console.log(listTitle)
var headers = options.headers;
headers['Accept'] = 'application/json;odata=verbose';
// Pull the SharePoint list items
requestprom.get({
url: url+"/_api/web/lists/getbytitle('Documents')/items(xxxx)",
headers: headers,
json: true
}).then(function(listresponse){
// var items = listresponse.d;
var items = listresponse;
var responseJSON = [];
console.log(items);
Code
Data get
For SharePoint Online, we could use Graph API to get the value of the excel.
Try this endpoint:
https://graph.microsoft.com/v1.0/sites/domain.sharepoint.com,id,id/drives/drive id/items/item id/workbook
You could take a look at the following blog:
Accessing the Excel file content
Test result:
Official document for your reference:
Get Worksheet
Related
I'm working on contentful to create blog posts.
I have created a field named with category with dropdown data, like the below image.
I have created more blogs for each categories (Ex: game has 5 blogs, Tour has 10 blogs and etc).
I want to show the list of all categories with content counts,
Is there any possible to get all of the categories with content count? ( I can get it by getting all blogs using this query
const res = ContentfulService.getEntries({ content_type: 'blog'})
then I grouped with category, but to get the category only, I don't want to get all of the blogs.)
Please let me know if there is a solution.
Thanks
The only way to do this through the API would be to make a request for each category and look at the total property of the response and that would be less efficient than what you're already suggesting.
https://cdn.contentful.com/spaces/{space_id}/environments/{environment_id}/entries?access_token={access_token}&content_type={content_type}&fields.category[in]={categoryValue}
I have achieved that using graphQL,
const query =
{
categoryCollection
{
items{
linkedFrom {
blogCollection {
total
}
}
name:category
sys {
id
}
}
}
}
let categories = await fetch(https://graphql.contentful.com/content/v1/spaces/${spaceId}, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
// Authenticate the request
Authorization: Bearer ${accessToken},
},
// send the GraphQL query
body: JSON.stringify({ query }),
})
We loaded a SP list directly from an Access query and now when we try to run a list update with pnpjs I get an "Error code: -2130575163.List data validation failed" .
There are no required fields, no validation on any columns, and no Validation settings on the list. Is this not working because it was uploaded from Access?
Updating it similar to this:
const items = await sp.web.lists.getByTitle("MyList").items.top(1).filter("Title eq 'A Title'").get();
const updatedItem = await sp.web.lists.getByTitle("MyList").items.getById(items[0].Id).update({
my_id: mynewID,
})
Adding list items works with no issues. Updating a list item does not work.
Try this.
let list = sp.web.lists.getByTitle("MyList");
const i = await list.items.getById(1).update({
Title: "My New Title",
Description: "Here is a new description"
});
console.log(i);
Is items[0].Id valid ?
Please try to use console.log (items[0].Id) to check in Developer Tool.
I tested the same request in my side, my_id is a number field:
const items = await sp.web.lists.getByTitle("JqueryList").items.top(1).filter("Title eq 'My New Title'").get();
console.log(items);
let list = sp.web.lists.getByTitle("JqueryList");
const i = await list.items.getById(items[0].Id).update({
Title: "My New Title",
my_id: 1
});
I did resolve it - when you use the StrReverse function in Access and then upload that query to a SP list - the list type is corrupted.
To fix it I simply went in and changed the type from single line text to multiline - then back to single line of text.
I was then able to update the list item.
I need to load .xlsx in node and angularjs app.
i have used some packages for that purpose like js-xlsx it give me a all the data, but I can't find images of the excel sheets nor in JSON neither in HTML generated by js-xlsx package.
var wb = XLSX.read(data.data, {
type: "array"
});
let sheets = [];
for (const key in wb.Sheets) {
sheets.push({
paneId: key.replace(/ /g, '').toLowerCase(),
title: key,
active: false,
disabled: false,
data: $scope.processData(XLSX.utils.sheet_to_csv(wb.Sheets[key]))
})
}
I have also tried.
XLSX.utils.sheet_to_json(wb.Sheets[key])
XLSX.utils.sheet_to_html(wb.Sheets[key])
$scope.processData is the function for converting csv to array.
I'm new to NodeJS and I'm trying to learn it a bit better by writing a Discord bot. But I'm having an issue with stringifying an object to JSON. I think it's having an issue with the array I'm setting, but I'm not sure how else I would do this. If I'm not supposed to set an array and using my guildMembers example below, how else should I insert this data into my JSON file?
I've looked through a few examples here on StackOverflow and found this particular article: JSON Stringify Removing Data From Object. However, it's not clear to me given what I'm trying to achieve.
var o = {};
var guildKey = guild.id;
o[guildKey] = [];
o[guildKey]['guildMembers'] = {};
var guildMembers = []
guild.members.forEach(function(guildMember, guildMemberId) {
if (!guildMember.user.bot){
var memberData = {
id: guildMember.id,
data: {
userName: guildMember.user.username,
nickName: guildMember.nickname,
displayName: guildMember.displayName,
joinedAt: guildMember.joinedAt
}
}
guildMembers.push(memberData);
};
});
o[guildKey]['guildMembers'] = guildMembers;
json = JSON.stringify(o);
I am expecting the data to show the guildMembers object with the array under the guildKey object. However, the JSON shows only the guildKey object with an empty array:
{"guildKey":[]}
You make guildKey an array and then try to use it as an object ...
Solution is:
o[guildKey] = {};
Just like in the mentioned post.
It is because you are assigning a key-value pair to an array with
o[guildKey]['guildMembers'] = { }; <= o[guildKey]
When iterating over an array to display the contents, JavaScript does not access non-integer keys. You should store o[guildKey] as an object instead.
I have created a saved search for transaction in netsuite and with suitescript 2.0 I am showing saved search data in my application. In application user can apply filter on any fields (please see the attached screenshot). For example user select "Aug 2011" for posting period, only transactions of Aug 2011 should be loaded. This works fine if I create a filter with internalid of "Aug 2011", but on UI I dont have internal id.
sample code:
/*
here is my required module
*/
function getTransactionData(datain)
{
try
{
var objSearch = search.load
({
id: datain.savedsearchid
});
/***** Work *****/
objSearch.filters.push(search.createFilter({ name: "postingperiod", operator: "ANYOF", values: "1" })); //here 1 is internalid of periodname "Aug 2011"
/***** Not Work (SSS_INVALID_SRCH_FILTER_JOIN) *****/
//objSearch.filters.push(search.createFilter({ name: "postingperiod", join: "accountingperiod", operator: "ANYOF", values: "Aug 2011" }));
objSearch.run();
}
catch(ex)
{
log.error("getTransactionData", ex);
throw ex;
}
}
I tried with join but seeing "SSS_INVALID_SRCH_FILTER_JOIN" error from Netsuite.
Can any one please help me regarding this.
Thanks in advance
I edited your code to a more simplified one to understand better.
If you get the gist of how it works, you can edit/customize the way you want.
I assume there is join 'accountingperiod' option available for 'postingperiod' and this works perfectly in your saved search you created in netsuite without using suitescript.
/*
here is my required module
*/
function getTransactionData(datain) {
try {
var objSearch = search.load({
id: datain.savedsearchid
});
var defaultFilters = objSearch.filters;
var customFilters = [];
//Adding filter
customFilters = ['postingperiod', 'ANYOF', '1'];
defaultFilters.push(customFilters);
customFilters = undefined;
customFilters = [];
//Adding filter
/*
customFilters = ['postingperiod.accountingperiod', 'ANYOF', 'Aug 2011'];
defaultFilters.push(customFilters);
*/
objSearch.filters = defaultFilters;
var objSearch_run = objSearch.run().getRange({
start: 0,
end: 10
});
} catch (ex) {
log.error("getTransactionData", ex);
throw ex;
}
}
If you want to know how filters is stored in saved search you created in netsuite, you can use the script debugger.
The following code is suitescript 1.0
//Load Saved Search
get();
function get() {
var search = nlapiLoadSearch('transaction', ' ENTER SAVED SEARCH ID HERE ');
log.debug('search',search);
var searchFilters = search.getFilterExpression();
log.debug('searchFilters',searchFilters);
return search;
}
I assume your application is a Suitelet? If so, you need to do a select field type of your record. So probably of 'posting periods'. This will show your periods in a drop down.
When the user selects it, have a client side script auto refresh the data and load your saved search.
Alternatively, you can load all the data and do the filtering client side DOM filtering. Really need a bit more information about your "application".