Restrict export of single column

Vijay Kumar
Tera Contributor

Hi All,

I have a requirement where i need to restrict export of single column . The column should be present in list view but whn exported all other columns of list should come but not the restricted one.

Kindly let me know for possible solutions.

Thanks in Advance

Regards,

VIjay

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vijay,



I think you will have to go with some custom code instead of updating out of box button.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vijay,



One solution is as below:



1) Create a list view and consider for example there are total 10 columns and you want to remove one from the export excel functionality


2) To this newly created list view add the 9 columns and skip the one which you want to restrict.


3) This will update the global export button so be careful to add that condition of table name check



Go to UI Context Menus in left nav -> search with name as Export -> Open it



Open the Context Menu with name as "Excel (.xlsx)" -> in the script section add this.


you will have to repeat this for other as well i.e. Excel, CSV context menu if you need.



if(g_list.tableName == 'table_name'){ // name of your table


sysparm_view = 'export_view'; // this is the newly created view which has 9 columns


}



This should work. I tested this and when user clicked on Export -> Excel(.xlsx) then only those columns came which were defined in the newly created list view.



Screenshot 1;


context-menu-1.JPG



Screenshot 2:



context-menu-2.JPG



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vijay,



Any update on this?


Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.



Regards


Ankur


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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vijay,



Any update on this?


Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement.


This helps in removing this question from unanswered list and helps users to learn from your thread.


Thanks in advance.



Regards


Ankur


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