- This topic has 5 replies, 2 voices, and was last updated 3 days ago by Alexander Bautz.
-
AuthorPosts
-
-
February 7, 2025 at 15:46 #38425
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”)); -
February 7, 2025 at 17:12 #38426
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
-
February 7, 2025 at 17:15 #38427
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;
-
February 7, 2025 at 17:21 #38428
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(); -
February 7, 2025 at 18:10 #38429
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
-
February 7, 2025 at 19:05 #38430
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
-
-
AuthorPosts
- You must be logged in to reply to this topic.