Hello All,
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 () { this.ActivateField("FileSize"); 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:
and I thought that RaiseErrorText was banned from scripting 😅...
ReplyDeletewe have implemented this approach with Data Validation. For example for BC."Action Attachment", we added the conditinal expression "[ActivityFileSize] > 8388608", and under RUle Detail this Expression "[ActivityFileSize] <= 8388608". if conditions match then we raised this error "This file cannot be uploaded to Siebel. It exceeds the allowed size of 8MB." (Please verify the maximum file size that is allowed)". The Rule is calling later from Runtime Events.
ReplyDelete🤚, Jose Luis