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

keerthilatha
Tera Expert

ANy idea on this


If you are updating the "attachment" UI Page, I think you will need to look at the client script section of the UI page, and ensure you create your new field dynamically. Have a look at the function called "refreshAttachments". In there, I think you will need to create your checkbox. Also, I presume you will be wiring that field up so that it acually saves something in the backend as well (sys_Attachment table)?


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.


Thank you very much.. though it is DOM manipulation we will consider this solution as it is working fine as expected



🙂 Thanks a lot