In this post let us try to put size restriction while adding new Attachments.
The Logic is pretty simple,
1. Identify the Target Attachment BC
2. Identify the File Size Field
3. Write Script on PreWriteRecord of Business Component
In any attachment applet, we can see the Fields Name, Size (in Bytes) ,Type etc.
Lets Try to write a Piece of Code to fetch the Size:
function BusComp_PreWriteRecord ()
var size= this.GetFieldValue("FileSize"); //Field that has size
var sizeMB = size/1000000 ; //converting Bytes to MB
if (ToNumber(sizeMB) >= 5 ) //checking the size to less then 5 MB
TheApplication().RaiseErrorText("Please add file less then 5 MB");
Error Popup on Save Record: