Skip to main content What is Dynamics 365? Guided tours Customer stories Try our products Build your own agents CRM ERP Sales Service Sales Customer Insights Customer Service Contact Center Field Service Supply Chain Management Commerce Finance Project Operations Human Resources Business Central Pricing Business application topics Training & certifications Migrate to the cloud Documentation Events Dynamics 365 Blog Product updates Onboarding and implementation Community Find a partner Software Development Companies Partner resources Microsoft Marketplace Product documentation Technical support On-premises product support Contact us Try for free Sign in
  • 1 min read

Wrong argument type for function


When double-clicking on a record in a list page to see the details of that record in a task page/form and getting this error:
Error executing code: Wrong argument type for function.

With a stack trace of:

(C)\Classes\QueryRun\setRecord

(C)\Classes\FormDataSource\executeQuery

Change the query used on your task page.  The cause is a table being present in the data sources for the task page but not in the query for the list page.  When the query is copied over from the list page by the SysListPageHelper class to the task page it leaves the additional table in the opened form without any data because the table didn’t exist in the query from the list page.  That datasource then throws the error message because the current record cannot be determined. 

To avoid this error in the task page/form if possible set the join type to Delayed on the additional data source.  Then the record doesn’t need to be loaded right away by the query.  If the query on the task page can not be modified change the list page so that it includes the additional table.

Get started with Dynamics 365

Drive more efficiency, reduce costs, and create a hyperconnected business that links people, data, and processes across your organization—enabling every team to quickly adapt and innovate.