Hi,
I have this powershell code:
$url = 'http://artemis/customers' #web URL $ctx = Get-SPServiceContext 'http://artemis' #site URL $scope = New-Object Microsoft.SharePoint.SPServiceContextScope $ctx $web = Get-SPWeb $url $listSyncZakazky = $web.Lists["bcs_Datis_t_synchronizace_Artemis_zakazky2"]; #BCS to MSSQL 2005 database table $listMain = $web.Lists["Zakázky"]; #custom SP list $camlQuery = New-Object Microsoft.Sharepoint.SPQuery [Microsoft.Sharepoint.SPListItemCollection]$itemsLSyncZakazky = $listSyncZakazky.GetItems() #foreach ($itemLSyncZakazky in $itemsLSyncZakazky) { foreach ($itemLSyncZakazky in $listSyncZakazky.Items) { ## happens for both of the ^above^ lines $camlQuery.Query = "<Where><Eq><FieldRef Name=`"CisloZ`" /><Value Type=`"Text`">" + ($itemLSyncZakazky["cislo_zakazky"]).TrimStart("0") + "</Value></Eq></Where>" $camlQuery.Query $camlItems = $listMain.GetItems($camlQuery) foreach ($item in $camlItems) { $item["CisloZ"] } $camlItems[0]["CisloZ"] } $web.Dispose()
This returns the following:
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">404</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">300</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">306</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">400</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">200</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">206</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">40303</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">40300</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">40301</Value></Eq></Where></Query>
404
404
<Where><Eq><FieldRef Name="CisloZ" /><Value Type="Text">5801</Value></Eq></Where></Query>
404
404
No matter what I do, from the second item in the collection I get the result from the first one although the CAML query is clearly modified. I tried to create new external content type, have the CisloZ column type as number and text and no matter what I do I always get the same result.
I use similar code elsewhere and it is working. What could be wrong here?
Martin