How to create a new report operator?

I need to create a new operator in Sugar, is that possible??

  • Unfortunately Reports module doesn't support upgrade safe customizations like that. You may create it by editing several core files, so you may need to redo the job unce upgrading your instance.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • As Andre suggested, there is no upgrade safe route, and mostly it's not a good idea to spend time customizing it.

    But - if you really realllyy need it - there is an non-upgrade safe route and I can give a few suggestions on how we did it, which is not as easy or straightforward as other Sugar customizations.

    1. The main file in the UI that you're looking for is include/javascript/reports.js -

    • Look for addFilterQualify function - this is where the operators are added.
    • You may also want to modify addFilterInput to define how it's displayed.
    • And as part of saveFilters, generate the filter definition that you need from the fields.

    2. Implement the query generation part for your filter in modules/Reports/Report.php - look out for register_field_for_query or filtersIterate functions.

  • I have just looked at a different post that more or less do what I need but when I select the new filter the input  datetime input does not display , does anyone knows about extra field displaying besides of option dropdown. 

    https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/1439/adding-an-older-than-x-days-filter

    Rodrigo Manara

    Sr. Developer

  • I have done the change but I cannot see the input displaying on the form, I have spent few days trying to find out where this trigger but there's something on the code that qualify the field to have a new entry and not hide the field , do you know how to do that ?

    Rodrigo Manara

    Sr. Developer

  • Did you try modifying the function

    addFilterInput: function(htmlTableCell, filter, rowId)

    There you may want to add your own logic on how to display the field:

    if (filter.qualifier_name == '#_test_days_ago') {
    SUGAR.reports.addFilterInputText(row,filter);
    }
  • Yes, I have change the field name, so it does not go into the "tp_" condition

    Rodrigo Manara

    Sr. Developer

  • Hello Rodrigo,

    May I ask you what task enforces adding a new operator?

    Cheers,
    Dmytro

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

  • this is for any reports, but I manage to add it on BWC reports. 

    Rodrigo Manara

    Sr. Developer

  • Can you share your code changes?

    If you have the filter/qualifier name with "n_days", it should automatically go into the previous logic which displays input text box.

    if (qualifier_name.indexOf("_n_days") != -1) {
    SUGAR.reports.addFilterInputText(row, filter);
    SUGAR.reports.addRunTimeCheckBox(row, filter, rowId);
    }