Notes Remove Button- If accidentally click on the remove button the note get deleted

Hi there

In Notes Module when I click on the remove button the note is deleted can anyone help me with these 2 possibilities

  1. If I click remove(Button) and cancel the edit view(Form) page the note should not remove
    if I click on remove(Button) and save the edit view(Form) page then the note can remove
  2. When the user clicks on the Remove button should ask confirmation.
    like are you sure want to delete notes if yes delete if no can stay in the same page

Possibility 1 is my need if it’s not possible help me with possibility second
Thank you

Help Me Please with these

@praveenkumar
I solved this question to adding accept flag before delete file. It works for all fields which type is “file”.
Edit file: “include/SugarFields/Fields/File/EditView.tpl” and change:

  • before:
{if !$noChange}
<input type='button' class='button' id='remove_button' value='{$APP.LBL_REMOVE}' onclick='SUGAR.field.file.deleteAttachment("{{$idName}}","{{$vardef.docType}}",this);'>
{/if}
  • after
{if !$noChange}
<input name="file_remove_checked" type="hidden" value="0">
<input type='button' style="display: none;" class='button' id='remove_button' value='{$APP.LBL_REMOVE}' onclick='SUGAR.field.file.deleteAttachment("{{$idName}}","{{$vardef.docType}}",this);'>
<input type='button' style="display: inline;" disabled="" class='button' id='remove_readonly_button' value='{$APP.LBL_REMOVE}' onclick='none;'>
<input name="file_remove_checked" id="file_remove_checked" onclick="checkRemove(this,'remove');" type="checkbox" class="checkbox" value="1"> {$APP.LBL_REMOVE_ACCEPT}
         <script type="text/javascript">
            {literal} 
			function checkRemove(el,field){
				if(el.checked){
					document.getElementById(field + "_button").style.display = "inline";
                                        document.getElementById(field + "_readonly_button").style.display = "none";
				}else{
					document.getElementById(field + "_button").style.display = "none";
                                        document.getElementById(field + "_readonly_button").style.display = "inline";
				}
			}
		{/literal}
         </script>
{/if}