I'm using Magento 2 Version 2.1.0

{folder path}\magento2\app\code\Custom\Module\view\adminhtml\ui_component\custom_module_index.xml

<massaction name="listing_massaction">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="selectProvider" xsi:type="string">custom_module_index.custom_module_index.custom_module_columns.ids</item>
            <item name="indexField" xsi:type="string">posts_id</item>
    <action name="delete">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="type" xsi:type="string">delete</item>
                <item name="label" xsi:type="string" translate="true">Delete</item>
                <item name="url" xsi:type="url" path="posts/massDelete"/>
                <item name="confirm" xsi:type="array">
                    <item name="title" xsi:type="string" translate="true">Delete items</item>
                    <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>

{folder path}\magento2\app\code\Custom\Module\Controller\Adminhtml\Posts\MassDelete.php

Only giving code for execute() method

public function execute() {
        $collection = $this->filter->getCollection($this->collectionFactory->create());
        $collectionSize = $collection->getSize();

        foreach ($collection as $item) {

        $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize));

        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
        $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
        return $resultRedirect->setPath('*/*/');

When i'm trying to Delete record from listing, It's giving below error.

2 exception(s): Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause', query was: SELECT COUNT(*) FROM posts AS main_table WHERE (`` IN('')) Exception #1 (PDOException): SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause'

I already compile the di.xml file & also try to remove folder from var/generation. Still same issue & error.

  • Can you show the schema install script? Aug 23, 2016 at 8:23
  • @Aaron After install schema i have changed DB fields & code as well. If you still need then i will post that as well.
    – Jackson
    Aug 23, 2016 at 8:41
  • I am also facing this issue when performing mass action. What is solution for this?
    – Magecode
    Mar 22, 2018 at 6:44
  • @Jackson what is solution? Jun 24, 2020 at 7:13

2 Answers 2


Check if you have following line in your Model\ResourceModel\Module\Collection.php file:

protected $_idFieldName = 'module_id';

Not entirely sure about this, but I think the line:

<item name="indexField" xsi:type="string">posts_id</item>

should be

<item name="indexField" xsi:type="string">post_id</item>   

The value of the tag should be the pk of your entity's main table.

  • Nope that not the case
    – Jackson
    Aug 23, 2016 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.