Attachment mandatory script in UI policy.

Balaji3
Kilo Contributor

Hi Techies,

I need help on coding part.....

i need script for attachment mandatory through UI Policy for my custom application when user raise a ticket for servicenow Quebec release.

Thanks in advance.....!

Regards,

Balaji

 

29 REPLIES 29

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello 

Please go through below article 

https://community.servicenow.com/community?id=community_article&sys_id=0f0c5290dbe7f380d82ffb24399619f5

Please mark correct/helpful if you get expected solution 

Thanks 

Chetan,

Is it possible through UI Policy?

I don't think UI Policy would be best approach

but you can achieve this by business rule (Before Insert)

(function executeRule(current, previous /*null when async*/) {

  if(current.hasAttachments()){            

            current.setValue("u_has_attachment","true");

              gs.addInfoMessage("Attachment Present");

            }

   else if(!current.hasAttachments()) {

              current.setValue("u_has_attachment","false");

              gs.addInfoMessage("Attachment Absent");

             }

}

Kindly Mark Correct/Helpful if you get expected response

Thanks

I don't think UI Policy would be best approach

but you can achieve this by business rule (Before Insert)

(function executeRule(current, previous /*null when async*/) {

  if(current.hasAttachments()){            

            current.setValue("u_has_attachment","true");

              gs.addInfoMessage("Attachment Present");

            }

   else if(!current.hasAttachments()) {

                gs.addInfoMessage("Attachment Absent");

                current.setAbortAction(true);

             }

}

So, If user attached Attachment then only record will get insert otherwise will abort action 

Kindly Mark Correct/Helpful if you get expected response

Thanks