How to fetch archived history from Chrome API - google-chrome

I would like to list archived (90+ days) history URLs from Google Chrome using Chrome API.
I realised that it's probably impossible because the results have not been returned:
let urlAmount = 0;
chrome.history.search(
{
"text": "",
"startTime": new Date(2018, 5, 14, 11, 0, 0).getTime(),
"endTime": new Date(2018, 6, 14, 11, 0, 0).getTime()
},
function(historyItems)
{
for (var i = 0; i < historyItems.length; i++)
{
urlAmount++;
}
});
As you can see I'm checking (2018.05.14 - 2018.06.14) time interval (it's more that 90 days ago from now).
urlAmount is 0 but for example (2019.01.14 - 2019.01.20) it's 100 (default max value is 100).
Is it possible to fetch such archived history this way?
If not what about Selenium automation approach?

The urlAmount variable is incremented inside a callback. So you should move its initialization to the callback function(historyItems), right before the for loop.
The default value for maxResults is 100 if you don't use it, but you can set to it a higher value.

Related

Widget Refresh at 6AM and 6PM by calling the api

Hi Could you please help me out like to refresh the widget needs to be refreshed(need to hit the api and show the updated data) twice daily it at 6AM and 6PM. Right now am using the policy with .atEND But I could see the same data is rendering at 6AM and 6PM. and the refresh ie API call is happening after 6PM. But my requirement is like to hit the api before rendering the widget at 6AM and again needs to hit the api before rendering at 6PM.
if let At6AM = Calendar.current.date(bySettingHour: 6, minute: 0, second: 0, of: Date()) {
let refreshEntryFor6AM = RecommendedWidgetEntry(date: At6AM, recommedationData: items)
refreshEntries.append(refreshEntryFor6AM)
}
if let At6PM = Calendar.current.date(bySettingHour: 18, minute: 0, second: 0, of: Date()) {
let refreshEntryFor6PM = RecommendedWidgetEntry(date: At6PM, recommedationData: items)
refreshEntries.append(refreshEntryFor6PM)
}
let timeline = Timeline(entries: refreshEntries, policy: .atEnd)

Google Apps Script not incrementing date correctly after 12/25/2021

This is my first post here, so forgive me if I'm doing this wrong. I am incrementing a year's worth of dates as follows:
for (i = 0; i <= 360; i++){
bDate.setDate(bDate.getDate() + 1);
bArray.push([Utilities.formatDate(bDate, "GMT", "M/dd/YYYY")]);
}
It works just fine until 12/25/2021, at which point Apps Script decides to celebrate New Year's a few days early!!! See below:
[12/22/2021], [12/23/2021], [12/24/2021], [12/25/2021], [12/26/2022], [12/27/2022], [12/28/2022], [12/29/2022], [12/30/2022], [12/31/2022], [1/01/2022], [1/02/2022]
Am I doing something wrong or is this some sort of bug?
Explanation:
This must be a bug which is related in this question.
I know this is not a solution, but a workaround to solve your problem is to manually add the problematic dates, and then let the for loop continue with the rest of the dates.
Another important note is to use SpreadsheetApp.getActive().getSpreadsheetTimeZone() because right now you have hardcoded the timezone and this can result in getting wrong days.
Workaround:
function myFunction() {
const bArray =
[[ '12/22/2021' ],
[ '12/23/2021' ],
[ '12/24/2021' ],
[ '12/25/2021' ],
[ '12/26/2021' ],
[ '12/27/2021' ],
[ '12/28/2021' ],
[ '12/29/2021' ],
[ '12/30/2021' ],
[ '12/31/2021' ]];
const bDate = new Date(2022,0,1);
for (i = 0; i <= 360 - bArray.length ; i++){
bArray.push([Utilities.formatDate(bDate, SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "M/dd/YYYY")]);
bDate.setDate(bDate.getDate() + 1);
}
console.log(bArray);
}
In fact, your error comes from the misusage of the YYYY which should be here yyyy. Y stands for week year and y for year. Please read MisusedWeekYear.
And read with more attention the post question given by #somario where the solution is given at the end.

Query all the users in a specific BIM 360 account

how can I get Query all the users in a specific BIM 360 account? with no limit, because I have over 100 users :
max limit means the limit of one page (the call of one time).e.g. if you set 50, then every call, 50 items only. By default offset = 0. It means starting with the first item. i.e. one call with limit=50&offset=0 will give you No. 0-49 items only.
one call with limit=50&offset=120 will give you No. 120-169 items only.
The response of the call will tell pagination info. e.g. when I set limit=2&offset=0. It tells total number of users is 10. The next page (nexturl) will be from No 2,3.
"pagination": {
"limit": 2,
"offset": 0,
"totalResults": 10,
"nextUrl": "https://developer.api.autodesk.com/bim360/admin/v1/projects/xxxxxx-
5d39-43cb-b4c4-xxxxxx/users?limit=2&sort=name&offset=2"
},
If calling nexturl, it will tell the url of previous page(No 2,3 only) and next page (No 4,5 only).
"pagination": {
"limit": 2,
"offset": 2,
"totalResults": 10,
"nextUrl": "https://developer.api.autodesk.com/bim360/admin/v1/projects/xxxxxx-
5d39-43cb-b4c4-xxxxxx/users?limit=2&offset=4&sort=name",
"previousUrl":
"https://developer.api.autodesk.com/bim360/admin/v1/projects/xxxxxx-5d39-43cb-b4c4-
xxxxxx/users?limit=2&offset=0&sort=name"
},
And my colleague Petr's sample will be also a good reference for coding.

NetSuite - Creating PO with line items

Using Restlets I can create any records in NetSuite. However, how do we create records with line items? I know we can use the getLineItemCount, loop through these items and use the setLineItemValue to set the line item.
What I'm not sure about is how we would pass such data to start with. So, we expect an external system to submit some data which I would then need to create POs with line items using my Restlet.
I would ideally like to test this using fire fox Poster, but not sure how to model the data. Something like this works fine to create a normal record using poster by passing data like:
{ "subsidiary" : 2, "entity" : 1084,"currency" : 2,"approvalstatus" : 2}
But how would we send line item data?
My JSon Object looks like this:
{"subsidiary" : 2,
"entity" : 1275,
"currency" : 2,
"approvalstatus" : 2,
"item": [{"item" : -3, "taxrate": 6},
{"item" : -3, "taxrate": 6}]
}
I tried getting the data out of the nested jason object with the below code but doesn't quite work...the itemid is blank
for (var x = 1; x <= jsonobject.item.length; x++)
{
var itemid = record.getLineItemValue('item', jsonobject.item['item'], x);
nlapiLogExecution('DEBUG', 'itemid', itemid)
record.setLineItemValue('item', itemid, x);
}
You could try using an array within your JSON to encapsulate the line items such as:
{"subsidiary" : 2,
"entity" : 1084,
"currency" : 2,
"approvalstatus" : 2,
"items": [{name:"item1", price: "100"},
{name:"item2", price:"200"}]
}
Your RESTlet code would have to then digest this, and call the relevant NS functions you mention.
As TonyH mentioned, your code has a bug wherein you should be getting the array index first. In addition, your index should start at 0, not 1, since you are going through a JS array, not a NetSuite sublist:
for (var x = 0; x < jsonobject.item.length; x++)
{
var itemid = jsonobject.item[x]['item'];
}
The same would go if you want to get the tax rate:
for (var x = 0; x < jsonobject.item.length; x++)
{
var taxrate = jsonobject.item[x]['taxrate'];
}

AS3 sortOn woes

I have an Array called alarmQueue. I'm pushing a new arrays in to it with the contents [hours:int, minutes:int, seconds:int] and I'd like to use alarmQueue.sortOn() to sort the queue of alarms Ascending but I'm having problems getting my head around the logic.
// the function to push the alarm in to a queue
public function setAlarm(_hours:int = 0, _minutes:int = 0, _seconds:int = 0):void
{
var alarmAsArray:Array = new Array(_hours, _minutes, _seconds);
alarmQueue.push(alarmAsArray);
alarmQueue.sortOn([0, [1, 2]], Array.NUMERIC | Array.DESCENDING);
trace(alarmQueue);
}
I'm setting these alarms:
clock.setAlarm(1, 0, 31); // alarm 1
clock.setAlarm(12, 1, 21); // alarm 2
clock.setAlarm(12, 1, 19); // alarm 3
and getting the following traces:
1,0,31
12,1,21,1,0,31
12,1,21,12,1,19,1,0,31
I seem to be ordering them as: alarm 2, alarm 3, alarm 1
but I want to be ordering them by hour, then minute and seconds.
Can anyone shed any light on my sorting woes?
Cheers!
thanks for the feedback.
I've tested:
alarmQueue.push(
{
hours: _hours,
minutes: _minutes,
seconds: _seconds
});
alarmQueue.sortOn(
['hours', 'minutes', 'seconds'],
[Array.NUMERIC | Array.ASCENDING, Array.NUMERIC | Array.ASCENDING, Array.NUMERIC | Array.ASCENDING]
);
if(alarmQueue.length == 3)
{
for(var i:int = 0; i SMALLERTHAN alarmQueue.length; i++)
{
trace(alarmQueue[i].hours,alarmQueue[i].minutes, alarmQueue[i].seconds);
}
}
I had to change the trace slightly due to the array items being objects now and used SMALLERTHAN as the < symbol seems to break to code tags here, but the app wouldn't compile as Flex Builder was telling me Array.ASCENDING not being a sort method, so I checked livedocs and found no mention of it there too. Any other guesses?
This should work, but I have not tested it.
public function setAlarm(_hours:int = 0, _minutes:int = 0, _seconds:int = 0):void
{
alarmQueue.push(
{
hours: _hours,
minutes: _minutes,
seconds: _seconds
});
alarmQueue.sortOn(['hours', 'minutes', 'seconds'], Array.NUMERIC);
}
Found the answer after some tinkering. The default method of sorting is ascending but there's no option to set Ascending as a secondry sorting method. So by performing two sorts, the first descending on the minutes and seconds, the second is a sortOn the hours with no parameter applied so it sorts ascending!
var alarmAsArray:Array = new Array(_hours, _minutes, _seconds);
alarmQueue.push(alarmAsArray);
alarmQueue.sortOn([1, 2]);
alarmQueue.sortOn([0], Array.DESCENDING);
if(alarmQueue.length == 3)
{
trace(alarmQueue);
}
this gives the correct output of: 12,1,19 12,1,21 1,0,31
Many thanks all!
ant