dffs vlookup,Precancel events,control of cancel list item

Forums General discussion dffs vlookup,Precancel events,control of cancel list item

This topic contains 1 reply, has 2 voices, and was last updated by  Alexander Bautz 3 months, 2 weeks ago.

  • Author
    Posts
  • #15963

    Navya Marla
    Participant

    Hi,

    i have a DFFS configured for the Newform which has some vlookup functionlaity in it.the functionlaity was working great….
    when the user clicked on cancel button in the parent New form the child items are still available in the child list as they are already saved in the child list.
    How can we delete those records in the child list if the parent item is not saved?
    can we write any client side code before the normal cancel functionality like PRESAVE for the save button?

    Thanks,
    Navya

  • #16000

    Alexander Bautz
    Keymaster

    Hi,
    There is no built in functionality in DFFS to handle this, but if this is a problem you need to address it could be done with some custom code in “Custom JS”:

    // Keep track of the item being saved or not
    var isSaved = false;
    window.onbeforeunload = function() {
        if(!isSaved){
            var items = [];
            $.each(spjs.vLookup.dataObj.vLookupTasks[getFieldValue("_vLookupID")].items,function(id,item){
                if(item.hasOwnProperty("ID")){
                    items.push(id);
                }
            });
            if(items.length > 0){
                spjs.utility.deleteItem({"listName":"ChildListTitleOrGUID","id":items});
            }
        }
    };
    
    function dffs_PreSaveAction(){
        isSaved = true;
        return true;
    }

    Please change “vLookupTasks” to match your vLookup field name and “ChildListTitleOrGUID” to match the child lists display name or GUID.

    Hope this helps,
    Alexander

You must be logged in to reply to this topic.