BPM to Query 1 specific PartNum

Got it!  Thanks again sir.

Hello,


I know the answer to this question will end up being silly, but i've spent too much time on this already and I just can't seem to figure it out.


My BPM will eventually update all Part records in Epicor, but while I develop and test it, I need to filter my BPM query to update just 1 PartNum.  The problem is, my code compiles just fine, but when I run it I get a runtime error of "NotSupportedException" for my LINQ query.


The query in my code:


foreach (var PODetail_iterator in (from PODetail_Row in Db.PODetail

where PODetail_Row["Date10"] != null && PODetail_Row.PartNum == "00C1"

select PODetail_Row))

{


}


I know my error comes from comparing PODetail_Row.PartNum to a string, but I can't figure out how to format "00C1" to get it to query correctly.  I've also tried PODetail_Row.PartNum.Equals("00C1"), but that didn't work out either.  Has anyone ever been able to "hard-code" a BPM query to return a specific row by a key value?  If so, how were you able to accomplish it?


Check out the E10 Programmers Guide in EpicWeb it has a lot of examples.
Also a BPM that updates ALL Part Records... sounds like a really bad idea performance wise... you may want to reconsider the purpose unless this is a one time thing.


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Tue, Aug 30, 2016 at 9:46 AM, chan213419@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p></p><p><span>Hello,</span></p><p><span><br></span></p><p><span>I know the answer to this question will end up being silly, but i&#39;ve spent too much time on this already and I just can&#39;t seem to figure it out.</span></p><p><span><br></span></p><p><span>My BPM will eventually update all Part records in Epicor, but while I develop and test it, I need to filter my BPM query to update just 1 PartNum.  The problem is, my code compiles just fine, but when I run it I get a runtime error of &quot;NotSupportedException&quot; for my LINQ query.</span></p><p><span><br></span></p><p><span>The query in my code:</span></p><p><span><br></span></p><p>foreach (var PODetail_iterator in (from PODetail_Row in Db.PODetail</p><p><span style="white-space:pre-wrap;">		</span>where PODetail_Row[&quot;Date10&quot;] != null &amp;&amp; PODetail_Row.PartNum == &quot;00C1&quot;<span style="white-space:pre-wrap;">	</span></p><p><span style="word-spacing:normal;"><span style="white-space:pre-wrap;">		</span>select PODetail_Row))</span></p><p><span style="white-space:pre-wrap;">	</span>{</p><p><br></p><p><span></span></p><p><span style="white-space:pre-wrap;">	</span>}</p><p><br></p><p>I know my error comes from comparing PODetail_Row.PartNum to a string, but I can&#39;t figure out how to format &quot;00C1&quot; to get it to query correctly.  I&#39;ve also tried PODetail_Row.PartNum.Equals(&quot; 00C1&quot;), but that didn&#39;t work out either.  Has anyone ever been able to &quot;hard-code&quot; a BPM query to return a specific row by a key value?  If so, how were you able to accomplish it?</p><p><span><br></span></p><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>

You almost have it, however, try doing something like this. We do this and it works just fine for us. Also if the project is from your string do your part number only have 4 characters, or are they formated like this, 1000-0000-00C1, or something similar. If so you need to do PODetail_Row.PartNum.Contains("00C1"). Here is an example I have and it works just fine.


            foreach (var Part_iterator in (from Part_Row in Db.Part
                                           where ((Part_Row.Company == Session.CompanyID) && (Part_Row.PartNum == ttPODetail_xRow.PartNum))
                                           select Part_Row))
            {
                //Do something here with Part_iterator
            }


Thanks for the replies fellas!

I actually just found out the error isn't coming from my querying against 1 PartNum, but instead it's the portion of the code where I'm checking to see if the UDDate is null or not (PODetail_Row["Date10"] != null).  Have either of you guys filtered to get results where a value isn't null?
 
Since you are querying the DB object it should have a typed Date10 which should of a nullable data type then you can use the HasValue proiperty


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Tue, Aug 30, 2016 at 10:35 AM, chan213419@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p>Thanks for the replies fellas!</p><div><br></div><div>I actually just found out the error isn&#39;t coming from my querying against 1 PartNum, but instead it&#39;s the portion of the code where I&#39;m checking to see if the UDDate is null or not (<span style="color:rgb(63,63,63);word-spacing:normal;">PODetail_Row[&quot;Date10&quot;] != null).  Have either of you guys filtered to get results where a value isn&#39;t null?</span></div><div> </div><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>

You could try it this way. Check the code, not sure i got all grammer, but its close.

var PODetailList = (from ttPODetail_Row in ttPODetail
                       where ttPODetail_Row.Company == Session.CompanyID && ttPODetail_RowPartNum == "00C1"
                       select ttPODetail_Row).ToList();
       
        //Do foreach in here
        foreach(Erp.Tables.PODetail row in PODetailList)
        {
       //Do something
        }

That was it, thank you Jose!

So if Date02 wasn't available what could I have done?  You are right Date10 was brought up with the upgrade, so If I added a UDField afterward, say PODetail.MyDate_c what should I do?  Would that field be available to use without coding in:

PODetail_Row["MyDate_c"]

?

After you update the datamodel the field would show up in the Db Object


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Tue, Aug 30, 2016 at 10:47 AM, chan213419@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p>That was it, thank you Jose!</p><div><br></div><div>So if Date02 wasn&#39;t available what could I have done?  You are right Date10 was brought up with the upgrade, so If I added a UDField afterward, say PODetail.MyDate_c what should I do?  Would that field be available to use without coding in:</div><div><br></div><div><span style="color:rgb(63,63,63);">PODetail_Row[&quot;MyDate_c&quot;]</span><br></div><div><span style="color:rgb(63,63,63);"><br></span></div><div><span style="color:rgb(63,63,63);">?</span></div><div><br></div><p></p>

</div><span class="ygrps-yiv-564009615">
 


<div style="color:#fff;min-height:0;"></div>