Menu
SuiteCRM dedicated support by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: Refresh / Reload a field

Refresh / Reload a field 6 days 23 hours ago #75201

  • robert_sinclair
  • robert_sinclair's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 0
Hello

I have a logic hook that changes a field's value, but in order to see the change I need to refresh the whole page... I want it to refresh the field in real time.

So I'm trying to accomplish something like this(suitecrm.com/suitecrm/forum/suitecrm-7-0...nel-is-updated#75194)

But instead of reloading a whole subpanel through the controller.php I'm trying to find a way to refresh a single field.

Can anyone advise what method needs to be used to reload a field?

For example to reload a subpanel it's

showSubPanel('SUBPANEL_NAME',null,true);

But what is the JS method that refreshes a single field?
The administrator has disabled public write access.

Refresh / Reload a field 6 days 3 hours ago #75243

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8555
  • Thank you received: 1307
  • Karma: 311
Maybe for a single field you can just grab the value and put it in the field with your own Javascript.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Refresh / Reload a field 6 days 1 hour ago #75254

  • robert_sinclair
  • robert_sinclair's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 0
Yep, it's a good idea, I'm just concerned if it will be upgrade safe in case the markup ever changes in the future and it's not the same setup (unlikely but still)
The administrator has disabled public write access.

Refresh / Reload a field 6 days 1 hour ago #75255

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8555
  • Thank you received: 1307
  • Karma: 311
The markup shouldn't be a problem, it is based on field names, for example the "Department" field:
<div class="col-xs-12 col-sm-8 detail-view-field inlineEdit" type="varchar" field="department">
    <span class="sugar_field" id="department"></span>
    <div class="inlineEditIcon col-xs-hidden">
        <span class="suitepicon suitepicon-action-edit"></span>
    </div>
</div>

This is genericly generated HTML, coming from tpl files (templates) with loops for each field.

Of course, to be upgrade-safe you need to make sure the actual overriding the view to inject HTML is done in an upgrade-safe way.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
The following user(s) said Thank You: robert_sinclair

Refresh / Reload a field 5 days 21 hours ago #75272

  • robert_sinclair
  • robert_sinclair's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 0
Figured out how to do it from the controller.php when a new subpanel item is added.

Here's the whole controller.php and the 5 minute video that explains what's actually happening:


class un_inventoryController extends SugarController {

    /**
     *
     */
    function action_SubPanelViewer() {



    require_once 'include/SubPanel/SubPanelViewer.php';


// only if this is creation of new sale under accounts, refresh the screen so the salerow subpanel will be refreshed too
if ( array_key_exists('module', $_REQUEST) && array_key_exists('subpanel', $_REQUEST) && array_key_exists('action', $_REQUEST) &&
$_REQUEST['module'] == 'un_inventory' && $_REQUEST['subpanel'] == "un_inventory_leads_1" && $_REQUEST['action'] == "SubPanelViewer") {


    write_to_log(array("request" => $_REQUEST), "all conditions filled, custom controller called", true);

    // Get the ID of the inventory unit so we can fetch the new status_c field and update the field right away (otherwise we'll have to refresh the page

    $inventory = BeanFactory::getBean($_REQUEST["module"], $_REQUEST["record"]);
    $inventory_status_c = ucwords(str_replace("_", " ", $inventory->status_c));
    $field_to_update = "status_c";

    $js=<<<EOQ
<script>

    // Update the status
    $( document ).ready(function() { 
                
        document.querySelector('div[type="enum"][field="$field_to_update"]').innerHTML = "$inventory_status_c";
        
    });


</script>
EOQ;

    echo $js;


    }

}
}

?>
Last Edit: 5 days 21 hours ago by robert_sinclair.
The administrator has disabled public write access.
The following user(s) said Thank You: pgr

Refresh / Reload a field 5 days 5 hours ago #75286

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 8555
  • Thank you received: 1307
  • Karma: 311
Great video, once again! The only part I don't like is the title mentioning that old thing called "SugarCRM" ;)

Since you're doing these videos, I notice you probably don't have XDEBUG set up and connected to your PHP Storm? If you don't, you really should. Sometimes it's a pain to set up, especially for remote debugging, but it's really worth the trouble, it's a game changer for development.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
The following user(s) said Thank You: robert_sinclair

Refresh / Reload a field 5 days 51 minutes ago #75310

  • robert_sinclair
  • robert_sinclair's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 0
Thanks I'll check it out! Already ended up buying phpstorm thanks to your advice! :)
The administrator has disabled public write access.
Time to create page: 0.078 seconds
Powered by Kunena Forum