<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem in Custom Code using SQL which uses label on token in WHERE clause in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595297#M90222</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@Jason Lightfoot&lt;/A&gt;&lt;BR /&gt;Thanks, now its working.&lt;BR /&gt;So what I was missing was appropriate symbol.&lt;/P&gt;
 &lt;P&gt;Thanks for the support &lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Mon, 18 Dec 2023 23:56:00 GMT</pubDate>
    <dc:creator>Tom24</dc:creator>
    <dc:date>2023-12-18T23:56:00Z</dc:date>
    <item>
      <title>Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595289#M90214</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 23.0.8 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P id="isPasted"&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/77152-test-countnumbersofiteminslot.fsm" target="_blank"&gt;Test_CountNumbersOfItemInSlot.fsm&lt;/A&gt;&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;I'm trying to get slot wise item/SKU count using Custom Code in Process Flow.&lt;/P&gt;
 &lt;P&gt;I've created and tried 3 patterns, "Get SlotWiseItemCount" 1 to 3 but all 3 has issues.&lt;/P&gt;
 &lt;P&gt;There are diffrence in location of "WHERE" clause but all 3 Custom Code has practically the same SQL but all results are different and incorrect.&lt;/P&gt;
 &lt;P&gt;Since SQL is having WHERE condition, LocationCD = token.LocationCD, only single row should come but as you could find in attached model, it wont.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Please take a look into Custom Code "Get SlotWiseItemCount" 1 to 3.&lt;/P&gt;
 &lt;P&gt;Checking will be easier if you use Global Table "QueryDump".&lt;/P&gt;
 &lt;P&gt;Kindly let me know whether I have done something wrong.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Thanks for the support.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 15 Dec 2023 13:12:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595289#M90214</guid>
      <dc:creator>Tom24</dc:creator>
      <dc:date>2023-12-15T13:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595290#M90215</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;If you want to get the content of a slot address, why do you try to do it so complicated.&lt;/P&gt;&lt;PRE&gt;Variant slotitems = Storage.system.queryItems("WHERE item.slot.address = $1",0,token.LocationCD);&lt;BR /&gt;token.labels.assert("inSlot",slotitems.length);&amp;nbsp;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 15 Dec 2023 14:07:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595290#M90215</guid>
      <dc:creator>joerg_vogel_HsH</dc:creator>
      <dc:date>2023-12-15T14:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595291#M90216</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You can get your table at any time directly from the storage system:&lt;/P&gt;&lt;PRE&gt;Storage.system.querySlots("SELECT &amp;nbsp;slot.slotItems.length, slot.address").as(Array).as(Table).cloneTo("QueryDump")&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 15 Dec 2023 14:40:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595291#M90216</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2023-12-15T14:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595292#M90217</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/461/joerg.v.html" nodeid="461"&gt;@Joerg Vogel&lt;/A&gt; &lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@Jason Lightfoot&lt;/A&gt; &lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P id="isPasted"&gt;What I'm trying to achieve is count base on specific label not the content.&lt;/P&gt;
 &lt;P&gt;For example, slot has 16 flowitems which is equal to the content/lenght.&lt;/P&gt;
 &lt;P&gt;All 16 flowitems are randomly labeled 1 to 8. In my model named as "ItemCD" (similar to "Type") on creation event.&lt;/P&gt;
 &lt;P&gt;When stored, slot would be like&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;i.e.&lt;/P&gt;
 &lt;P&gt;ItemCD 1 : 8 boxes&lt;/P&gt;
 &lt;P&gt;ItemCD 3 : 5&lt;/P&gt;
 &lt;P&gt;ItemCD 5 : 2&lt;/P&gt;
 &lt;P&gt;ItemCD 7 : 1&lt;/P&gt;
 &lt;P&gt;total 16 boxes/contents are stored in slot.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Length/conten is 16 but count of "ItemCD" should be 4.&lt;/P&gt;
 &lt;P&gt;That is why I'm using group by/count in sql.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Yes, I understand that there is no need to use sql if there is an easier way to get the count.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;If I'm still missing something, kindly let me know.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 16 Dec 2023 00:46:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595292#M90217</guid>
      <dc:creator>Tom24</dc:creator>
      <dc:date>2023-12-16T00:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595293#M90218</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;in relation to your comment: Use more lines of code. First collect values of itemCD label name. Then push them onto a list with only single value option. List entries are your desired result. &lt;/P&gt;&lt;P&gt;E.g, you could first get all slotItems as an array. Iterate over this array all label values of itemCD in a table query. Push an aggregated result onto a list. &lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 16 Dec 2023 07:44:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595293#M90218</guid>
      <dc:creator>joerg_vogel_HsH</dc:creator>
      <dc:date>2023-12-16T07:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595294#M90219</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;PRE&gt;Storage.system.queryItems("SELECT item.ItemCD, count(*) as freq, slot.address GROUP BY item.ItemCD,slot.address ORDER BY address").as(Array).as(Table).cloneTo("QueryDump");
Table.query("SELECT address, count(*) as numDiffItemCDs FROM QueryDump GROUP BY address ORDER BY address ").cloneTo(Table("SlotMixSummary"));&lt;/PRE&gt;&lt;P&gt;Model with script attached.&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/77180-test-countnumbersofiteminslot-jl.fsm" target="_blank"&gt;test-countnumbersofiteminslot_jl.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 16 Dec 2023 13:41:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595294#M90219</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2023-12-16T13:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595295#M90220</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@Jason Lightfoot&lt;/A&gt; &lt;/P&gt;
 &lt;P&gt;Thanks for the support.&lt;/P&gt;
 &lt;P&gt;Essential problem I'm having in SQL is in WHERE condition.&lt;/P&gt;
 &lt;P&gt;Since picking/target address will be different by each tokens, I want to use label value on each token. But the problem is "WHERE address = [" + token.LocationCD + "]" not working. I have also tried in your SQL using Custom Code but didn't work either.&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Please provide me a support how to use token in WHERE condition.&lt;/P&gt;
 &lt;P&gt;I believe what I'm missing is how to code/write WHERE condition properly.&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 18 Dec 2023 02:27:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595295#M90220</guid>
      <dc:creator>Tom24</dc:creator>
      <dc:date>2023-12-18T02:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595296#M90221</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Not sure why you're using brackets - I'd remove those - but you should use the apostrophe around your string when concatenating the value.&lt;/P&gt;&lt;PRE&gt;"WHERE address = '" + token.LocationCD + "'"&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 18 Dec 2023 02:50:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595296#M90221</guid>
      <dc:creator>jason_lightfoot_adsk</dc:creator>
      <dc:date>2023-12-18T02:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Custom Code using SQL which uses label on token in WHERE clause</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595297#M90222</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/226/jason.l.html" nodeid="226"&gt;@Jason Lightfoot&lt;/A&gt;&lt;BR /&gt;Thanks, now its working.&lt;BR /&gt;So what I was missing was appropriate symbol.&lt;/P&gt;
 &lt;P&gt;Thanks for the support &lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 18 Dec 2023 23:56:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/problem-in-custom-code-using-sql-which-uses-label-on-token-in/m-p/13595297#M90222</guid>
      <dc:creator>Tom24</dc:creator>
      <dc:date>2023-12-18T23:56:00Z</dc:date>
    </item>
  </channel>
</rss>

