

My time break for Office in 365 days
source link: http://aaclage.blogspot.com/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Thursday, October 22, 2020
New Drag and Drop ListView @pnp/spfx-controls-react
This post is about a feature that i was expecting some and was launch in @pnp/spfx-controls-react in version V2.1.0, that was the capability to use drag and drop of files in ListView and capture the file object to make the associated actions afterwards.
The following example explain how we can use the ListView Control to use drag and drop option and retrieve the file object from the new handler onDrop event and copy to a SharePoint Document Library.
The first thing that needs to be made is to configure the ListView properties in the control with the following:
- dragDropFiles as True, activates the drag and drop option.
- OnDrop handler, Method this._getDropFiles retrieves files from drop handler.
The handler OnDrop retrieves the files object that allow us to manage the content as we want.
This can be upload files to a libraries, validate what type of file, size of file, naming with capability or renaming, in the end multiple business requirements that can be stop or validated before file is included in the system.
/**
* Method that retrieves files from drag and drop
* @param files
*/
private _getDropFiles = (files) =>{
let count=0;
for (var i = 0; i < files.length; i++) {
var file = files[i];
if (file != undefined || file != null) {
let spOpts : ISPHttpClientOptions = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
body: file
};
var url = `${this.props.context.pageContext.web.absoluteUrl}/_api/Web/GetFolderByServerRelativeUrl('Shared%20Documents')/Files/Add(url='${file.name}', overwrite=true)`;
this.props.context.spHttpClient.post(url, SPHttpClient.configurations.v1, spOpts).then((response: SPHttpClientResponse) => {
console.log(`Status code: ${response.status}`);
console.log(`Status text: ${response.statusText}`);
response.json().then((responseJSON: JSON) => {
count++;
if(count=== (files.length) ) {
this.componentDidMount();
}
console.log(responseJSON);
});
});
}
}
}
The following method is a reuse function componentDidMount to make refresh of ListView to display the uploaded files that was managed in method below.
public componentDidMount() {
const restApi = `${this.props.context.pageContext.web.absoluteUrl}/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents')/files?$expand=ListItemAllFields`;
this.props.context.spHttpClient.get(restApi, SPHttpClient.configurations.v1)
.then(resp => { return resp.json(); })
.then(items => {
this.setState({
items: items.value ? items.value : []
});
});
}
Tuesday, June 16, 2020
List of Frameworks that could help you start with SPFX
It's really impressive what everyone involve was able to do at this point, since documentation, videos to code..., i remember the beginning of the PnP concept and follow what Vesa Juvonen was generating on the initial steps, cannot believe the amount of years that already past...
But at this point i see people creating samples for everything and reuse existing frameworks without clear information, for people that is working, this can be very confusing on what is provided by SPFX or what needs to be added, i don't what to talk about the SPFX versioning that another article on how to keep everything on track.
But if you are beginning and can understand in what are you in, this Frameworks could help start you development and response the normal question that you make, where i can add a calendar, can i include a metadata control and all this questions that doesn't have a direct but external answer. :)
Here a compilation of some Frameworks that i found very useful, you can use to include in your SharePoint Framework (SPFX) solutions.
tui.image-editor
fullcalendar
https://github.com/fullcalendar/fullcalendar
SharePoint Framework React Controls
Reusable React controls for your SharePoint Framework solutionshttps://pnp.github.io/sp-dev-fx-controls-react/
https://github.com/pnp/sp-dev-fx-controls-react/
PnP Modern Search solution
https://github.com/microsoft-search/pnp-modern-search/
PnP/PnPjs
Fluent JavaScript API for SharePoint and Microsoft Graph REST APIshttps://github.com/pnp/pnpjs/
https://pnp.github.io/pnpjs/
Chart.js
Simple, clean and engaging charts for designers and developershttps://github.com/chartjs
FluentUI
A collection of UX frameworks for creating beautiful, cross-platform apps that share code, design, and interaction behavior.https://developer.microsoft.com/en-us/fluentui#/
https://github.com/microsoft/fluentui
Fontawesome
Popular icon toolkithttps://fontawesome.com/
https://github.com/FortAwesome/Font-Awesome
tui.image-editor
Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.https://github.com/nhn/tui.image-editor
tesseract
Pure Javascript OCR for more than 100 Languageshttps://github.com/naptha/tesseract.js
All NPM installers commands can be found in the following web site.
https://www.npmjs.com/
I am sure there are a bunch of other frameworks i didn't reference that make a huge difference, but this ones will give you a huge boost to start and became motivated to develop in this platform.
Lot of the are being used in the samples provided by the PnP team.
SharePoint Framework
https://github.com/SharePoint/sp-dev-docs
Samples SPFX
https://github.com/pnp/sp-dev-fx-webparts
https://github.com/pnp/sp-dev-fx-extensions
Personal thought:
I remember when i was starting (in 1985 copying code from a magazine to my spectrum 128k that generate a game of falling pieces and needed to escape from them. Draw a circle with a line and thinking "i just draw Saturn, how fascinating this is.", more than 30 years and now i am going to internet to find code... some things never change)
Best regards,
Andre Lage
Thursday, September 06, 2018
Microsoft Flow - Copy Folders with documents between Sites using REST
Following small Business Case:
- Provisioning of Sites and Subsites base in request (example article).
- Sub Site needs to have Folder with Document Templates that needs to be filled by users.
- Template folder is in root Folder and needs to be copy into Sub Site.
- Create Flow Action base in REST to copy folder template to new Sub Site when site is created.
Site URL: {Site}
Method: POST
URI : _api/SP.MoveCopyUtil.CopyFolder
Body:
{
The Flow definition should be enough to be executed.
You can manually execute the Flow and validate their success of the Action.
You can use the flow history for more details, as show in the image below.
Hope you like it,
Best Regards,
André Lage
Tuesday, September 04, 2018
Microsoft Flow - Excel Actions To Copy Table Rows by Recurrence Timeline
- Have Excel document where are stored entries from users.
- Excel Document is stored in SharePoint Online Document Library.
- Every 30 days should archive in different Excel Table the entries from that Month
- Copy from Table 1 to Table 2 (Archive)
- Get rows method can be up to 2048 items.
- The action can list up to 256 rows
This example try to use all Office 365 services and capabilities and SharePoint Online Document Library was used to store the excel demo as show in the image below.
List Excel Table View - Table 1
After access the excel example we are able to see the entries from Table 1 where are listed multiples entries for this demo to be used in the copy between tables.
Microsoft Flow
Recurrence - Action
Access to Microsoft Flow Page and create New Flow using Blank Template.
To fulfill the job timer was used a recurrence Action where was defined interval of 1 time by month to be executed as show in the image below.
List of Action "Preview Excel"
After Recurrence is defined a new Action was defined and list the Excel options, for this example "Excel Online (Business)" to use SharePoint Online Location where is stored the Excel file.
List rows present in a table - Action
This action lists the Table 1 items base in a query from the Excel File to return the selected items to be used to copy in the Table 2.
Property Options:
Location - SharePoint Online Site
Document Library - Document Library from selected SharePoint Online.
File - Excel File Location from Document Library
Table - Table from Excel used as Datasource
Filter Query - query option to select which items to return.
Order by - query option to specify how to sort the items in your query return set
Top Count - query option to specify how much items should return from the return set
Skip Count - option enables you to skip over items until the specified item is reached and return the rest.
For this example were defined 10 items to make the example associated as show in the image below.
Add an apply to each - Step
This step manage the result item collection from last Action where Query from Table 1 was made to be used and copied in Table 2.
Add a Row into Table - Action
As defined in my last Action a new parameter with Item Collection rows from my last query are stored in the parameter "value".
To add new Row in new
Location - SharePoint Online Site
Document Library - Document Library from selected SharePoint Online.
File - Excel File Location from Document Library.
Table - Table from Excel used as destination Datasource.
[Columns Name] - Column Name from Excel Table to include new Items.
To call the item Collection row in the new Row/Column, i would like to recommend the following expression:
- item()['Column Name']
List Excel Table View - Copy output to Table 2
After execution of the Microsoft Flow and validation of execution, users can access to Excel Document and access to support "Table 2", for this case were stored in a separated worksheet and the values should appear as shown in the image bellow.
Best Regards,
André Lage
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK