Alexander Bautz

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 4,590 total)
  • Author
    Posts
  • Alexander Bautz
    Keymaster

    You 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

    in reply to: Vlookup filter not working #37840
    Alexander Bautz
    Keymaster

    If the field starts with underscore you must prefix it with OData_ like this:

    OData__DFFSID
    OData__vLookupProjectID
    

    Alexander

    Alexander Bautz
    Keymaster

    No 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

    in reply to: $().SPServices() is not a function. #37836
    Alexander Bautz
    Keymaster

    I 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

    in reply to: $().SPServices() is not a function. #37830
    Alexander Bautz
    Keymaster

    I forgot to mention that jQuery is automatically loaded with DFFS so you must not load it again – that can cause problems.

    Alexander

    in reply to: $().SPServices() is not a function. #37829
    Alexander Bautz
    Keymaster

    Hi,
    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

    in reply to: Trouble with field and current user email matching #37827
    Alexander Bautz
    Keymaster

    Thanks for the detailed description – I’ll get this fixed in a new version over the weekend or early next week.

    Alexander

    Alexander Bautz
    Keymaster

    Thanks for the detailed descriptions – I’ll get this fixed in the next version.

    Alexander

    in reply to: DFFS Email Alert #37796
    Alexander Bautz
    Keymaster

    Using 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

    in reply to: Get user input prior to sending email #37789
    Alexander Bautz
    Keymaster

    It 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}"
    });
    
    in reply to: Get user input prior to sending email #37782
    Alexander Bautz
    Keymaster

    I 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

    in reply to: Get user input prior to sending email #37778
    Alexander Bautz
    Keymaster

    Try 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
    in reply to: Easy way to make all fields readonly? #37771
    Alexander Bautz
    Keymaster

    I’m glad you figure it out.

    Alexander

    in reply to: Easy way to make all fields readonly? #37761
    Alexander Bautz
    Keymaster

    Ah, 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

    in reply to: Easy way to make all fields readonly? #37757
    Alexander Bautz
    Keymaster

    You 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

Viewing 15 posts - 1 through 15 (of 4,590 total)