Home › Forums › Classic DFFS › Write DFFS Email Send Date to list field
- This topic has 9 replies, 2 voices, and was last updated 5 years ago by MikeS.
-
AuthorPosts
-
-
October 22, 2019 at 20:09 #27424
Spent some time searching through the forums and the DFFS backend but could not find the answer. I’m sending an email from DFFS and want to write the date and time sent to a field in the same list. That will allow us to calculate time spans from email send date to answer date (other list fields are updated by the email recipient).
The email is launched from a DISPLAY form button using this HTML:
<input type="button" onclick="spjs.dffs.processEmailTemplate('AssignmentEmail')" value="Send Assignment email">
So need to write a date to a field when this email is processed from a DISPLAY form.
Thanks for your help,
Mike -
October 23, 2019 at 19:01 #27449
You can use this in Custom JS:
var date = new Date().toISOString(); spjs.utility.updateItem({ "listName": _spPageContextInfo.pageListId, "id": spjs.dffs.data.thisItemID, "data": { "YOUR_DATE_FIELD_NAME": date } });
Alexander
-
October 23, 2019 at 20:39 #27455
Unfortunately, this script updates the Date field whenever the Display form is opened or refreshed. The Date field should only capture the date (time is no longer needed) corresponding to when the DFFS email was sent. It could simply capture today’s date (and then never change if the Display or Edit form is opened). I could set this script to fire in a rule perhaps . . but it still needs something that will trigger when the email was sent (button pressed to start email process).
Thanks
Mike -
October 23, 2019 at 23:15 #27457
Sorry for not giving you the full explanation. You must wrap this code in a function that you call from your button along with the call to spjs.dffs.processEmailTemplate.
Add this to your Custom JS:
function setDateFromBtn(){ var date = new Date().toISOString(); spjs.utility.updateItem({ "listName": _spPageContextInfo.pageListId, "id": spjs.dffs.data.thisItemID, "data": { "YOUR_DATE_FIELD_NAME": date } }); }
Then change your button like this:
<input type="button" onclick="spjs.dffs.processEmailTemplate('AssignmentEmail');setDateFromBtn()" value="Send Assignment email">
Alexander
-
October 24, 2019 at 02:02 #27461
Works great Alexander. Just one final request: I’d like to have the date written to the field in the format MM/DD/YYYY, without the time, e.g., 10/23/2019.
Thanks
Mike -
October 24, 2019 at 19:16 #27468
I misunderstood and thought you wanted to write the date to a date field and not a plain text field.
Change this line:
var date = new Date().toISOString();
like this:
var date = new Date().toLocaleDateString();
Alexander
-
October 24, 2019 at 22:10 #27476
Works great Alexander. Having the option to write to either a text field or a date field will come in handy.
Thank you.
Mike -
November 5, 2019 at 20:00 #27599
Alex,
How can I ensure the above date variables return a chosen time zone, e.g., “America/Chicago” or GMT-5?
I have a similar question related to using the timestamp variable in a Tab rule for ‘Set field value.’ Currently {timestamp[MM/dd/yyyy]} returns the UTC date. I would like to return a chosen time zone, e.g., “America/Chicago” for this field as well.
Thanks,
Mike -
November 6, 2019 at 19:54 #27620
If you write the date to a date and time field as ISO8601 format (YYYY-MM-DD hh:mm:ss) SharePoint should show it correctly. You can also get the date representation for a specific timezone by using this approach, but it will not work in IE:
new Date().toLocaleString("en-US", {"timeZone": "America/Chicago", "timeZoneName": "long"})
Alexander
-
November 13, 2019 at 18:38 #27648
Thanks Alex. This is working for custom JS.
Mike
-
-
AuthorPosts
- You must be logged in to reply to this topic.