Gowthami Senthi
Kilo Expert

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?