How to refresh popup attachment window

keerthilatha
Tera Expert

I have created a check box in attachment popup window as shown below(pic2). so for every attachment this checkbox will appear.

But, as soon as i attach a attachment check box is not coming next to file name. It is coming after closing the popup window and reopening again. as shown in PIC 1.

Please tell me how to refresh it.

For adding check box i have written as below,

<TD>

<g2:evaluate jelly="true">

var checkRole=gs.hasRole('ServicePortal Custom');

var tableName="${RP.getWindowProperties().get('target_table')}";

var show = 'false';

if(tableName == 'incident' &amp;&amp; checkRole)

show = 'true';

</g2:evaluate>

<j2:if test="$[show]">

<j2:set var="jvar_can_visible" value="$[sys_attachment.u_customer_visible]" />

<j2:if test="$[jvar_can_visible == 'true']">

<input   type="checkbox" checked="checked" name="chk" id="chk"   onclick="check(this,value);" value = '$[sys_attachment.file_name]'></input> &#160; <label for="chk" style='horizontal-align: text-top; padding-top: 2px;'>${gs.getMessage('Customer Visible')}</label>

</j2:if>

<j2:if test="$[jvar_can_visible == 'false']">

<input   type="checkbox" name="chk" id="chk"   onclick="check(this,value);" value = '$[sys_attachment.file_name]'></input> &#160; <label for="chk" style='horizontal-align: text-top; padding-top: 2px;'>${gs.getMessage('Customer Visible')}</label>

</j2:if>

</j2:if>

</TD>

PIC: 1

find_real_file.png

PIC 2: After closing and opening attachment popup now it is available instead that it should come as soon as file is attached

find_real_file.png

1 ACCEPTED SOLUTION

chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hi,



The Jelly script which will get execute on load of the page and here the "attachment" modal box data is coming from "attachment" ui page so generally your code should not required to refresh the page instead it should add checkbox ("Customer Visible") when any new attachment is getting add. You can use "refreshAttachments" function to bind check box.



For temporary solution of refreshing the modal box, you can add below two lines at the end of refreshAttachments() function.



jQuery('#attachment').modal('hide');


jQuery('#header_attachment_list_label').click();



Note: This is a DOM manipulation which is not suggested best practice so you should bind checkbox when new attachment is getting added.


View solution in original post

10 REPLIES 10

Hi ,




I am trying to do the same thing. with every attachment I am mapping 1 check box field from attachment table and same problem is accuring, for the first time check box with field is not coming. but if I close the box and again hit on UI action field is showing with attachment, I am using ur complete code still it is not working.


I tried with jQuery to refresh also , that too didnt work.


Could you please let me know if it was worked for you, or you have nay solution.




Thanks


Deepti