Delay in Save

Home Forums Requests Delay in Save

Viewing 5 reply threads
  • Author
    Posts
    • #38425
      Rad
      Participant

        Hi Alex, I’ve a simple 3 line code t save and send an email out to users but the the save doesn’t seem to work always. The request status sometimes gets set and sometimes not. I tried adding a timer for save but that does work also. Any suggestions here?

        case “btnSubmit”:
        setFieldValue(“txtRequestStatus”,”Submitted”);
        $(“input[id$=diidIOSaveItem]:last”).click();
        sendEmail(getFieldValue(“txtRequestStatus”));

      • #38426
        Alexander Bautz
        Keymaster

          Hi,
          You must not run this line:

          $(“input[id$=diidIOSaveItem]:last”).click();

          until after your custom sendMail is completed to ensure the form is not closed before your email is sent.

          I don´t see any reason the txtRequestStatus field would not be set though – are you sure it is not overwritten by for example a FLOW? – do you see the value in the version log of the list item?

          Alexander

        • #38427
          Rad
          Participant

            it seemed like there was a delay in setFieldValue(“txtRequestStatus”,”Submitted”);, so added timer to excute Save after 2 sec. Have you seen this issue with delay in setting a variable?

            case “btnSubmit”:
            setFieldValue(“txtRequestStatus”,”Submitted”);

            //$(“input[id$=diidIOSaveItem]:last”).click();

            setTimeout(function() {

            // alert(“here”);
            $(“input[id$=diidIOSaveItem]:last”).click();

            if(getFieldValue(“txtRequestStatus”) == “Submitted”){
            sendEmail(getFieldValue(“txtRequestStatus”));
            };
            }, 2000);

            break;

          • #38428
            Rad
            Participant

              so, the order should be like below? First send email then save? I that the reason?

              setFieldValue(“txtRequestStatus”,”Submitted”);
              sendEmail(getFieldValue(“txtRequestStatus”));
              $(“input[id$=diidIOSaveItem]:last”).click();

            • #38429
              Rad
              Participant

                I looked into the versioning and it doesn’t show any value change for this field. Hope adding a timer would help. It seems to work so far. this is the updated code.

                case “btnSubmit”:
                setFieldValue(“txtRequestStatus”,”Submitted”);
                sendEmail(getFieldValue(“txtRequestStatus”));

                // $(“input[id$=diidIOSaveItem]:last”).click();

                setTimeout(function() {

                // alert(“here”);
                $(“input[id$=diidIOSaveItem]:last”).click();

                }, 2000); //2 second

              • #38430
                Alexander Bautz
                Keymaster

                  The only field types that have a delay when setting are lookup and people picker fields, but from the name of the field I assume this is a single line of text?

                  Alexander

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