Function QuerySizeCondition giving 'NullReferenceException

I’m not sure why I’m getting a NullReferenceException when I’m just checking to see if a table has more rows than zero. The table was attempted to be filled by a Method Call and it’s possible that nothing be returned. If nothing is returned then I want to continue with creating a record.
If something is found the QuerySizeCondition works fine, but if there isn’t then I get the NullReferenceException.
I’m wondering if there is a bug or limitation with the Function’s QuerySizeCondition on a Table with no records.
Or perhaps if a BO Method call returns no records the Tableset isn’t created or something? (but that doesn’t make sense).


1 Like

you should show full stack trace from server log for the error

1 Like

Yes widgets… which brings up another oddity… so this is cloud… and eventhough my user account has BPM Advanced Enabled, all Epicor Function Sec Groups, and my Function Library has custom Code options enabled, I don’t get Custom Code widget options. Maybe cloud doesn’t permit custom code in a Function? But that doesn’t seem right.
Also, an another attempt on this in a BPM I was trying to do a LINQ Union and setup a new table and if I referenced ‘CustID’ syntax check said that only BPM Advanced Users can access CustID, but I am a BPM Advanced User.

1 Like

This is cloud so I can’t have access to the server log.
Unless you mean one of the Server Logs accessible via the Download Server File menu item…then I would need to know which log.

But I know the dataset it’s complaining about, but I didn’t think it cared if there were rows in a table or not when using a query to check the row count.
BTW - I have three tables, Customer, ShipTo and Contacts and I’m using a BO Method to look for any matches in each of those tables then I’m attempting to run a QueryCondition to make sure there are more than zero rows in those table before continuing. If all tables are empty then I want to take one action, if there are any values in any of those tables I want to display some key data from those tables.
What is odd is of the three tables, only the Contacts table gives the NullReference error.

Quoting doesn’t seem to be working properly on my phone at the moment, ugh.


Server log is coming soon from Epicor upon user request.

You can get the event logs currently by using my dashboard. Check the experts corner.

Cloud customers have all the same options in functions as on prem.

To use custom code “widgets” in functions, it has to be enabled on the library AND. you have to create the function with new with that option.

Remember, I’m SaaS, and I do all kinds of crazy crap.

1 Like

Is this not the full Error message:

System Information


AppServer Connection:
Form Name: Customer Maintenance
Customization Name:
Menu ID: DRVMT000
Software Version: 11.2.300.0


Server Side Exception

BPM runtime caught an unexpected exception of ‘NullReferenceException’ type.
See more info in the Inner Exception section of Exception Details.

Exception caught in: Epicor.ServiceModel

Error Detail


##!Correlation ID:##! 422e86bb-3ebb-41e8-a321-ce3ea728f5c5
##!Description:##! BPM runtime caught an unexpected exception of ‘NullReferenceException’ type.
See more info in the Inner Exception section of Exception Details.
##!Program:##! efx.getaligned.dll
##!Method:##! A004_FillTableByQueryAction
##!Original Exception Type:##! NullReferenceException
##!Framework Method:##! Run
##!Framework Line Number:##! 92
##!Framework Column Number:##! 17
##!Framework Source:##! Run at offset 23 in file:line:column C:_releases\ICE\ICE4.2.300.0\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.cs:92:17

##!Server Trace Stack:##! at EFx.GetAligned.Implementation.CustLookupImpl.A004_FillTableByQueryAction()
at EFx.GetAligned.Implementation.CustLookupImpl.RunStep(Int32 workflowStep)
at Epicor.Functions.FunctionBase3.Run() in C:\_releases\ICE\ICE4.2.300.0\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.cs:line 92 at Epicor.Functions.FunctionBase3.Run(TInput input) in C:_releases\ICE\ICE4.2.300.0\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.cs:line 75
at EFx.GetAligned.Implementation.CustLookupImpl.AdapterRun(ITuple input)
at Epicor.Functions.FunctionBase3.Epicor.Functions.IFunctionAdapter.Run(ITuple input) in C:\_releases\ICE\ICE4.2.300.0\Source\Server\Internal\Lib\Epicor.Functions.Core\FunctionBase.Adapter.cs:line 11 at Epicor.Customization.Bpm.CustomizationBase22.InvokeFunction(String libraryId, String functionId, ITuple input) in C:_releases\ICE\ICE4.2.300.10\Source\Server\Internal\Lib\Epicor.Customization.Bpm\CustomizationBase2.Plugins.cs:line 66
at Epicor.Customization.Bpm.DirectiveBase2.InvokeFunction(String libraryId, String functionId, ITuple input) in C:\_releases\ICE\ICE4.2.300.10\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.Plugins.cs:line 373 at Epicor.Customization.Bpm.BO.GetNewCustomerPreProcessingDirective_CheckForCCCustomer_EA793A66BE7144A6A966DFAF2E45146C.A004_InvokeEpicorFunctionAction2() at Epicor.Customization.Bpm.BO.GetNewCustomerPreProcessingDirective_CheckForCCCustomer_EA793A66BE7144A6A966DFAF2E45146C.ExecuteCore(Int32 step) at Epicor.Customization.Bpm.DirectiveBase2.Execute() in C:_releases\ICE\ICE4.2.300.10\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 330
at Epicor.Customization.Bpm.DirectiveBase`2.Execute(TParam parameters) in C:_releases\ICE\ICE4.2.300.10\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 222

Client Stack Trace

at Ice.Cloud.ProxyBase1.CallWithCommunicationFailureRetry(String methodName, ProxyValuesIn valuesIn, ProxyValuesOut valuesOut, RestRpcValueSerializer serializer) at Ice.Cloud.ProxyBase1.CallWithMultistepBpmHandling(String methodName, ProxyValuesIn valuesIn, ProxyValuesOut valuesOut, Boolean useSparseCopy)
at Ice.Cloud.ProxyBase`1.Call(String methodName, ProxyValuesIn valuesIn, ProxyValuesOut valuesOut, Boolean useSparseCopy)
at Erp.Proxy.BO.CustomerImpl.GetNewCustomer(CustomerDataSet ds)
at Erp.Adapters.CustomerAdapter.GetNewCustomer()
at Erp.UI.App.CustomerEntry.Transaction.GetNewCustomer()

Inner Exception

Object reference not set to an instance of an object.

It fails in the action, not check query rows condition. You probably looking into wrong place?

1 Like

So here is what my function is doing… BTW it works fine if I exclude one widget or rearrange things.
BPM Pops a form to ask for a Name, Phone Number & Email address which are stored in BPMData fields.
Then I call a Function (because of conflicts with multiple datasets referencing the same fields… doesn’t matter, just need different scope) and I pass these values.
In the function it calls 3 GetListCustom for Customer, ShipTo and Contact and in each I am modifying the whereClause to look for any of the values (Name, Phone, Email). Which are configured to return the results to the required Tableset variables.
Then I was going to check each of these tablesets to ensure one of them have a row, if they do, then I use a LINQ Expression to Union the 3 tablesets to to extract the distinct Customer ID, then I use that to lookup the Customer Name, pass these back to the BPM for an exception popup.

If a match is found in Contacts, it all works fine… but if no match is found I get the NullReferenceException. Even if before or after that step I fill the Contact table with a dummy record.
The other two GetList for Customers & Ship To work fine and do not throw the NullReferenceException when there are no rows. It’s almost like when no contacts are found the table no longer exists, which doesn’t make sense as it’s a defined variable.
Now WHEN the NullReferenceException happens seems to follow whichever BPM widget follows the BO Method call Contact.GetListCustom. If I skip that widget and just fill the table with dummy records, or not even do anything with the table, I don’t get a NullReferenceException.
But if I call that method and nothing comes back it’s like it tosses the tableset or something.
I was hoping to use the Method call because it returns the CustID and CustName in it’s dataset… but if I can’t figure this out… I’ll have to check for the contact, and then try to look up it’s customer, which is fine, but not elegant… and this error it doesn’t make sense…
(maybe I have bulldog lockjaw or something), it’s just annoying when only 80% seems to work consistantly and the rest seems random.

That’s what this test run was giving as the point of the NullReferenceException.
In trying to nail down what the issue is I’ve skipped some actions to see if it’s the action or the previous action that is causing the NullReferenceException.
In this case I decided to call the BO Method which should fill the contact table, then in order to ensure there was at least one row in that table, I used FillTableByQueryAction, which just adds a dummy record and then go into the condition check… and the error moved to this action, so the issue isn’t with my condition query check, but seemingly with the table just disappearing between the BO Method call (when no rows are returned) and whatever action follows it.
I’ve tried taking it straight to a Message popup and the NullReferenceException then is thrown there…

Maybe your linq queries use .FirstOrDefault() function and this throws null on Union? Do you have acccess to the source code of your function? or it is not possible in the cloud?

You can get it, but you’d have to code it to get it.
I can get mine, I guess I could code up a tool when I have time.

1 Like

I have no doubt YOU can get it :smiling_imp:
Maybe there is an approved way to get source code from server?

1 Like

Not that I’m aware, but I guess I’m off to make an idea.


Yes please

1 Like

When I was on Dedicated Tenancy, I suggested this would be a good place for GitHub. Users could clone, make a pull request, fire off a ServiceNow ticket, approve, and install.

1 Like

What, no link to your idea here :grinning:?

1 Like

It was LONG before the Epicor Ideas program. And, it does kinda fall into the DevOps one… :face_with_hand_over_mouth: