Why is SPList.GetItems(SPQuery) returning always the same item to different SPQueries?

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

Hi,
I tried removing $camlItems and it didn't help. Now I moved the $camlQuery
= New-Object
Microsoft.Sharepoint.SPQuery insided the foreach and rremove it at its end and it works now. Thanks!
However this looks like a bug in SPQuery to me.
m.

Similar Messages

  • Applying different template to the same item for different organizations

    Hi I'm having an issue with an item load.
    We are trying to load a list of items using the item import.
    3 orgs
    1: mas
    2: first
    3: second
    say in the new list that we are importing there is an item "100A" (mtl_system_items_b.segment1)
    This item already exists in the mtl_system_items_b as a master item (ie assigned to the master org) it has template "STOCK ITEM"
    and is also attached to the first org
    I want to create the same item as a nonstock for the Second org
    Can this be done?
    When i tried to do the import it failed giving me a INV_IOI_MASTER_CHILD_1A error (Master - Child Conflict in one of these Attributes: Default Buyer(BUYER_ID), Accounting Rule(ACCOUNTING_RULE_ID), Invoicing Rule(INVOICING_RULE_ID), Purchased(PURCHASING_ITEM_FLAG), Shippable(SHIPPABLE_ITEM_FLAG), Customer Ordered(CUSTOMER_ORDER_FLAG), Internal Ordered(INTERNAL_ORDER_FLAG), Inventory Item(INVENTORY_ITEM_FLAG))
    Any ideas on how to do this?
    Thanks
    D

    Hi Sandeep
    Thanks a lot for the reply
    In our MASter org setup, the Template "T1" is a STOCK_ITEM template and it has the stockable attribute set at the org level.
    This item is also assigned to ORG1 as a T1 STOCK_ITEM.
    So can we create the same item using "T2 which is a NON_STOCK Template in org2 ?
    If yes then that means I just have to create a record in the MTL_SYSTEM_ITEMS_INTERFACE only for the child org2.My concern is I read somewhere that
    the item import tries to match the attributes of the child org to the master org attribute(for attributes controlled at master org i think).
    And since the attributes for a nonstock are different than those for a STOCK wouldn't that create a problem?
    Thanks
    D

  • Why does a song not return to the same place when I close it?

    Recently, for some reason, when I have a song open and press 'my songs'  (which effectively closes the song) the song doesn't return to its usual location on the screen/folder. Instead it cues to the top left hand corner, and likewise with every other song, the same thing happens.
    It's only just started doing this which makes remembering what is where even more difficult.
    Any help much appreciated.

    You are welcome, Nick. Don't worry about the "é" - it will depend on your keyboard, if it is easy. On my keyboard I type first the accent ´ and then the e, and all is done

  • FlexSession : always the same !?

    Hi,
    In a java class, I do, in a method that I call from a remote object in ActionScript :
    System.out.println(FlexContext.getFlexSession().getId());
    And whatever the client who connects, it have always the same session id (it is in fact exactly the same object FlexSession, the ref is the same).
    However, the client is different : in the Message object that I got in my custom JavaAdapter, getClientId() returns a different id.
    What's the problem?
    Thank you by advance.

    <DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2>Romain, I think you are running into two concepts that may <br />not have been obvious. </FONT></SPAN><SPAN class=164310314-15052008><FONT <br />face=Arial color=#0000ff size=2>I hope others will chime in with more detail, <br />but the following should help you clear things up...</FONT></SPAN></DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2></FONT></SPAN> </DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2>1. Let's say you're using the AMFChannel in your Flex <br />application, ultimately flash.net.NetConnection is used to contact the server. <br />NetConnection batches multiple requests made in short succession into a single <br />payload. Each batched message will be delivered in the same HTTP request and <br />hence FlexContext.getHttpRequest() will return the same instance for each <br />message processed in the batch.</FONT></SPAN></DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2></FONT></SPAN> </DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2>2. Note that a clientId is not the same as a <br />sessionId. Take the AMFChannel as one scenario which posts messages using AMF <br />over HTTP. A sessionId is issued by the J2EE server and typically persists using <br />a jsessionid cookie. Each time the AMFChannel is used to make a request these <br />cookies are sent too reestablising the session. You may have several <br />publishers/subscribers in your application and thus you may have several <br />MessageClient clientIds. If all communication is done over the protocol to <br />the same server then all of these MessageClients would appear to be in the same <br />"session". There are no doubt similar scenarios with RTMP.</FONT></SPAN></DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2></FONT></SPAN> </DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2>Note that there's a further scenario to consider. If you <br />have several Flex applications on say a web page, all communicating with the <br />server using the same channel URL, then you may have several FlexClients, each <br />with any number of MessageClients, all in the same session. This is why there is <br />a unique "FlexClient" id too which uniquely identifies the SWF to the <br />server.</FONT></SPAN></DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2></FONT></SPAN> </DIV><br /><DIV dir=ltr align=left><SPAN class=164310314-15052008><FONT face=Arial <br />color=#0000ff size=2></FONT></SPAN> </DIV><BR><br /><DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><br /><HR tabIndex=-1><br /><FONT face=Tahoma size=2><B>From:</B> Romain Vimont <br />[mailto:[email protected]] <BR><B>Sent:</B> Thursday, May 15, 2008 4:47 <br />AM<BR><B>To:</B> [email protected]<BR><B>Subject:</B> Re: <br />FlexSession : always the same !?<BR></FONT><BR></DIV><br /><DIV></DIV>A new message was posted by Romain Vimont in <BR><BR><B>General <br />Discussion</B> --<BR>  FlexSession : always the same !?<BR><BR>Worse, <br />even FlexContent.getHttpRequest() returns always the same instance of <br />HttpServletRequest. <BR><BR><br /><HR align=left width=200><br />View/reply at <A <br />href="http://www.adobeforums.com/webx?13@@.59b53ed1/0">FlexSession : always the <br />same !?</A><BR>Replies by email are OK.<BR>Use the <A <br />href="http://www.adobeforums.com/webx?280@@.59b53ed1!folder=.3c061a83">unsubscribe</A> <br />form to cancel your email subscription.<BR><BR>

  • HT1689 How can I stop multiple automatic downloads of the same item?

    Why does iTunes keep wanting to download the same item over and over again? How do I stop this without turning off the automatic download function.

    You may click on the "+" button to the right of the first multiple choice box to add more in the same line. When you hover over the button, the tooltip says "insert item beside".

  • Payment Predictor applying multiple payments to the same Item when customer send more than 1 payment in 1 deposit.

    We have an issue where customers are sending us multiple payments and they come in the same deposit. When payment predictor runs, it is applying both the payments to the same Item using different algorithms. I would think when an Item is selected by 1 payment it should be tagged like it is on a payment worksheet and another payment should not try to apply it to the same item. Ex: we have an Item with balance $1356. Two payments came in for the same customer for $992 and $1356 in the same deposit. Payment predictor applied both payments to the same Item using #BALANCE and #OLDESTC algorithm. The Item now has a balance of -$992. Did anyone else see this issue?
    Thanks,

    Are both the payments for the employee not transferred or only the unpaid one ?
    How about paying both the amounts(status paid) and then do a transfer to SLA.
    Cheers,
    Vigneswar

  • Please can someone explain how to delete email addresses?  I have people who when I type in their name it comes up with the correct email address but then when you hit return to confirm it promptly changes the name to someone else (always the same someone

    Please can someone explain how to delete and email address that when typed in brings up one name but when you hit return to confirm it jumps to another name.  I can't find them in my contacts list but they do come up when you type the first few letters of a name.
    EG If I type xyz and the name of the person comes up, when I press return to confirm that's the one I want then it jumps to [email protected],  always the same def address.
    I can't fathom it out.
    Thanks
    Terri

    Try this:
    Start a new email.  In the To address bar, type in xyz like you normally do, press return to confim, and when the address you want to remove shows up in the address bar, move your cursor over the address you want to delete.
    A small triangle next to the name will show up.  click on it, a drop down menu will open, click Remove from Previous Recipients List.  Then do the drop down menu again and Remove Address.
    Good luck.

  • Every time I turn my mac off, the desktop background changes. It always returns to the same picture, which was the second or third thing I changed my desktop to after getting my mac.

    Every time I turn my mac off, the desktop background changes. It always returns to the same picture, which was the second or third thing I changed my desktop to after getting my mac. I have background switching unchecked in my preferences, and I have never selected it as an option. Also, when I go to my preferences, it will show the icon of the picture I changed it to, even though the desktop itself has switched back.

    I would start with some basic troubleshooting.
    REPAIRING DISK PERMISSIONS -
    NOTE: refer to article "About Disk Utility's Repair Disk Permissions feature" found here http://support.apple.com/kb/ht1452 - for the actual apple article on these step. ----
    - click finder in the bottom dock, and in the window that opens, select applications in the left column - scroll through until you see the 'Utilities' folder and double click to open it.  Then double click on 'Disk Utility'
    - When prompted to select a disk volume or image, select the 'Macintosh HD' in the left column
    - ensure the the "first aid" tab is highlighted blue in the middle of the screen
    - click the button at the bottom that says 'Repair Disk Permissions'
    - this process will take a few minutes to run.  It will indicate it's done, by scrolling to the bottom of the "details area" displaying 'Permissions repair complete'
    Dan Frankes has written an excellent article for Macworld on "Permissions" and the need to repair them - see - http://www.macworld.com/article/52220/2006/08/repairpermissions.html.    Another good web site is - http://www.thexlab.com/faqs/durepairfns.html.
    REPAIRING DISK - About OS X Recovery - http://support.apple.com/kb/HT4718.
    - restart your computer hold down command + R keys on the keyboard to boot you into Lion / Mountain Lion Recovery mode
    - select english as your main language then the continue arrow
    - select "Disk Utility" on the resulting screen then 'Disk Utility' ---
    - When prompted to select a disk volume or image, select the 'Macintosh HD' in the left column
    - ensure the the "first aid" tab is highlighted blue in the middle of the screen
    - click the button at the bottom that says 'REPAIR DISK' .......NOT "Repair disk permissions"
    - this process will take a few minutes to run.  It will indicate it's done, by scrolling to the bottom of the "details area" displaying "The Macintosh HD appears OK"
    If you get any other message OTHER than "The Macintosh HD appears OK", like "the Macintosh HD was repaired successfully" run the "Disk Repair" again, until it displays  "The Macintosh HD appears OK".
    Once done, restart the computer as normal

  • Why all JMenuItem's of JPopupMenu perform the same action?

    Why all JMenuItem's of JPopupMenu perform the same action?
    I trying to do something similar to what there is in JBuilder where you right click a method or a class - you get a popUpMenu and if you choose the
    "Browse Symbol" JBuilder browses to that method/class.
    I'm trying to do the same and to browse to some class of mine (not a java class). But there's a problem.
    This is my code : -
    OMClass desiredClass = event.getNavigationClass();
    if(desiredClass instanceof OMComplexClass) {
    Set classSet = desiredClass.getSimpleClasses();
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem = null;
    menu.add("Browse to :");
    menu.addSeparator();
    Iterator it = classSet.iterator();
    for(; it.hasNext(); ) {
    OMConcept concept = (OMConcept)it.next();
    menuItem = new JMenuItem(concept.getName());
    menuItem.addActionListener(new NavigateToComplexClass(concept));
    menu.add(menuItem);
    menu.show((JComponent)(event.getMouseEvent().getSource()), getX(), event.getMouseEvent().getY());
    ComplexClass is build of SimpleClasses - so if I want to browse to complex class I ask the user by a JPopupMenu what specific SimpleClass he would like to browse to. My ActionListener is a NavigateToComplexClass class - and hewe is the code : -
    public class NavigateToComplexClass implements ActionListener, ItemListener {
    private static OMClass classToShow = null;
    GUI_Location currentLocation = null;
    public NavigateToComplexClass(OMConcept desiredClass) {
    classToShow = (OMClass)desiredClass;
    public void actionPerformed(ActionEvent evt) {
    currentLocation = frame.fillGUI_Location();
    frame.getProject().getHistoryManager().updateHistory(currentLocation);
    if(classToShow == null) {
    return;
    frame.getClassDisplay().getTabbedPane().setSelectedIndex(1);// 1 - parameeter : Property tab.
    frame.getConceptViewPanel().selectConcept((OMConcept)classToShow);
    public void itemStateChanged(ItemEvent e) {
    The problem is that no matter what JMenuItem I select and press it's navigating to the same simpleClass like if I have a
    b
    c
    no matter what I'll press I'll always goto a (or b or c but always the same)

    hi,
    for your actionlistener all those items are more or less the same. when browsing to them you have to give them different names or better different actioncommands.
    regards

  • How do I return to the same folder in Mavericks?

    Since I've upgraded to Mavericks, my apps always go back to the top level when I open a document. For example, let's say I want to open a document called SAMPLE FILE.  I go to the file menu, select OPEN and then navigate thru the directory to find the file I want...
    HD > Clients > Documents > SAMPLE FILE
    Now I want to open a second file - I go to the file menu, select OPEN and instead of returning to the "Documents" folder where my SAMPLE FILE was just found - it puts me back at the top of the directory...
    HD >
    ... and I have to dig thru all the folders again to return to where I just was.
    In my previous system configurations (going back as far as I remember) - the default was to return to the same folder. Or maybe I always set the preferences that way - I honestly don't remember. But now I've searched all over for it and can't find it. Anyone know where to find it? Or has it been eliminated in Mavericks? I can't imagine Apple would do that.
    Any and all help would be appreciated. Thanks.

    Dear Friends
    My actual problem description as the following
    I have a form for production order screen , and this form contain header and details blocks , so the user in the details will select Type Code , and he will go the next field that is Item Code Field search for specific Item Code if it is not exist he has to call the Item Definition Form by using this script
    CALL_FORM(ITEM_DEFINITION);
    Then when he finished defining the Item , and I assign the item code as the following in the :
    WHEN-BUTTON-PRESSED TRIGGER
    :GLOBAL.ITEM_CODE_VAR := :ITEM_CODE;
    DO_KEY('exit_form');
    But I don't know where to keep this assignment
    :ITEM_CODE := :GLOBAL.ITEM_CODE_VAR;
    inside the caller form in which trigger do I have to use when it return from the caller form it should assign the :GLOBAL.ITEM_CODE_VAR to the :ITEM_CODE and the cursor it should show inside the ITEM_CODE , and as I mention it does not return to the same location of The ITEM_CODE when it return from the calling form
    Waiting for your valuable answer .
    With example please .
    Best Regards
    Jamil Alshaibani

  • TableModelEvent  is always the same - one cell or entire table changed

    Why does JUTableModel fire always the same event, if you change a single cell, or entire table structure changes.
    Event always looks like this:
    first row: 0
    last row: 2147483647
    type: 0
    column: -1
    source class: oracle.jbo.uicli.jui.JUTableBinding$JUTableModel
    I need to distinguish between a single cell change and entire table structure change.

    Thanks for getting back at this.
    Unfortunately I get a 0, when I try to reproduce your solution. Of course, I am using the German version, but it should be the right formula.
    When I leave out the $-signs in the search array I get a 0. See second picture.
    Am I doing it wrong?
    Lukas

  • Why cant i talk and surf at the same time?

    Why cant i talk and surf at the same time? Got lost yesterday and while on the phone i couldn't search store web to get the address. Perfect timing to figure this out; when you're lost.  This is a MAJOR problem for me and anyone on the go. WHEN WILL THIS BE FIXED??? I will not hesitate to return this phone as im sure all TURBO users feel the same. Someone said the MOTO X was the same way... is it still...why hasn't then been fixed by now? Which now makes me wonder if this wasn't an oversight but something intentional. Why did they hide the fact that they knew this was going on? i should have been told that this capability wasn't available on the TURBO at time of purchase. FIX IT NOW!

    ChristiLockridge wrote:
    And i've had every DROID since the original with the exception of the Bionic.
    Then you have had phones WITHOUT the capability of talk/surf at the same time. If you don't realize this, then you don't(or at least didn't) use it as often as you think. Original Droid didn't have this capability. Droid X didn't have this capability. Droid X2 didn't have this capability. For the most part(there may have been exceptions of which I am unaware), NO Verizon phone had this capability until 4G phones and then ONLY when on a 4G LTE signal. 4G phones on a 3G signal did not/do not have this capability.
    ChristiLockridge wrote:
    The same as texting, or calling or browsing. This is just a given.
    Personally, I check these things on EVERY phone before I purchase. This is just a given.

  • IPhone 5s restored from 4s all but my photos and won't finish.  Have tried reset and restore several times but always the same thing. Pat bottom of screen it shows downloading but no pictures transfer.

    Have tried 4 times to reset, erase and restore but always the same result.  Everything restores except my photos. When I go to photos at the bottom of the screen it says downloading but the pictures never transfer.  Every time I turn my phone on it asks to continue restore but it never finishes. It won't let me upgrade to the latest iOS due to incomplete restoration.

    How long has it been since you let the restore just happen? Sometimes photos are what takes the longest to bring back from an iCloud back up. I would recommend that you let it just keep restoring for about 2-3 days and see if more photos come back than what you're experiencing. Also make sure that you are connected to wifi as much as possible so that those photos can be downloaded faster. It is a waiting and being patient kind of thing. I did an iCloud restore from a backup that took 4 days to finish bringing down all my photos.

  • Why can't two different users use Itunes on the same computer with different log ins

    Why can't two different users use Itunes on the same computer with different log ins

    Pmorgan5672 wrote:
    Why can't two different users use Itunes on the same computer with different log ins
    They can, but not at the same time.
    If one user left iTunes running, and another user tries to use iTunes from a different Windows user ID, that second user will get an error message.  If they really want to use iTunes, they either have to beg the first user to log in and close iTunes, or else they have to restart the computer.
    If you are asking the technical reason why, it is something about context switching.

  • When I listen to music on Apple TV 2 my pictures from iPhoto come in, but always the same album (which I nevr asked for), always in random order and always in a different format. How can I control what is going on and choose the album myself.

    When I listen to music on Apple TV 2 my pictures from iPhoto come in aafter about ten minutes, but always the same album (which I never asked for), always in random order and always in a different format. How can I choose a different album myself and control the order and format?

    Thank you Winston for a helpful response and for reminding me of something which I found nearly a year ago and then lost (in my mind) because I did not use it. I am grateful for a correct answer but it still only achieves part of what I wanted.
    I can now choose my photos, decide how long they stay on screen and choose one of a variety of presentations. Two things I still can't do.
    One is to get it to play the photos in the chronological order in which I have carefully set them in an album; it still tends to be random and repetitive. The other is that I cannot get any of them them to saty on screen for more than about 20 seconds. I guess this is all due to the way Apple TV is constructed.
    But still thanks, nevertheless.
    Alec

Maybe you are looking for