How to hide attachment icon in portal when the ticket is in closed state

sangz
Kilo Contributor

Hi,

I have one requirement in which I need to hide the attachment icon from portal when the ticket is in closed complete/ closed cancelled/ Review state.

I tried client script but that is working in native UI not in portal.

Please help to complete this requirement

Thanks

 

16 REPLIES 16

@sangz 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@sangz 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi! 

I tried this solution, this does not work for me. Can you help? What can I be doing wrong?

Regards

Richa

Mike Grimm
Tera Contributor

Not sure what release everyone is running on, but I had a similar requirement and found a quick fix. You will need to clone both the Ticket Attachments and Ticket Conversations widgets.

For the Ticket Conversations widget, you need only to modify line 134 of the Server script:

function userCanAttach(originalRecord) { //133
        if (!gs.hasRole(gs.getProperty("glide.attachment.role")) || (originalRecord.active == false)) //134
            return false; //135

 

For the Ticket Attachments widget, you'll need to add the following to line 31 of the Server script:

data.canWrite = gr.canWrite(); //line 29
data.canAttach = gs.hasRole(gs.getProperty("glide.attachment.role")) && GlideTableDescriptor.get(data.table).getED().getAttribute("no_attachment") != "true"; //line 30
data.recordIsActive = gr.active == true; //line 31 - Add this line
data.canRead = gr.canRead(); //line 32

And modify line 6 of the HTML code:

<div class="panel-heading padder-b-none">
    <h2 class="h4 sp-attachments-header panel-title pull-left">
      ${Attachments}
    </h2>
    <div ng-if="::(data.canWrite && data.canAttach && data.recordIsActive)"> <!-- Modify this line -->
      <sp-attachment-button></sp-attachment-button>
    </div>
    <div class="clearfix"></div>
  </div>

Make sure that you replace the OOB widgets with your newly cloned widgets before testing and you should be good to go!

mev
Tera Contributor

this worked for me, thanks for saving me some time!