Upload Profile Photo In User Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2016 06:09 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 11:08 PM
Hi Slava,
Thankyou so much for your reply.....
I have tried the same which you mentioned above but even after displaying the message the photo is getting updated in the profile. My requirement is to restrict the image upload which is more than 200KB and the old photo should remain in the profile after the error message populated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2016 11:54 PM
Hi Aj
Above business rule looks good.
Please use this code: current.setAbortAction(true) in above BR to abort the action.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 12:14 AM
Hi,
Please change the script as below:
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(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2016 02:45 AM
Hi,
When I give current.setAbortAction(); expected error message appearing and its redirecting to User table but image is got updated.
When I give current.setAbortAction(true); error message didn't appear and its redirected to User table and image got updated.
Below script is working like abort action is happening but previous image got deleted from User table. I need to abort the action but previous record should remain in user profile.
=============================
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();
gs.setRedirect('/user_image.do?sysparm_sys_id='+current.table_sys_id;
}
=============================
Here I have a doubt that we are aborting the action before inserting the record itself then how ll be the previous record is getting deleted?