OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions Datagrid: select ids that are not part of another select from the same table

This topic contains 10 replies, has 2 voices, and was last updated by  Mike Kudelya 7 years, 4 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #36363

    bosumflici
    Participant

    Hi,

    I want to build a datagrid that selects all users who have not been updated in a date interval. Something like this:

    SELECT u1.id, u1.username FROM oro_user u1 WHERE u1.id NOT IN (SELECT u2.id FROM oro_user u2 WHERE u2.updatedAt BETWEEN ‘2016-07-01’ AND ‘2016-11-30’)

    Can i write a datagrid.yml to do this? I do not figure out how to write the condition!!!

    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Author
    Replies
  • #36364

    Mike Kudelya
    Participant

    Hi

    I think subselect is not necessary.

    datagrid.yml:

    #36365

    bosumflici
    Participant

    Thanks Mike! Above i did not choose the best example to describe my problem.

    I have a table with resources and a table with events related to those resources. What i need is a datagrid filled with all resources that do not have events that do not overlap with a time interval.

    So, with standard select i would write:

    I did it this way:

    So this is DONE.

    Next i implemented a workflow to select start and end dates in the first step, and in the second step i extended oro_multiple_entity to use with the above grid in the 2nd workflow transition. The problem appears after i choose the rows from datagrid widget, which have to be added to the form field after pressing the <select> button. They render fine on the view, but when i submit the form it says “This value should not be blank.”
    After digging a while i figured out that it does not sets the ids to the hidden form element to be saved (oro_workflow_transition_offer_resources_added)!!!
    If i press on “x” it removes those coresponding ids from the view and also sets the ids to the hidden form element to be removed after submit. (oro_workflow_transition_offer_resources_removed)

    Do you have any idea why is this happening and how to fix it?!

    Thanks!

    #36366

    bosumflici
    Participant

    I’ve found the missing code:

    Thanks!

    #36367

    bosumflici
    Participant

    Back :(

    Can you help me setting initial_elements of the oro_multiple_entity in a workflow step? I cannot figure it out!!!

    #36368

    Mike Kudelya
    Participant

    Hi

    Can you give me workflow config, templates so that i can emulate you case. Screenshots would be very useful. Can you give me more information, what do you want to achieve? What is wrong ?

    #36369

    bosumflici
    Participant

    This is my workflow config:

    This is my type config:

    First step in workflow is to create a new entity (offer). This is where i give a name and the time interval (start/end):
    workflow create transition
    After that it redirects to the entity view:
    entity view

    Second step in the workflow is to select related entity records using a custom oro_multiselect_entity, with datagrid filtered by previous start and end date (datagrid config can be seen in above posts):
    oro_multiselect_entity
    As you see in the picture there are no records added.

    Then i press <+Add> to add records:
    datagrid selection
    Here i select the first two records and add them to the form.
    added to form
    And finally i save them, redirect to the entity view page and can be seen in the datagrid:
    final view

    The problem appears when i go back one step, where i have to select new records/deselect currently selected. Previously selected records does not appear on the form so i can remove them.
    oro_multiselect_entity
    Also if i press the <+Add> button to open the grid, they do not appear as selected in the grid:
    oro_multiselect_entity

    I’d appreciate if you could help me with this issue.
    Thanks!

    #36370

    Mike Kudelya
    Participant

    Hi

    I found the way how to resolve the problem. I want to show here code which you probably wrote and new, which fixed the problem. Here is example how i added contacts to my opportunity entity.

    I modified filters transition, main idea – give opportunity id to controller (custom_oro_contact_grid):

    Here is action (it returns list of contact ids which will be selected on grid):

    Action template:

    Here is my contact grid:

    and last thing, custom multiple entity type (it is printing saved contacts on page):

    #36371

    bosumflici
    Participant

    Thanks Mike!

    Giving id to the controller fixed the problem. What i’ve encountered next is that when i apply a filter to the datagrid, in a workflow step, i get:

    Catchable Fatal Error: Argument 1 passed to Doctrine\DBAL\Connection::resolveParams() must be of the type array, null given, called in /var/www/html/crm-application/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php on line 836 and defined in /var/www/html/crm-application/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php on line 1524

    Outside of the workflow datagrid filters works fine. Any idea what could cause this?

    #36372

    bosumflici
    Participant

    My bad here, i was sending a datetime value, instead of a date.

    Tnank you!

    #36373

    Mike Kudelya
    Participant

    Hi

    It is strange, i have modified contacts-grid and all works fine. Maybe you forgot set value (or column type) to binded parameter.. Try to make grid as easy as possible, to understand what is wrong. Here is my filters:

Viewing 10 replies - 1 through 10 (of 10 total)

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top