async functions not working

Home Forums Modern DFFS async functions not working

Viewing 5 reply threads
  • Author
    Posts
    • #38506
      Amal Vellappillil
      Participant

        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.

      • #38507
        Amal Vellappillil
        Participant

          Forgot to attach the sample file.

        • #38508
          Amal Vellappillil
          Participant

            changed sample attachement from js to txt.

            Attachments:
          • #38510
            Alexander Bautz
            Keymaster

              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

            • #38511
              Amal Vellappillil
              Participant

                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?

              • #38513
                Alexander Bautz
                Keymaster

                  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

              Viewing 5 reply threads
              • You must be logged in to reply to this topic.