Forum Replies Created
-
AuthorPosts
-
Alexander Bautz
KeymasterYou can use something like this:
var today = new Date(); var datePlusOffset = null; var offset = 6; // The offset number of business days var ticker = 0; while(ticker < offset){ datePlusOffset = new Date(today.setDate(today.getDate() + 1)); let day = datePlusOffset.getDay(); if(day !== 6 && day !== 0){ ticker += 1; } } spjs.utility.setDateFieldFromDateObject("DateColumn1", datePlusOffset);
Alexander
Alexander Bautz
KeymasterIf the field starts with underscore you must prefix it with OData_ like this:
OData__DFFSID OData__vLookupProjectID
Alexander
Alexander Bautz
KeymasterNo problem, use something like this
var today = new Date(); var datePlus6 = new Date(today.setDate(today.getDate() + 6)); spjs.utility.setDateFieldFromDateObject("Your_date_column_fin", datePlus6);
Alexander
Alexander Bautz
KeymasterI referred to jQuery as the jQuery JavaScript library and not jQuery.SPServices so your setup should be OK.
I guess that the $ namespace (alias for jQuery) used in the SPServices library for some reason is not populated when jQuery is loaded. I have seen that SharePoint or other third party code uses the same namespace.
You can try adding something like this in the top of your Custom JS to fix it:
$ = jQuery;
I still recommend using the built in spjs.utility functionality linked in my previous answer instead of SPServices.Alexander
Alexander Bautz
KeymasterI forgot to mention that jQuery is automatically loaded with DFFS so you must not load it again – that can cause problems.
Alexander
Alexander Bautz
KeymasterHi,
SPServices is not part of DFFS. If you want to use it you must load it in the textarea above Custom JS.You don’t need to use it either as DFFS has built in support for getting list items – see this thread for example code: https://spjsblog.com/forums/topic/query-update-delete-an-item-in-javascript/
Alexander
Alexander Bautz
KeymasterThanks for the detailed description – I’ll get this fixed in a new version over the weekend or early next week.
Alexander
July 23, 2024 at 10:42 in reply to: Question about modern DFFS and Lookup column functionality #37820Alexander Bautz
KeymasterThanks for the detailed descriptions – I’ll get this fixed in the next version.
Alexander
Alexander Bautz
KeymasterUsing a SP2013 workflow should not be a problem, but I don’t have any examples on the setup. You can find some general information here: https://support.microsoft.com/en-us/office/send-email-in-a-workflow-11d5f9dd-955f-412c-b70f-cde4214204f4
You should be able to find the same type of actions in SP2013 WF as in SP2010 WF to replicate the steps see in the user manual here: https://spjsblog.com/dffs/dffs-user-manual/#Set_up_the_workflow
Alexander
Alexander Bautz
KeymasterIt is not possible to send it after the form is saved because the classic DFFS is using the built-in save function in SharePoint and you are automatically redirected away from the form when the save completes – effectively cutting off any ongoing custom code you have running.
You can modify it like this to send the email – and if it is successfully sent, the form is saved.
function sendCustomEmail(arg){ spjs.dffs.alert({ "title": "Enter a return reason", "msg": "<textarea style='width:100%;box-sizing:border-box;height;75px;' id='varFromAlertInput_input'></textarea>", "ok": function(){ var fromAlertInput = jQuery("#varFromAlertInput_input").val(); spjs.dffs.REST_Email({ "to": arg.to, "cc": arg.cc, "bcc": arg.bcc, "subject": arg.subject, "body": arg.body.split("{0}").join(fromAlertInput) }).done(function(success){ if(success){ spjs.dffs.triggerSave(); } }).fail(function(err){ alert("Sending failed with this error: " + err.responseJSON.error.message.value); }); }, "cancel": function(){ // Close dialog } }); } sendCustomEmail({ "to": ["alexander@spjsblog.com"], "cc": [], "bcc": [], "subject": "The subject of the email", "body": "The default body - the variable from the input will be inserted by replacing this token: {0}" });
Alexander Bautz
KeymasterI fixed a missing quote in the code snippet above. You can wrap it in a function something like this to use it from different other functions:
function sendCustomEmail(arg){ spjs.dffs.alert({ "title": "Enter a return reason", "msg": "<textarea style='width:100%;box-sizing:border-box;height;75px;' id='varFromAlertInput_input'></textarea>", "ok": function(){ var fromAlertInput = jQuery("#varFromAlertInput_input").val(); spjs.dffs.REST_Email({ "to": arg.to, "cc": arg.cc, "bcc": arg.bcc, "subject": arg.subject, "body": arg.body.split("{0}").join(fromAlertInput) }); }, "cancel": function(){ // Close dialog } }); } // Call the function like this sendCustomEmail({ "to": ["alexander@spjsblog.com"], "cc": [], "bcc": [], "subject": "The subject of the email", "body": "The default body - the variable from the input will be inserted by replacing this token: {0}" });
Alexander
Alexander Bautz
KeymasterTry it like this:
spjs.dffs.alert({ "title": "Enter a return reason", "msg": "<textarea style='width:100%;box-sizing:border-box;height;75px;' id='varFromAlertInput_input'></textarea>", "ok": function(){ var fromAlertInput = jQuery("#varFromAlertInput_input").val(); spjs.dffs.REST_Email({ "to": ["user@sdomain.com"], "cc": [], "bcc": [], "subject": "This is a test email", "body": "This is the message: " + fromAlertInput }); }, "cancel": function(){ // Close dialog } });
Please note that this uses the built in SharePoint REST API to send the message and the recipient(s) must be members of the site.
Alexander
-
This reply was modified 1 month, 2 weeks ago by
Alexander Bautz. Reason: Fixed missing double quote
Alexander Bautz
KeymasterI’m glad you figure it out.
Alexander
Alexander Bautz
KeymasterAh, now I understand. You must remove this function and use the setting in the Misc tab named “Multiple-choice columns (checkboxes and radio buttons) in multiple columns”.
Alexander
Alexander Bautz
KeymasterYou basically just remove the contents of the /SPJS/DFFS folder and upload the contents of the zip-file you downloaded.
If your old installation was done using the “version 1 installer” you should update to V2 and then use the installer to uninstall and then reinstall DFFS to the forms.
The uninstall / reinstall will not affect your configurations – they are stored in a separate list in your site and will pop back when you reinstall.
Follow the instructions in the installation manual here: https://spjsblog.com/dffs/dffs-installation-manual/#Upgrading_from_a_previous_version
Alexander
-
This reply was modified 1 month, 2 weeks ago by
-
AuthorPosts