Reload a form right after attaching files

Koji Yanase
Tera Contributor

Can we reload a form automatically right after attaching files? I wrote a business rule which count up attachments and show the number in the form. But we need to refresh the form to display the new number. So it should be reloaded automatically right after attaching files.

Thanks.

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

Hi Koji, why don't you do this through a client script?



You can use the client function getCurrentAttachmentNumber(sys_id_of_your_record) to get the Attachment Number for your record.



This function just looks-up into the field which holds the attachmentNumber for that record. Here goes how internally ServiceNow has defined this function:



function getCurrentAttachmentNumber(sysid) {


if ($$('.attachmentNumber_' + sysid)[0] == undefined) {


if ($('header_attachment_list_label') == undefined)


return undefined;


else


return $('header_attachment_list_label').down().innerHTML;


}



Clarification: This function is already defined and available in your client code.



Thanks,


Berny


View solution in original post

12 REPLIES 12

Hi Berny,


I appreciate your answer! I could resolved my situation.


Thanks & Regards,


Koji


What kind of client script? 

Hello @bernyalvarado 

 

I know this is an ancient post, but I don't understand what type of client script it should be in order to close the attachment pop up and reload the form.

I've tried the code with an onSubmit but nothing happens.

 

Am I missing something?