Home › Forums › Modern DFFS › async functions not working
- This topic has 5 replies, 2 voices, and was last updated 2 days, 11 hours ago by
Alexander Bautz.
-
AuthorPosts
-
-
March 28, 2025 at 20:53 #38506
Hi Alex,
I started noticing that none of the async functions in my customJs are working after I upgraded to the latest version. (1.1.4.0). I have attached a sample customJS script with comments for explanation. None of the functions marked with async doesnt even show up in the browser dev console either. These used to work with 1.0.83. More than 90% of my lists have these kind of customJS which are currently broken. Please advise. -
March 28, 2025 at 20:59 #38507
Forgot to attach the sample file.
-
March 28, 2025 at 21:00 #38508
changed sample attachement from js to txt.
Attachments:
-
March 28, 2025 at 21:56 #38510
Hi,
I have tested and I’m not able to call a function marked as async from a rule in v1.0.83.0 either.I’m not sure why you would mark the function as async in the first place – can you explain what you are trying to do?
I tested calling a synchronous function that again calls an asynchronous function and it works as expected.
I tested using this custom js:
async function asyncFn(){ console.log("Running async function..."); return "This is a message from the async function..."; } function syncFn(){ console.log("Running sync function..."); asyncFn().then(message => { console.log(message); }); }
I called the “sync” function from a rule and this is the console output:
21:56:01.431 VM92546:25 Running sync function... 21:56:01.431 VM92546:20 Running async function... 21:56:01.435 VM92546:27 this is a message from the async function...
Alexander
-
March 28, 2025 at 22:10 #38511
I have been using the async await syntax/pattern. Since i was awaiting an async function from within my main function, i marked it as async as well. My background is in C# and have very limited experience with async development in JS. If i recall correctly, I had received errors if I didnt have the parent function marked as async if its awaiting an async function inside it.
In my case, the getEmailsAndNames function loads all the required user information from an external script. Those functions are async as well. This is why i am awaiting those function calls within my getEmailsAndNames function. Sometimes, there are 10+ different user information i need to gather (mostly for rules that involve rules). Async/await pattern seemed to be cleaner and concise.
I thought i had 1.0.83 installed previously and it did work. Maybe it was an earlier version. I am not sure, but this method surely worked. I had tested this many times before implementing it on the rest of SharePoint lists.
What do you recommend I do in this case?
-
March 29, 2025 at 00:04 #38513
Can you email me the external js-file (or at least an example of a function) so that I can see the relationship between the custom js function and the one loaded in the external file?
I tried going back to v1.0.50.0, but still could not get a function in Custom JS marked as async to load from a rule, or from a call from an external file.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.