OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM Datagrid with query builder and bind parameters

This topic contains 10 replies, has 3 voices, and was last updated by  Benjamin 6 years, 6 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
  • #30744

    Benjamin
    Participant

    Hello guys,

    I need to display a custom entity datagrid in the customer datagrid.

    I used the query_builders parameters in datagrid configuration

    I tried to link a request parameter to it (Id of current customer) to pass it to the request but when I dump this parameter in the query I obtain the code of the datagrid(customer-reward-point-grid) and not the value of my request:

    Can someone help me?

    Thanks and have a nice day!

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

    Benjamin
    Participant

    I solve it: no need to specify the condition and the parameter in the query when using bind_parameters.

    But now I have another error:

    Getting grid data failed.
    Context: { “exception”: “Exception(Doctrine\\ORM\\Query\\QueryException): [Semantical Error] line 0, col 11 near ‘customer, crp.rewardPoint’: Error: Invalid PathExpression. Must be a StateFieldPathExpression.” }

    Anyone have an idea? I already had this error when using the query from the datagrid.yml (without the query_builders parameter).

    #30746

    dzakharov
    Participant

    Hi! Are you sure its valid name customer_id maybe when you rendering grid you use another name? For example try to use like:

    More information about parameter binding you can read in https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/DataGridBundle/Resources/doc/backend/parameter_binding.md

    #30747

    Benjamin
    Participant

    Hello dzakharov and thanks for the fast reply!

    I solved my parameter binding issue in my first post but now I have the error raised in my second post I don’t think it is related to the first one.

    #30748

    dzakharov
    Participant

    Also if you want to use datagrids without query_builders, you can try write like:

    Documentation with examples how use datagrids: https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/DataGridBundle/Resources/doc/backend/datagrid.md

    #30749

    Benjamin
    Participant

    Hello dzakharov,

    I read the data grids doc, at my first attempt I even applied the method in your last comment with datagrid without query_builders. I obtained exactly the same result as the error in my second post :

    Getting grid data failed.
    Context: { “exception”: “Exception(Doctrine\\ORM\\Query\\QueryException): [Semantical Error] line 0, col 11 near ‘customer, crp.rewardPoint’: Error: Invalid PathExpression. Must be a StateFieldPathExpression.” }

    So I tried to build my grid with the query_builders parameters…but now I have this error too with this configuration and I don’t know how to solve it.

    Thanks for your reply,

    Regards

    #30750

    jderdziak
    Participant

    Hello Benjamin,

    Are you able to provide full example that causing this error for you (so all Entities, current Repository and current grid configuration)?

    Regards
    Jakub

    #30751

    Benjamin
    Participant

    Hello jderziak,

    Thanks for your reply.
    Here it is:

    RewardPoint Entity:

    RewardPointCustomer Entity:

    Datagrid:

    CustomerRewardPointRepository used:

    I suspect a misconfiguration in my entity in the relation with oro customer entity.

    Again thanks for taking your time for this!

    #30752

    jderdziak
    Participant

    Hello Benjamin,

    Looks like your entity primary key is causing error:

    As a walkaround you may remove this primary key (use UNIQUE instead) and create normal “id” field.

    In the meantime I’ll try to find out if it’s a correct behavior.

    #30753

    jderdziak
    Participant

    Hello again!

    I’ve confirmed this is a bug, but since it’s not recommended to create Primary Key from reference columns, it has quite low priority and I’m not able to predict how fast the fix will be implemented.

    Regards
    Jakub

    #30754

    Benjamin
    Participant

    Hello jderdziak!

    Thanks for your help!

    I will create a normal Id field then!
    I will open an issue but I agree with you it should be a low priority since it’s not the best practice to do it.

    Have a great week!

    Regards

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

The forum ‘OroCRM’ is closed to new topics and replies.

Back to top