Upload Profile Photo In User Table

Gowthami Senthi
Kilo Expert

Hi All,

Whenever the photo has been uploaded in user record, I want to validate whether the uploaded image size is more than 200 KB. If its more than 200 KB we need to show an alert message saying "Max attach size is 200 KB". I want to display this message in the page which will appear while clicking the "Click to add.."" in User record.

Kindly let me know the possible ways to achieve this.

Thanks in advance

8 REPLIES 8

Slava Savitsky
Giga Sage

The photo is saved in sys_attachment table like normal attachments. Table name field is set to "ZZ_YYsys_user" and Table sys ID is the sys_id of the User record. There is also a column called Size bytes that indicates the size of the uploaded image. You can create a business rule for sys_attachment table to abort the upload of larger images and/or display a message to the user.


I assumed you meant the Photo field in the User record. Or did you actually mean the Live Feed avatar?


Hi Slava,



Thanks for your response. I meant the photo field in User table.



I have also tried the same script which you mentioned in sys_attachment table. But I am not able to popup an error message in the UI page where we can upload the image. Also I need to show a message in that page with Attachment size limit information.


I set up the following business rule in my developer instance and it seemed to do work just fine. Displaying the message on the same screen is not going to work because upon uploading the image the user is automatically taken back to the previous page. So the error message will be displayed at the top of the User record instead.



Business Rule details:


=============================


Table: Attachment [sys_attachment]


Active: true


Advanced: true


When: before


Insert: true



Filter Condition:


  Table name = ZZ_YYsys_user


  File name = photo



Script:


      var limit_kb = '200';


      if (current.size_bytes > limit_kb * 1024) {


              gs.addErrorMessage('Image size exceeds the limit of ' + limit_kb + ' KB. Try a different one.');


              current.setAbortAction();


      }


=============================