BKen
(Brian Ken)
January 9, 2023, 9:23pm
1
So our Sales orders will sometimes have a different Ship To Customer than the Bill To Customer, and some Sales orders will have a ShipTo record for the Ship To Customer:
I am trying to show a task owner what the ship to name is:
Here is the formula I am using on the Data Directive (for my variable ShipToShipToName):
The formula results in a null value.
I created a BAQ with the same links:
The criteria on my OrderHed is this particular Sales Order, and here are my display fields:
The results of my BAQ are:
So I am expecting my formula in my Data Directive would be “TestCustomerTwo - Ship To TX” and not be null.
But I get this:
Is there a problem with my formula?
jkane
(John Kane)
January 9, 2023, 9:40pm
2
I forget the exact phrase that is needed, but you need to filter out the empty Ship To records. Once you do that, it should work.
BKen
(Brian Ken)
January 9, 2023, 10:12pm
3
Do I need something different than the FirstOrDefault() in my c# expression (I am weak with code)
(from x in Db.ShipTo where x.Company == ttOrderHedRow.Company && x.CustNum == ttOrderHedRow.ShipToCustNum && x.ShipToNum == ttOrderHedRow.ShipToNum select x.Name).FirstOrDefault()
jkane
(John Kane)
January 9, 2023, 10:26pm
4
I just remembered, you have to account for using the blank ship to record on both tables. I forget how to code this right now, but I will look it up as I believe I have it noted somewhere.
klincecum
(Kevin Lincecum)
January 10, 2023, 12:44am
5
someVariable = (from x in Db.ShipTo
where
!string.IsNullOrEmpty(ttOrderHedRow.ShipToNum) &&
ttOrderHedRow.ShipToCustNum != null &&
x.Company == ttOrderHedRow.Company &&
x.CustNum == ttOrderHedRow.ShipToCustNum &&
x.ShipToNum == ttOrderHedRow.ShipToNum
select
x.Name).FirstOrDefault();
someVariable = !string.IsNullOrEmpty(someVariable) ? someVariable : "No Record Found";
BKen
(Brian Ken)
January 10, 2023, 5:12pm
6
Kevin,
I am weak with code, but I get this error when I try to use your code:
But I am not sure that is my issue. My BAQ is getting the data from the ShipTo Db table, with the same links, giving a value (that is not null).
I just placed Field queries in my email message so I can see the values:
And this is the text from the message:
I suspect my issue lies within the formula I am using to find the ShipToShipToName:
But I do not know what the issue is.
jkane
(John Kane)
January 10, 2023, 6:14pm
7
Instead of returning just the field, throw the full table in there and see how many records get returned.
BKen
(Brian Ken)
January 10, 2023, 6:54pm
8
I noticed an odd thing. In my formula, “… == ttOrderHedRow.ShipToNum…” that the ShipToNum was pink and not black like the other fields.
I was grabbing the value from here:
But because I had a variable with the name ShipToNum, Epicor thought I was referencing the variable and not the tt value.
So I changed my variable name from ShipToNum to Ship2Num and it changed the values in this formula:
I had to do the same thing with CustNum (another variable I created).
Now the formula looks like this:
But still no joy yet.
BKen
(Brian Ken)
January 10, 2023, 6:55pm
9
John,
How do I dump the whole table?
jkane
(John Kane)
January 10, 2023, 6:58pm
10
same as how you insert a field into the message, except choose table instead of field. should be right above or below the field one.
BKen
(Brian Ken)
January 10, 2023, 7:03pm
11
Here?
If so, you can choose only 1 field:
jkane
(John Kane)
January 10, 2023, 7:17pm
12
Yup, select them all to see all of the data and how many records are returned. I have found many times that the tt table does not actually contain the info I am looking for. Or that I am returning more than 1 row.
BKen
(Brian Ken)
January 10, 2023, 7:32pm
13
ADVICE: DO NOT CREATE VARIABLES WITH THE SAME NAME AS FIELDS
Success!!! Once I changed my variables (so the variable name did not match a field name), I forgot to change the Scalar variable to match my new variable name. Now that I have fixed all my variable names, I get the value I am looking for.
Thanks for the help forum.
1 Like
klincecum
(Kevin Lincecum)
January 11, 2023, 12:26am
14
I’m sorry, I was unclear on if it was being used in a custom code block, or an expression.
It would have required some tweaking to be used in an expression.
Glad you got it all worked out though!