Automatic Data import

%3CLINGO-SUB%20id%3D%22lingo-sub-60242%22%20slang%3D%22en-US%22%3EAutomatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60242%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI'm%20putting%20up%20in%20place%20a%20sharepoint%20site%20(using%20Sharepoint%20Online)%20for%20my%20company.%3C%2FP%3E%3CP%3EI'd%20like%20to%20create%20an%20Infopath%20form%20that'll%20retrieve%20datas%20from%20a%20sharepoint%20list%20(customers%20list).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'd%20like%20this%20list%20to%20be%20automatically%20updated%20from%20an%20external%20source%20(csv%20file%2C%20power%20bi...)%3C%2FP%3E%3CP%3EWhat%20would%20be%20the%20best%20way%20to%20proceed%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60310%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60310%22%20slang%3D%22en-US%22%3E%3CP%3EUse%20Add-PnPListItem%20without%20the%20Value%20parameter.%20Then%20use%20Set-PnPListItem%20to%20set%20the%20fields.%20This%20is%20a%20known%20issue.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fissues%2F778%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fissues%2F778%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60308%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60308%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20pieter%2C%3C%2FP%3E%3CP%3Ethanks%20for%20info%2C%20i%20already%20tried%20with%20%26nbsp%3B%3CSPAN%3EAdd-PnPListItem%20but%20it's%20make%20trobule%20so%20that%20i%20used%20csom%20within%20pnp%20script%20.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20804px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F12926iEFD89ACC78640031%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22error.png%22%20title%3D%22error.png%22%20%2F%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60303%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60303%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F3058%22%20target%3D%22_blank%22%3E%40Manidurai%20Mohanamariappan%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYour%20script%20will%20work%20for%20simple%20text%20fields%20but%20what%20if%20the%20SharePoint%20fields%20are%20of%20a%20diffferent%20type.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%20using%20Add-PnPListItem%20and%20Set-PnPListItem%20and%20Get-PnPListItem%20will%20be%20better.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%20you%20would%20need%20to%20handle%20things%20like%20%22the%20item%20already%20exists%22....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60302%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60302%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3CBR%20%2F%3EUsing%20csv%20is%20simplest%20method%20but%20you%20need%20to%20create%20list%20columns%20with%20corresponding%20csv%20header%20name.then%20try%20below%20script%2C%20here%20i%20create%20simple%20script%20with%20two%20column%20and%20two%20csv%20header%20so%20you%20can%20change%20column%20name%20and%20header%20value%20in%20the%20script%20and%20this%20script%20based%20on%20pnp%20%3CSPAN%3Esharepoint%20online%20%3C%2FSPAN%3Epowershell%20module%20so%20you%20need%20to%20install%20pnp%20sharepoint%20online%20powershell%20module%20.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%24cred%3D%20Get-Credential%0A%24Listname%3D%20%22Listname%22%0AConnect-PnPOnline%20-Url%20https%3A%2F%2FTenantName.sharepoint.com%2Fsites%2Fcontosobeta%20-Credentials%20%24cred%0A%24csv%20%3D%20Import-Csv%20%22C%3A%5CUsers%5Ccsv%5Cusers2.csv%22%20%0A%24ctx%3DGet-PnPContext%0A%24list%3D%20Get-PnPList%20-Identity%20%24Listname%0Aforeach%20(%24line%20in%20%24csv)%20%20%0A%7B%20%20%0A%0A%24listItemInfo%20%3D%20New-Object%20Microsoft.SharePoint.Client.ListItemCreationInformation%20%20%0A%20%20%20%20%24listItem%20%3D%20%24list.AddItem(%24listItemInfo)%20%20%0A%20%20%20%20%24listItem%5B%22Listcolumn1%22%5D%20%3D%20%24line.Csvheadername1%20%0A%20%20%20%20%24listItem%5B%22Listcolumn2%22%5D%20%3D%20%24line.Csvheadername2%20%0A%20%20%20%20%24listItem.Update()%20%20%20%20%20%20%0A%20%20%20%20%24ctx.load(%24list)%20%20%20%20%20%20%0A%20%20%20%20%24ctx.executeQuery()%20%20%0A%7D%3C%2FPRE%3E%3CP%3ENote%3A%3C%2FP%3E%3CP%3EBefore%20run%20the%20script%20youneed%20modify%20following%20value%20in%20the%20script%3C%2FP%3E%3CPRE%3E%24Listname%3D%20%22Listname%22%3CBR%20%2F%3E%24listItem%5B%22Listcolumn1%22%5D%20%3D%20%24line.Csvheadername1%20%0A%24listItem%5B%22Listcolumn2%22%5D%20%3D%20%24line.Csvheadername2%20%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60282%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60282%22%20slang%3D%22en-US%22%3E%3CP%3EWhy%20do%20you%20want%20to%20use%20InfoPath%3F%20if%20users%20can%20ever%20be%20on%20a%20mobile%20device%2C%20their%20experience%20will%20not%20be%20very%20good.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20may%20want%20to%20take%20a%20look%20at%20PowerApps%2C%20you%20can%20set%20up%20a%20Data%20Gateway%20to%20provide%20access%20to%20on-prem%20data%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60276%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60276%22%20slang%3D%22en-US%22%3EFor%20the%20CRM%2C%20I%20have%20to%20contact%20the%20software%20company%20developping%20it%20to%20check%20if%20something%20already%20exist.%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20for%20my%20powershell%20skills%2C%20they%20are%20a%20bit%20rusty%20%3A)%3C%2Fimg%3E%20but%20I%20can%20try.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60261%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60261%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20might%20be%20a%20better%20way%20as%20you%20could%20let%20CRM%20do%20the%20update%20work.%20I%20could%20imagine%20creating%20a%20CRM%20module%20doing%20the%20work.%20I'm%20not%20100%25%20sure%20about%20the%20options%20available%20in%20CRM%20but%20I%20guess%20this%20could%20be%20a%20workflow%20in%20CRM%20doing%20the%20update%20work%20in%20SharePoint.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20have%20the%20csv%20files%26nbsp%3Bready%20already.%20then%20you%20could%20read%20these%20files%20using%20PowerShell%20and%20then%20update%20SharePoint.%20Personally%20I%20like%20the%20PnP%20PowerShell%20options%20available.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20these%20commands%20it%20is%20quite%20easy%20to%20create%20items%20in%20SharePoint%20and%2For%20update%20them.%20How%20are%20your%20Powershell%20skills%3F%20I%20would%20expect%20that%20developing%20these%20scripts%20as%20somethign%20that%20is%20produciton%20ready%20could%20take%20a%20few%20days.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60253%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60253%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Pieter%2C%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20your%20quick%20reply.%3CBR%20%2F%3EWe%20have%20a%20CRM%20that%20can%20export%20automatically%20the%20datas%20into%20csv%20or%20txt%20format.%3CBR%20%2F%3ESo%20I%20think%20I'd%20go%20for%20the%20import%20solution%20from%20external%20source.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20to%20proceed%3F%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI've%20exlcuded%20BCS%20as%20the%20CRM%20database%20has%20already%20some%20slowness.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-60246%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Data%20import%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-60246%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F49256%22%20target%3D%22_blank%22%3E%40Florent%20SEGUI%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20many%20ways%20to%20do%20this.%20Do%20you%20want%20to%20ijmport%20the%20data%20from%20the%20external%20sources%20or%20do%20you%20want%20to%20reference%20the%20data.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20could%20use%20external%20lists%20using%20the%20BDC%2FBCS%20to%20talk%20to%20your%20databases.%20Please%20be%20aware%20of%20this%20in%20Office%20365.%20I've%20seen%20very%20poor%20performance%20on%20very%20wide%20tables.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20could%20use%20an%20import%20scripts%20(PowerShell%20could%20do%20this%20for%20you).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%20to%20go%20for%20a%20coding%20solution%20then%20you%20could%20access%20your%20data%20maybe%20through%20web%20services.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlternative%20option%20of%20course%20are%20creating%20a%20SharePoint%20Add-in%20or%20maybe%20even%20the%20new%20SPFx%20could%20be%20of%20some%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello,

I'm putting up in place a sharepoint site (using Sharepoint Online) for my company.

I'd like to create an Infopath form that'll retrieve datas from a sharepoint list (customers list).

 

I'd like this list to be automatically updated from an external source (csv file, power bi...)

What would be the best way to proceed?

 

Thanks

9 Replies
Highlighted

Hi @Florent SEGUI,

 

There are many ways to do this. Do you want to ijmport the data from the external sources or do you want to reference the data.

 

You could use external lists using the BDC/BCS to talk to your databases. Please be aware of this in Office 365. I've seen very poor performance on very wide tables.

 

You could use an import scripts (PowerShell could do this for you).

 

If you want to go for a coding solution then you could access your data maybe through web services.

 

Alternative option of course are creating a SharePoint Add-in or maybe even the new SPFx could be of some help.

 

 

 

 

 

 

 

Highlighted

Hello Pieter,

Thanks for your quick reply.
We have a CRM that can export automatically the datas into csv or txt format.
So I think I'd go for the import solution from external source.

 

How to proceed?


I've exlcuded BCS as the CRM database has already some slowness.

Highlighted

There might be a better way as you could let CRM do the update work. I could imagine creating a CRM module doing the work. I'm not 100% sure about the options available in CRM but I guess this could be a workflow in CRM doing the update work in SharePoint.

 

If you have the csv files ready already. then you could read these files using PowerShell and then update SharePoint. Personally I like the PnP PowerShell options available. https://github.com/SharePoint/PnP-PowerShell.

 

With these commands it is quite easy to create items in SharePoint and/or update them. How are your Powershell skills? I would expect that developing these scripts as somethign that is produciton ready could take a few days.

 

 

Highlighted
For the CRM, I have to contact the software company developping it to check if something already exist.

As for my powershell skills, they are a bit rusty :) but I can try.

Highlighted

Why do you want to use InfoPath? if users can ever be on a mobile device, their experience will not be very good.

 

You may want to take a look at PowerApps, you can set up a Data Gateway to provide access to on-prem data

Highlighted

Hi,
Using csv is simplest method but you need to create list columns with corresponding csv header name.then try below script, here i create simple script with two column and two csv header so you can change column name and header value in the script and this script based on pnp sharepoint online powershell module so you need to install pnp sharepoint online powershell module . 

 

$cred= Get-Credential
$Listname= "Listname"
Connect-PnPOnline -Url https://TenantName.sharepoint.com/sites/contosobeta -Credentials $cred
$csv = Import-Csv "C:\Users\csv\users2.csv" 
$ctx=Get-PnPContext
$list= Get-PnPList -Identity $Listname
foreach ($line in $csv)  
{  

$listItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation  
    $listItem = $list.AddItem($listItemInfo)  
    $listItem["Listcolumn1"] = $line.Csvheadername1 
    $listItem["Listcolumn2"] = $line.Csvheadername2 
    $listItem.Update()      
    $ctx.load($list)      
    $ctx.executeQuery()  
}

Note:

Before run the script youneed modify following value in the script

$Listname= "Listname"
$listItem["Listcolumn1"] = $line.Csvheadername1 $listItem["Listcolumn2"] = $line.Csvheadername2

 

Highlighted

Hi @Manidurai Mohanamariappan,

 

Your script will work for simple text fields but what if the SharePoint fields are of a diffferent type.

 

Also using Add-PnPListItem and Set-PnPListItem and Get-PnPListItem will be better.

 

Also you would need to handle things like "the item already exists"....

 

 

Highlighted

Hi pieter,

thanks for info, i already tried with  Add-PnPListItem but it's make trobule so that i used csom within pnp script .error.png 

 

Highlighted

Use Add-PnPListItem without the Value parameter. Then use Set-PnPListItem to set the fields. This is a known issue.

 

https://github.com/SharePoint/PnP-PowerShell/issues/778