Without editing item getting unsaved changes warning


When I open an item of the Custom item type from the search grid and attempt to close it without editing the item, Aras displays an unsaved changes warning.

On that custom item, a file is attached as a relationship. We create a file using the following code:

let newFileItem = top.aras.newItem("File", FileElement);
let itmResult = top.aras.applyItemWithFilesCheck(newFileItem, '', '', '');
let fileId = itmResult.getAttribute("id");

After creating the file, we add a relationship between the custom ItemType and the file:

Item fileUpload = dal.NewItem("Custom_File", "add");
fileUpload.setProperty("source_id", custom_id);
fileUpload.setProperty("related_id", fileId);
fileUpload = fileUpload.Apply();

Is this the correct approach for attaching files to a Custom ItemType?
how to tackle this issue?



  • Hi Suhas,

    Which Innovator version do you use? Innovator 12 or 14? Your code looks like Innovator 10, which maybe can cause the issue you see :)

    1. Remove the top references! 
    2. Where did you find applyItemWithFilesCheck? It´s in the code tree yes, but I never have seen code that use the function itself directly.
    3. Which event triggers the upload of the file?

    4.  How to add restrictions to aras.vault.selectFile() file picker 


  • Hello  

    Thanks for your quick reply. Instead of applyItemWithFilesCheck API now I'm using top.aras.saveItemEx API in javascript & now it is working fine. But for saveItemEx  API again I need to call UnlockItem API. is there any alternate for saveItemEx to avoid to call UnlockItem api?



  • Don´t use top.aras.saveItemEx but aras.saveItemEx! As mentioned before, don´t use the top references anymore if you don´t use Innovator 10. Aras it self try to remove them whenever possible.

    But I think in your case saveItemEx is maybe not the best solution. I typically use this one, when the item is already in edit mode. It´s a perfect function to edit something, while the user is editing anyway. 

    If you want to use it for some kind of "background" edit action, you will need to unlock manually. 

    Have you checked the linked filepicker post? Ignore the title of the thread. But the whole post contains a couple of variants for file upload for Innovator 11/12 and 14. Scroll down and look at the sample code from Gopi and Chris.