Stop saving using dffs_PreSaveAction

Home Forums Modern DFFS Stop saving using dffs_PreSaveAction

Viewing 4 reply threads
  • Author
    Posts
    • #38376
      Amal Vellappillil
      Participant

        Hi Alex,

        I have a requirement in which i need to create a new record in a different list (lets call it LIST-B) from LIST-A. My current rule setup is as follows in LIST-A:
        Rule-A
        Trigger based on field change. Checks if a particular field is “Yes” and is changed from initial value. If true, then the action is to prepare an email and then call a function that flags a variable (VARIABLE-A) to true.

        In my dffs_PreSaveAction, i am checking if VARIABLE-A == true and if it is then call a function to create the new record in LIST-B with some data from LIST-A. This function is an async function. So i am using the .then().catch() pattern. Depending on the response from the record creating function, i am either returning true, or false (to stop saving). However, no matter what I do inside the then() or catch(), I am not able to stop the form from saving. I am guessing this is due to the new record creating function is async. If that is the case, what are my options to achieve my requirements?

        My new record creation function also sets a global variable (newRecordUrl). This is the url of the newly created record. Will setting the variable here work, if the “prepare email” action is using the [[variable:newRecordUrl]] in Rule-A? If this is not possible, what are my options for such requirements?

        Greatly appreciate all your help.
        Thank you!

      • #38378
        Alexander Bautz
        Keymaster

          Hi,
          Can you attach the relevant code as a txt-file? – please ensure you strip away any sensitive information.

          Alexander

        • #38379
          Amal Vellappillil
          Participant

            I have attached a word document. Hopefully this helps.

          • #38381
            Alexander Bautz
            Keymaster

              Try it something like the attached code. I have butchered your code a bit so you must edit it to match what you wanted to do after the child list item has been created. See comments in the code and let me know if you have any questions.

              Alexander

            • #38387
              Amal Vellappillil
              Participant

                Hi Alex,

                This worked great. Instead of preparing the email during a rule, i had to create another rule that prepares the email. This rule had to be triggered from custom javascript. I called this rule after child item was created successfully. This way, the email had the newRecordLink variable populated and available.

                Thank you so much for your help.

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