SugarCRM fetching data from outside REST service to subpanel - rest

I'm trying to create subpanel in Account detail view where list of elements is fetched from external REST service.
I know how to define subpanel, but have no idea how to fill it with data from external network source. Was trying to use get_subpanel_data but there I can only change SQL.
Any ideas how can I do this?

When I've done this in the the past, at least with Sugar 6, I opted distinctly not to try to create a true subpanel. The data being loaded is coming from an outside source and is loaded dynamically with the page, so why present it as if it's static data coming from Sugar? Instead, I created a custom Smarty template to use as the footer on the detail page. For such an example, you can check how it works on the Calls Edit View. I think it's the footerTpl parameter in the detailviewdefs.php or editviewdefs.php. I loaded the smarty template by creating a custom detail view for my module, so custom/modules/MyModule/views/view.detail.php - extend the base Detail View class and override the display to feed Smarty new params, then your Smarty template only needs to iterate through and present the data that your view defined.
To be super-hip and abide by MVC, you could even put your custom code into your bean (if it's a custom module) or into a custom controller method, then reference that from the view.detail.php, and still feed it from there to the Smarty template.
Alternatively, you could just load JavaScript into the Smarty template and use the JavaScript to call the third-party service, parse and present it, etc.

I realize this question is a little bit old now however it comes up fairly often so why not provide an answer with a couple possible solutions. I won't get into code but more just into the design theory of how it can work. If someone needs more specific code help then that is another question.
A couple ideas...
As you mentioned you can define a custom Function which will load in Data to the SubPanel from your own SQL Query. That is one method that I just recently got to finally put to use after knowing about it for a good year and a half.
When you go this route, you are restrained to using the Columns in the SubPanel. I assume it is using the actual Metadata files to determine which Field Columns a SubPanel can use so you pretty much need your custom data in a Database table to have the same column names as the fields defined in the SubPanel Metadata.
Obviously this works great in the right situation, however not always and that leads us into the 2nd method I know of.
The other way is pretty much what #Mattew-Poer mentioned in his answer. It means abandoning the SubPanel altogether and instead generating your own HTML. This is by far my favorite and prefered way of doing it and I have been some really custom modules due to this being possible in a custom module! I will show an example below.
(Click HERE to View full size image)
In the screenshot, you can see in this example that I have something looking Similar to a SubPanel however it is not and is much for flexible and easy to customize.
Example, to the far left column in my fake subpanel is image checkboxes. When clicked on, an AJAX request is made to change the Task row Status.
After that, the checkbox image is updated to indicate the new Status state, the Modified DateTime is updated, the Status column has color background SPANS and is also updated with the correct text and background color when the left side checkbox is clicked.
Doing any of this with the standard SubPanels is a complete nightmare and would be difficult to do some of the stuff that you are open to do when you build your own version of a SubPanel.
With that said, I have built an identical clone of the above screenshot using SugarCRM default SubPanels! It was a nightmare. I could easily update the content and HTML in some of the columns. I even had the AJAX click checkbox image to update and do all the other updates I mentioned above. It wasn't too hard and worked fairly good but it had some issues.
When you do inline edit, inline create record, or subpanel paging to load different set of record. You would then lose all the custom HTML formatting that was applied. The reason is, in the SubPanel you are limited to using the After UI load logic hook. So since the "Page" is loaded already, when an AJAX request is made to add/edit the subpanel content or load a new set of items with the paging links. It only loads the SubPanel content on those events and the whole Page content does not reload. Because the logic hook only fires off 1 time after the page loads, this newly loaded subpanel data doe not receive any of your custom HTML formatting.
In my case, this means that nice looking colored background Status spans are lost, the image checkboxes are lost, and some other functionality is lost.
Now to get super technical, I could have gone another 3rd route and instead made new Custom Field Types for each SubPanel filed that I needed to apply custom HTML to. This process is super hard in my experience and in some cases it really isn't the BEST solution.
Because of the reason explained, this is why my new modules use the Custom HTML route to generate my own version of a custom subpanel or whatever Data is needed in my Module pages! So far it is working better than I imagined and has opened doors for me to build custom SugarCRM modules that I previously didn't even realize would be possible to build due to some of the issues I mentioned above. Now I bypass them altogether and open the door to do pretty much anything!
I've got some really cool stuff for SugarCRM in the works right now. If anyone has any questions feel free to ask in a new question or for me personally in a comment here.

Related

Realtime datatable with asp.net core web app , EF core and SignalR

I want to retrieve data from Sqlserver database with EntityFramework core and do crud operations and show data table to client without refreshing the page (Realtime) , is there any source or example in this case ?
Not sure there is a definitive source for this, but it's not that hard to build yourself.
It should be relatively straight forward. In general you'd need
A model for the grid that defines the properties to show and edit, and also which row is selected.
An HTML Helper to change the rows from read-only to editable
A view to display the table.
An [edit] action link for each row enables you to select a row by ID for editing, and after clicking it, reloads the page and then the view can respond accordingly to change the type of the row from read-only to editable.
You could use Blazor or maybe Ajax to change a row from read-only to editable without refreshing the page, but I'm not sure if you need to meet certain requirements that discard using either of them.
John Ciliberti has written a recipe for a book, that works just like I described, find it on his Github page to get some ideas of what's involve.
If you need a more out-of-the-box solution, perhaps consider wiring up DataTables.js.

SYMFONY FORM - filter attribute form on top with submit button, that provides a table with other form used to edit each row details

I am looking for best practices on SYMFONY FORM handling to achieve the following standard page (surprisingly I haven't found anything similar existing yet on SO).
Here is a shema of what I want to achieve:
As you can see at the top there is a SYMFONY FORM to filter the results that should be displayed.
It displays a table and each tuple of the table should permit to open another SYMFONY FORM kind linked to the tuple.
I am in the process of learning SYMFONY FORM, so far, I can manage to create the top row FORM to set the filter that'll apply to the table display.
But I wonder if anyone has experience on the second part: Displaying the table that embed as well many forms of a similar kind -That seems a bit more complex. I read about TWIG.EXTENSION and FORM.COLLECTION, I'll investigate that. But if someone could save me to re-invent the wheel and lead me to some direct shortcut, I'd be really grateful.
No idea if it's the best practice, but one way to do it would be to create a new property for your entity being listed in this table, called $editionForm (without mapping it to the database) for example.
Then, either throught a custom loop or by listening to a doctrine (or any ORM you use) hydration event (or triggering such an event if you don't use any ORM), fill the property with the generated form, probably within a dedicated service.
Then, just use it in your template like this :
$entity->getEditionForm()->render()

web2py autocomplete widget not working

need a hint on web2py built-in autocomplete widget.
in controller:
db.otc_products.counterparty.widget = SQLFORM.widgets.autocomplete(request, db.counterparty.Long_Name, limitby=(0,10), min_length=2)
in model:
db.define_table('otc_products',
Field('counterparty','reference counterparty',
widget = SQLFORM.widgets.autocomplete(request, db.counterparty.Long_Name, id_field=db.counterparty.id,
limitby=(0,20), min_length=2 )),
...
db.define_table('counterparty',
Field('Long_Name'),
...
The resulted sqlform.grid returns a grid which features the counterparty field to be a regular table field instead of a widget, let alone autocompelete widget.
What is the configuration that needs to modify here to get a autocomplete widget shown and work.
thanks in advance!
check link above for a snapshot of tge grid.
The .widget attribute of a Field object produces the HTML form input element used for the field in forms created via SQLFORM. The grid is for displaying values stored in the database, not for editing those values. The display of a given field in the grid is therefore determined by the field's .represent attribute, not by the .widget attribute.
As you have mentioned in your comment above, you can use a form widget within the .represent attribute, and the grid will then display the widget. However, in both your model and controller code above, you have set the .widget attribute of the counterparty field rather than the .represent attribute.
In any case, there is really no point to using form widgets within the grid itself, because the grid provides no mechanism for making inline updates to records via those widgets (i.e., you will be able to select/input values in each widget, but you will have no way to submit the changes so they will be persisted in the database).
In theory, you could build your own inline editing functionality on top of the grid (via Javascript that reads the values from the inputs and posts the updated records to the server via Ajax). But this functionality is not built into the grid.
The grid does provide a way to edit individual records. If you configure the grid to be editable, each row will include an "Edit" button, and when you click it, you will be taken to an edit form on a separate page. That edit form will make use of any widgets you have defined, including the autocomplete widget you have configured in your code.
For web2py and stackoverflow communities and the sake of completeness, developer who is leveraging this framework and streamlining the web development:
the sqlform.grid can be secondarily developed to extend its capacity in some ways, just need to be very familiar with the underlying .py files which is open source and modifiable to meet your needs.
folks have posted solutions like below, with this one can in-line edit a gird, which provides convenient editing as well as comparing between sql records, the sql tables can be managed thru the grid with greater transparencies without jumping back and forth for an edit:
http://www.web2pyslices.com/slice/show/1928/basic-inline-editing-in-sqlformgrid-no-plugin-no-javascript
p.s.: I am utilizing web2py for faster development for a financial firm, so there is really no time for me to extend this framework to unclock additional functionalities, like the one above. when I do have some free time, if there is actual development need, I will extend web2py for particular requirement, and post the code on the web.

Using overlayButtons on FusionCharts with javascript links

I would like to use a javascript function link such as 'link:j-myJS-data' for drill down type charts. I have everything working great to drill down but cannot figure out how to incorporate the overlayButton through the configureLink when drilling down. At present, I can drill down but cannot go back. Can anyone provide a basic example of how I may go about this? Is it even possible?
I thought I could add my own "Back" button to hande this as one option. I do not want to use a jsonURL as there is a lot of data and many paramertes need to be passed resutling in a long links and a lot of extra data in the JSON.
Thanks in advance.
There are multiple options available to create a drill-down chart with FusionCharts XT. Here is a table which explains all of them, with each one's syntax.
The method that you've used is the JavaScript function link. Using this one, you won't get an overlay button to go back to the parent chart.
The overlay button is available only when a LinkedChart is created.
So there are 2 ways that you could go about:
You could change all your charts to use the LinkedCharts technique. Here is a blog post detailing how LinkedCharts can be created using PHP + MySQL. If you aren't using PHP, the general idea shown still applies to any server-side environment.
You could create a separate button sitting near the chart, and this button would re-create the parent chart for you.
The button (which we call "overlay-button") can be made automatically visible using LinkedCharts alone.
However the overlay-button can be internally invoked using the charts' private API. Since these APIs are private, it may change between implementations and may not work as desired under certain circumstances. I would not recommend you to use this. If you are still interested in knowing more on this API, put in a comment and I will update this post.

ACCESS 2010 Navigation Form Query Property

I'm coming accross a problem and i have searched the entire World Wide Web:
I have a Navigation form which has forms in it.
Those forms are used to give properties to my queries.
For example:
FormStatus-->Ask user to select the status and shoot the value to the query.
These queries build reports.
The main problem is that now that my form is in a navigation form, the link for the property is no longer working.
The link used to be : Forms!myForm!myProperty
Now i tried
Forms!navigationForm!myForm!myProperty
Me!myForm!myProperty
Forms!ParentForm!SubForm.Form!FieldName
Nothing works out!! Can anybody help me?
As a general approach to filtering forms or reports, as you can see placing forms! references inside of forms becomes a rather messy business real fast here.
You are best to remove the forms! references from ALL your queries. You then build a form that the user enter the values into, and then execute a browseto command.
The problem you are experiencing here is that the new navigation form swaps out a given form for a new form. This means that the old form is NOT loaded anymore. So, either you
Plan A
Dump use of forms! commands in your SQL queries. This is a good idea anyway since then one query will not blow up because some silly form is not open. And more important the query can be used in other places in the application without fear of some form not being opened.
The instant you place a forms! reference inside of a query is the instant you ruin that query and force "marry" that query to one form that must be opened.
Plan b:
Dump the use of the new navigation control system. Just remember, the new navigation system does NOT load the next form, but "replaces" the one that is being displayed. Thus the previous form is not going to be loaded anymore and thus no forms! ref is allowed. Worse, since the navigation form is really using sub-forms, then the forms! references have to be changed.
You can certainly grab the values of controls and build a where clause in code and use that for openform or open report commands here.
Last but not least, if you in for lots of continued torture, you can stick with your poor design you have now and simply re-edit and fix all of the forms! references to reflect that they are now being used inside of a parent form, and all of your forms are now in effect being run as sub forms.
Try using a dot instead of ! before the property Forms!navigationForm!myForm.myProperty