The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Executing a client script when attachment is added to incident table

JJ1
Kilo Guru

I have a requirement to set certain field values when an incident is saved with an attachment file of specific file name.I wrote   on submit client script which uses a script include   to query sys_attachment and return the values based on requirement.This works fine ,no issues faced.But I recently noticed that adding an attachment to incident doesn't need a save on incident which will not execute my on submit client script and thus it will not set the fields.Is it possible to make this on submit client script execute when an attachment is added to the incident form or make save action mandatory after adding the attachment?

6 REPLIES 6

bernyalvarado
Mega Sage

Hi Jeevan,



I believe that the best approach for this is using business rules. On your first and current scenario, you can use and on before insert / update business rule on the incident table to set the field. This way your logic would always work, even for server side scenarios like REST integration, inbound actions, workflows, etc...



As for your second scenario, you can also have a business rule, this time on the sys_attachment table and make an onAfter one.



I hope this helps!



Thanks,


Berny


I had thought about it earlier,but somehow I started with CS and script include and thought may be it is better to execute the same CS if is possible.I will try your approach and let you know.So is there no other way to call or execute a CS when we add attachment ?   There are some UI pages related to attachment ,I wonder if it can be edited.Just a thought.


Jeevan,



Were you able to resolve this using GlideAJAX?


Well, I didn't work on it .The requirement went on hold.I am considering to change it to a BR than using CS and Ajax.