Results 1 to 8 of 8

Thread: Parent's field in listview

  1. #1
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Parent's field in listview

    Hi. i tryed to get some parent field usiong action_listview.php with some query.
    Code:
    function action_ListView()
    {
    $this->view = 'list'; 
    $GLOBALS['view'] = $this->view; 
    
    global $db; 
    $query = "select (CASE WHEN c.priority='P0' THEN s.slacrireshw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltreshw ELSE (CASE WHEN c.priority='P2' THEN s.slamedreshw ELSE s.slabaireshw END) END) END) as slareshw, " .
             "(CASE WHEN c.priority='P0' THEN s.slacriressw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltressw ELSE (CASE WHEN c.priority='P2' THEN s.slamedressw ELSE s.slabairessw END) END) END) as slaressw, s.description, " .
    		 "ADDTIME(SUBTIME(c.date_entered,'03:00:00'), (CASE WHEN c.type='Software' THEN (CASE WHEN c.priority='P0' THEN s.slacriressw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltressw ELSE (CASE WHEN c.priority='P2' THEN s.slamedressw ELSE s.slabairessw END) END) END) ELSE (CASE WHEN c.priority='P0' THEN s.slacrireshw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltreshw ELSE (CASE WHEN c.priority='P2' THEN s.slamedreshw ELSE s.slabaireshw END) END) END) END)) as vencimento " .
    		 "from sup_contratosuporte s, sup_contratuporte_cases_c cstm, cases c where s.id=cstm.sup_contra8d4esuporte_ida and c.id=cstm.sup_contra20a5escases_idb and c.deleted=0 and cstm.deleted=0 and s.deleted=0 and c.id= '" . $this->bean->id . "'";
    $result = $db->query($query, true);
    while($row = $db->fetchByAssoc($result))
    {
    $this->bean->sup_contratosuporte_cases_sla_critico_resolucao_hw = $row['slareshw'];
    $this->bean->sup_contratosuporte_cases_sla_critico_atendimento_hw = $row['slaressw'];
    $this->bean->sup_contratosuporte_cases_descricao = $row['description'];
    $this->bean->data_vencimento = $row['vencimento'] ;
    }
    
    
    }
    this in controller.php

    it works for editview. how can i get it working for listview either?
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Parent's field in listview

    I believe you may need to use views instead for this and in view.list.php iterate through the returned results from Sugar's list query and merge in the results from your query.

    At least, that's what I could recall from something similar just a few days. I could be off though.

  3. #3
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Parent's field in listview

    Jason suggestion may works, but the best place to accomplish such feature is the logic_hook process_record.

    Best regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  4. #4
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Re: Parent's field in listview

    Hi!
    with logic hook i can use query as well?
    how can i do this with logic hook?
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  5. #5
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Re: Parent's field in listview

    I tryed this:

    Code:
    <?php
    // Do not store anything in this file that is not part of the array or the hook version.  This file will	
    // be automatically rebuilt in the future. 
     $hook_version = 2; 
    $hook_array = Array(); 
    // position, file, function 
    //$hook_array['process_record'] = Array(); 
    $hook_array['process_record'][] = Array(3,'dtvenc', 'modules/Cases/CaseLogicHook.php','CaseLogicHook', 'dtvenc'); 
    
    
    
    ?>
    Code:
    <?php
    
     if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
    
    class CaseLogicHook { 
        function dtvenc(&$focus, $event, $arguments) { 
    global $db;
    	$query = "select s.name from cases s where s.id= '" . $this->bean->id . "'" ;
              $result = $db->query($query,true);
            //$row = $db->fetchByAssoc($result);
    
    		$focus->data_vencimento = $result;
    		$focus->sup_contratosuporte_cases_descricao = $result;
    }
    }
    ?>
    It's bringin me this:
    Attached Images Attached Images  
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  6. #6
    ashishmathur is offline Senior Member
    Join Date
    Aug 2008
    Posts
    37

    Default Re: Parent's field in listview

    you have commented fetch record statement and directly assigned record set to variables

    //$row = $db->fetchByAssoc($result);
    $focus->data_vencimento = $result;
    above should be replaced by

    $row = $db->fetchByAssoc($result);
    $focus->data_vencimento = $row['name'];

  7. #7
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Re: Parent's field in listview

    thanks! it works just fine know!
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  8. #8
    mel0 is offline Junior Member
    Join Date
    Dec 2009
    Posts
    4

    Default Re: Parent's field in listview

    Hello , i'm new at SugarCrm and i need some help ... i read the solution and i don't know what $focus->sup_contratosuporte_cases_descricao = $result;
    represent ...can you please explain how it works ? ... i want to display in ListView a new field with the phone value that is in another module

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Display parent's field on detail view
    By kinshibuya in forum Developer Help
    Replies: 14
    Last Post: 2009-07-14, 03:26 PM
  2. all phones in one field in listview
    By zaska in forum Help
    Replies: 1
    Last Post: 2009-05-07, 03:33 PM
  3. clickable field in ListView
    By zaska in forum Help
    Replies: 6
    Last Post: 2009-03-19, 09:09 PM
  4. Replies: 0
    Last Post: 2009-01-27, 04:44 AM
  5. Add a field in subpanel listview
    By fjhuerte in forum Help
    Replies: 5
    Last Post: 2008-08-28, 08:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •