Monday, May 4, 2015

DFFS: Check out list items

This post will describe a possible solution to handle check out of list items when editing. This will prevent others from making changes to the list item while anoother person has the same item already open in EditForm.

This solution is intended used in EditForm, and requires you to add one new field to the list: A yes/no column named (for example) “CheckedOut”.

Currently this requires four rules added to DFFS, but I might consider building in support for this so that this would just require a “tick in a box” to enable.

These are the rules required in DFFS


IMG


IMG


IMG

Please note that you must have DFFS frontend v4.267 or later to be able to “alert” the name of the Editor like in this example.


IMG

And here is the custom code in the CSS and JS

IMG

Code in plain text
function goToDispForm(){
        $("#part1").hide();
        location.href = location.href.replace(/editform.aspx/i,"DispForm.aspx");
}

function mustCheckOut(){
        if(confirm("You must check out this item to proceed.\n\nCheck out this item now?")){
                var res = spjs_updateItem({"listName":_spPageContextInfo.pageListId,"id":GetUrlKeyValue("ID"),"data":{"CheckedOut":"1"}});
                if(res.success){
                        location.href = location.href;
                }else{
                        alert(res.errorText);
                }
        }else{
                goToDispForm();
        }
}

function promptCheckIn(){
        if(getFieldValue("CheckedOut") === true){
                if(confirm("Do you want to check in this item to allow otheres to contribute?")){
                        setFieldValue("CheckedOut",false);
                }
        }
}

Please use the forum for any discussions

Alexander


by Alexander Bautz via SharePoint JavaScripts

No comments:

Post a Comment