getFullYear() is not a function - angular7

I am developing web app by using Angular. When I upgrade my app to Angular7, Date function is not working. It gave me error such as
DateTime.getFullYear is not a function
It was ok before I upgraded to Angular7. In package.json:
"typescript": "^3.1.1", "#angular/cli": "~7.0.2",
"#angular/complier-cli": "~7.0.0".
What is going on?

Remember next time you post a question to paste the code relating to your error so that someone can have a look at it, since the same error can result from different code.
After upgrading my ng6 app to ng7 my DateTime.getFullYear worked fine, until I changed something about it, and it suddenly gave the same error. Everything seemed fine.
Checking my date object like below returned an object just the way it should
dateFunction(longdate) {
console.log(typeof(longDate)) // This returned 'object' which is correct
longDate.getFullYear() // Would get the same error here
}
So I tried passing in a fresh date object into the function, and not one being send via parameter like this:
dateFunction() {
longDate = new Date();
console.log(typeof(longDate)); // This returned 'object' which is correct
longDate.getFullYear(); // This worked fine now
}
And this would work fine, so I realized it is not my getFullYear() function that is wrong, but my parameter that is corrupt.
But here is the strange part, so I went to the parent component and did the same thing there - I deleted the old code and made a fresh longDate = new Date() and send it through to my function, and suddenly it was working. The exact same code, but I just re-wrote it.
Try creating a fresh date just before your function, pass it in and see if it works. If it works then it is not your function but the old date variable that is corrupt.
PS: I just feel that I have to say that you must use the new keyword (see examples above) when creating your initial date variable, or it will also throw the error...

Related

#FirestoreQuery Not returning list of documents in Collection

I'm using FirebaseFirestoreSwift and Swift5.5 on iOS15+
I have this query:
#FirestoreQuery(
collectionPath: "/Users/" + Auth.auth().currentUser!.uid + "/Pages/"
) var pages2: [PageItem]
And I'm trying to get the following:
The structure is: /Users/{userId}/Pages/{pageId}/{key/value pairs}
I even confirmed from Firestore that the path was matching with its own.
This is from the console: /Users/JuzWOzAf54a7oFlOlb09dhAuOjI3/Pages/LZQAmbb18tYtz8ypkd8p
and this is what my string concatenation produces: /Users/JuzWOzAf54a7oFlOlb09dhAuOjI3/Pages/
So I should be getting the Page LZQAmbb18tYtz8ypkd8p and 3 others in the response, but thus far it is empty. Am I checking too early?
I am printing it like so:
.onAppear {
print(pages2)
}
On a view in the same file.
I don't even think it's a problem with printing it too soon, since it's meant to update in real-time.
But just incase it never showed since it was onAppear,and could have been received after, I added the following:
List {
ForEach(pages2) { page2 in
Text(page2.name)
}
}
And still, it receives nothing.
Not really sure what I'm doing wrong, I've researched and all I can find is a few resources, but they all seem to be doing the same thing, however, mine is simply not working, or I might be confused.
Any help is greatly appreciated, thank you!
Edit
This is the official SDK file whose methods I'm using:
https://github.com/firebase/firebase-ios-sdk/blob/master/Firestore%2FSwift%2FSource%2FPropertyWrapper%2FFirestoreQuery.swift
I am doing exactly as they propose.

ng-block-ui not working with Angular 7 concatmap

I'm using NgBlockUI and BlockUIHttpModule with blockAllRequestsInProgress set to true in an app I'm working on. In general it's working fine, but on one page I'm using a concat map to perform some action and then update the data. The first request, the update, triggers BlockUI fine, but the second one doesn't. Otherwise, it executes properly. It's just a little jarring for the user since the results seem to update without warning. Here's the code for the function:
onUpdate(event: items[]) {
this.updateService.update(event).concatMap(
_ => this.seachService.search(this.cachedSearch)
).subscribe(
resp => this.handleResponse(resp),
err => this.handleError(err)
);
}
I tried calling BlockUI directly, but still no luck. As a last resort, I'm going to make the whole thing one request, but I'd like to at least understand why this isn't working.
This happened to me as well. This issue occurs for sequential HTTP calls (usually with await) wherein the second request is not blocked by ng-block-ui.
As fix what I did was set blockAllRequestsInProgress to false. The behavior is just the same but setting it to false yields more predictable results:
BlockUIHttpModule.forRoot({
blockAllRequestsInProgress: false,
requestFilters: [urlFilter]
}),
I've also updated to ng-block-ui to latest version as of this writing:
"ng-block-ui": "^2.1.8",

Konvajs - findone() function behaviour has changed between 2.0.2 and 2.4.2

I have a piece of code that worked just fine with Konvajs.2.0.2.
var startCity = mainStage.findOne('#0');
It would return the node with the ID=0. Works like a charm in the 2.0.2 version.
But know when I udpate to 2.4.2, this does not find the node anymore and returns a JS error (object undefined). It works for any other IDs on the map (2,3,4,etc).
I checked and printed all the node and there is definitely one with ID=0;
Any information or clue on what could have changed in the find() or findone() function between those 2 releases? Is it something like you cannot have an ID=0 anymore maybe?
Thank you.
The behavior was slightly changed.
Now id cannot have values that == null (like empty string or 0).
To fix the issue you can convert number 0 to string "0". Or use another id.

Event Handler later than OnPublished

Are there any Project Server event handler events later than the "OnPublished"-event when creating a new project?
The time when the on published event occurs seems to be to early. Loading the project FieldValues does not work. They are always null.
PublishedProject project = projCollection.First().IncludeCustomFields;
projectContext.Load(project);
projectContext.Load(project.IncludeCustomFields);
CustomFieldCollection fields = project.CustomFields;
projectContext.Load(fields);
projectContext.ExecuteQuery();
Dictionary<string, object> fieldValues = project.FieldValues;
When executing the same code for an existing project everything works fine.
Instead I could do a timeout for x seconds but I would prefer a later server event where all values have already been set.
Edit:
Seems there was something wrong with my other code before executing this. Custom Fields and FieldValues are loading correctly now.
But loading the projectSiteUrl afterwards is still to early at this point. The ProjectSiteUrl stays null.
projectContext.Load(project, p => p.ProjectSiteUrl);
projectContext.ExecuteQuery();
Once a project is completely published, OnProjectChangedRemote event of ReportingEventReceiver Class gets fired.
When a new project is created and the creation process completes, OnProjectCreatedRemote event of ReportingEventReceiver Class gets fired.
I used PSI not CSOM and "ProjectSiteUrl" is null after first publish(OnPublished event).
For first publish I used OnWssWorkspaceCreated event which is in WssInteropEventReceiver class or interface.

Box::info showing "refreshEx"

I have a method that displays a validation result using the syntax
Box::info(message,title);
However, the first time I run the code it displays the correct title, but the message refreshEx.
Debugging the code the message that is being used is correct, Valid Account Number, but what displays is refreshEx. If I rerun the process the correct message is displayed, this only happens the first time.
Just in case it matters the flow is
Form - DoValidation method creates Class to call...
Class - public AccountValidation method that calls...
- private displayValidation method that contains this code
Thanks...
I have seen this error (unfortunately), in an AX 2009 installation, launched from code behind a button in a form:
if(HIEItemOrderSetup.RMAvailable < HIEItemOrderSetup.RMQuantity)
{
ok = DialogButton::Ok == box::okCancel("#HIE848",DialogButton::Ok,"#HIE849");
}
As far as I can tell it only occurs when you have a breakpoint on your form, when you are updating it. Removing the breakpoint will show the original message or at least this is what I have found.
If the message contains some fields from the database, try to execute a reread() or refresh() or refreshEx() method (depending on the context) to the datasource before showing the value through the info box.
May be the cached data is not refreshed after an update or insert.
EDIT:
If you are specting a return parameter from an Event, don't forget that this is an async process. An example on MSDN:
http://msdn.microsoft.com/en-us/library/gg843664.aspx

Resources