-1

I need to fetch data from external server using custom REST API and show the data in list view and detail view.(custom Module).

I am completely new to Suitecrm. Need to know that when I click on module name how could Fetch data and where to write action, which files to be created and so on.

What is to be used is it connector or end point or else?

Versioning-

SuiteCrm-Version 7.10.7

Sugar Version 6.5.25 (Build 344)

I tried on internet but no specific example found

Community
  • 1
  • 1

1 Answers1

1

What you are looking for are called Logic Hooks.

Those hooks exist inside each module and will be fired on different cases.

For listview / detail view you need process_record hook.

Go and create a file custom/Extension/modules/Accounts/Ext/LogicHooks/ListViewHighlight.php

If you are using a custom module, change Accounts for the name of the module and remember this function is executed for EACH record on the list.

Content will be:

<?php
$hook_array['process_record'][] = Array(1, 'Highlight account industry', 'custom/modules/Accounts/HighlightIndustryLogicHook.php','HighlightIndustryLogicHook', 'highlightIndustry');

That is for setting up the hook, the following file should contain the code executed custom/modules/Accounts/HighlightIndustryLogicHook.php

<?php
class HighlightIndustryLogicHook{

    public function highlightIndustry(SugarBean $bean, $event, $arguments){
        $colour = substr(md5($bean->industry),0,6);
        $bean->industry = "<div style='border: solid 5px #$colour;'>".$bean->industry."</div>";
    }
}

In this example, this hook will override the industry value and add in the styling we want.

Now, if you DON'T want to use SuiteCRM list view, let's say you want a totally customized view, then you should read this guide.

https://docs.suitecrm.com/developer/views/#_custom_module

mrbarletta
  • 902
  • 11
  • 17
  • I have my contacts on external server. Where should I call my api in code to fetch those contacts ( when I click on my module name , then list view will appear, at that time my all contacts should appear) I have created custom module using module builder. – Pravin Pokharkar Aug 27 '19 at 11:28
  • Added some details in case you want your own view – mrbarletta Aug 27 '19 at 13:43
  • I dont want my own view am using same view given by suitecrm. In which file I need to write API. If you have any code similar written by you or anyone else? please show. – Pravin Pokharkar Aug 28 '19 at 04:44