How to call after_ui_frame Logic Hook in SuiteCRM 8 like we did in the SuiteCRM 7.x Version?

I would like to Hide some fields of the Module on Detailview based on the value in the particular Record. For Example, In Contacts Module, If the Lead Source is Equal To the Website then Hide the Office Phone Field in the Detail view using jQuery through Logic Hook.

1 Like

I think that’s one of the pages that are still “under construction” here…

SuiteCRM 7 hooks should work fine in SuiteCRM 8 because they’re back-end. But I guess that those UI frame hooks are the exception since they affect front-end, and the front-end has changed for some modules (not all!) in SuiteCRM 8.

Hi @Urvi,

Thank you for trying out SuiteCRM 8.

As @pgr mentioned the docs are still being built.

The section on how to do this has already been written, its just under review at the moment.

However, I can give a quick intro that may help.

In SuiteCRM 8 there is a new concept called Field Logic. It allows to one or more logic rules attached to a field, at the moment we have:

  • displayType - allows to change the field display type (hide/show, make read only) depending on other fields
  • required. allows to make the field required or not, depending on other fields

Other logic type can be added through the frontend extensions.

You can add that in the vardefs or in the detailviewdefs by adding a logic config entry, something like:

 'priority' => array(
            'name' => 'priority',
            'vname' => 'LBL_PRIORITY',
            'type' => 'enum',
            'options' => 'case_priority_dom',
            'len' => 100,
            'audited' => true,
            'comment' => 'The priority of the case',
            
            // new part
            'logic' => [
                'display' => [
                    'key' => 'displayType',
                    'modes' => ['detail', 'edit', 'create'], // modes to to apply in
                    'params' => [
                        'fieldDependencies' => [
                            'state', // fields that priority depends on
                        ],
                        'targetDisplayType' => 'none', // the display type that priority should change to
                        'activeOnFields' =>  [
                            'state' => [ 'Closed']  // the values of state that trigger the change
                        ]
                    ]
                ],
                
            ]
        ),

Hope this helps

2 Likes

I don’t want to Hide/Show or make the field mandatory using vardefs. I want to do some process after the page completely load like we did in the previous versions of SuiteCRM 7.x using after_ui_frame Logic Hook

1 Like

I am also facing the same issue.

Hi @Urvi,

Sorry, I probably misunderstood. So what is it that you would like to do?

The after_ui_frame Logic Hook is deprecated in SuiteCRM 8 views. The angular front end engine works as an SPA, so this logic hook doesn’t really make sense, from the SPA perspective. This now needs to be done on the front end.

Hi @clemente.raposo
please help me know How we can do in the front end which we did use after_ui_frame logic hook in SuiteCRM 7.x Version

This is a blocker for a decent number of add-ons out there. It would be great for the ecosystem to have documentation with examples of what could be done previously (e.g. cover each hook type) and how you can accomplish that in the new framework.

What is the after_ui_hook mostly used for, do you know?

I suspect it’s probably the preferred way to inject custom Javascript into screens, so maybe that’s the question we should be asking @clemente.raposo is - how to inject custom JS into the Angular front-end?

BTW, I find this current way to inject JS very fragile, I have a bunch of lines in my hooks just to prevent JS from getting injected into all sorts of requests that aren’t screens (they’re Ajax calls or others).

I think you are right on. From what I’ve seen, most cases it’s to insert HTML into the DOM and/or add javascript functions. Doing it via the front-end should do the trick. Would jsGroupings be one way to do this? How would one avoid being injected on non-screen calls, etc?

hi
yes it works .
but i am facing a problem ( hide and show not working properly ‘like when option is empty’)
this is my code:

$dictionary["con_ContactLog"]["fields"]["esd_dates_con_contactlog_1esd_dates_ida"] = array (
  'name' => 'esd_dates_con_contactlog_1esd_dates_ida',
  'type' => 'link',
  'relationship' => 'esd_dates_con_contactlog_1',
  'source' => 'non-db',
  'reportable' => false,
  'side' => 'right',
  'vname' => 'LBL_ESD_DATES_CON_CONTACTLOG_1_FROM_CON_CONTACTLOG_TITLE',
  'logic' => array (
    'display' => array (
        'key' => 'displayType',
        'modes' => array ('detail', 'edit', 'create'),
        'params' => array (
            'fieldDependencies' => array (
                'type_of_contact',
            ),
            'targetDisplayType' => 'none',
            'activeOnFields' =>  array (
                'type_of_contact' => array ('','PhoneCall', 'Email', 'TextMessage', 'InPerson', 'VideoCall')
            )
            ),
    ),
  )
);