logo

NJP

ServiceNow Portal(Part 13b) - Download in XLS with/without filters (Customized Button)

Import · Dec 31, 2019 · video

asslamu alaikum everyone i'm back with another video and today i'll be showing you one of the most interesting stuff so the thing is i'll be creating one widget where there will be a button on clicking of which the whole data will get downloaded in the excel sheet and we can view those data and we can keep those data as already it has in the like this but I'll be just creating it in the l1 l1 button so how to do that I'll be showing you today and you can even download it according to the filter so you can just give the filter here and according to that filter we can download the records number of Records and the values which is present in that particular filter so let's get started so the first thing that I would like to show you is there is something known as link button which is out of the box which is present in our system so we will first copy this widget because from this widget only we will be modifying my download widget thing so I'll just close this and I will rename it as export in CSV okay I will just save it now I will open it in the editor so my main concept is how to like how is this happening okay over here the functionality with ServiceNow it has given us I will create a custom widget of mine own and I'll show you how to do that so the first thing the main concept of mine will be if you will see that there are two options schema which is present one is for link for button and the another is for contents or button okay so button text is the name and the HR a href is the name of the link for button so I will not provide any link for button so that and I will I will be needing a pop-up page if you will click that particular button so I will be needing a pop-up page and I'll be needing that table where you are putting where I will put this for example if I put the widget here so I need to refer this table I need to refer this particular filter and I need the data so it's quite simple and with these three with the help of these three things I will just create an href and I will push it in the and I will pass it in the link for button so I'll just show you how we can do that the first thing is over here if you see that option what color is there okay so I'll be adding here one more thing is ng click because if you will click this button I need you to open the pop-up C dot open Papa okay okay the first thing I have completed the next thing I'll go to the client sir client side over here nothing is written first I will mention the window and the scope okay now firstly see dot data dot href href is the link for button I will give the value here test okay because I need I need a blank page for example the way it got downloaded if you see if I just do export an excel see this blank page is coming so I need that so for that I am giving it as test because href is here HR Eve is the name of this particular link for button name okay so now next thing I will do is see dot data dot action I will create one particular variable and it will be empty now after this I will give the function name pop-up is equals to function okay what will happen inside this function is first I will create one variable method and I will assign this value as confirm confirm okay means this is confirmed like you have already clicked this button and you want to download the data which is present in the sheet which is present in the table so confirm message I will do now I will give the seed or server dot dot update dot then function then function and after this I will open the window not a pen and I will give the zero data dot href which is the name for the links of button which I will give us empty or test which because I have given as test so nothing will open if you will give blank here as well nothing will work but sometimes it happens that in most of the people give the value in link for button so to remove that value I will give test because I need a blank page and I will give as pop-up the name and I will give us with equals to nine hundred comma height equals to 600 the length and height of the page okay because if you see it is opening a new page in over here the new page is getting open which is out of the box but I am giving one the height and width of the page now this is done okay so this is done but server-side now the main thing is starting first over here the that this is given data dot button message is given now my main part starts from here that if input dot method which I have already given here seed because once it gets clicked the option dot pop-up open pop-up is getting clicked my data dot method is equals to confirm so if only it is getting clicked and it the value becomes this confirm then only I will come inside and I will this tab is the table table means I will take the gate parameter the table the name of the table which is which where you will put this particular widget I will get the table name automatically we all know a speed or get parameter gets it automatically takes the table mean now I will take the filter if the filter is present I will get the filter as well okay now I need to take the instance name also which is very important and it is already present in the property instance name it is out-of-the-box property so if filter is present okay if filter is present okay filter is present then we will go inside and we will take the href data dot href is equals to now if you will notice that if you want to for example I will go in incident table incident dot list or not going into incident as well if you see if I will do export as Excel see the sorry the link which is there so we will just add that links of first in black back slash plus the name of the table okay I will give the name of the table plus and the score list which is all obviously there because the whole list I want dot do okay question mark I need it in the XLS format because here it is providing it in the XLS okay I will give it dot XLS you can give anything whatever you want and I will give the system query system query equals to plus filter okay I hope you guys are getting oh if filter is present then I will get all the records with this particular filter else I will only take this part dot XLS this and this I hope you guys got everything so this is a very customized widget you can use anywhere in any of the page so I will add here widget page in designer I will open I will just change the name because this name is not export in Excel as I will give in XLS this is better and refresh it once again now if I search with XLS directly so export in XLS scheme I will just put it in the middle ok so click here is coming because out of the box it is kept and click here over here if you see it is given click click here here see in the server script over here click here is given if you can you want you can give any other thing so I will give the content of button as export in XLS and the color I will give as denture ok so just save it so let's just test whether it is working fine or not so exporting XLS I'll just click this one yes time reading so it is not working somewhere oh my god over here the option I don't know how it happened but I need to write again ng-click equals to C dot open papa to save it refresh and I will download see the size of this it's 900 were was just 600 now if I open this show in folder because excellence format is not supported in my system so I'll open it with the excel see everything got downloaded all the columns which is present in the here which is present everything is there now if I just give any number okay I will just add the filter number is this one I'll just copy okay let's do back number is this run okay if I download from here let's see what happens they actually this is not there in my systems I'll open showing for love open with Excel see one is coming now I will do it with this as well export in Excel s showing folder open with the office excel see ok so the main difference is because of the column the number of columns which is present here and the number of columns you can give the view as well I haven't added the view this is one of the negative point which I haven't added so you can give the view and according to that the number of columns will be visible so you can try it on yourself thank you guys for watching I hope you will like my video and if any other requirement you have you can just mention in the comment thank you guys thanks for watching

View original source

https://www.youtube.com/watch?v=QO0vHc1IhHk