Results 1 to 9 of 9

Thread: problem in showing DetailView of custom module

  1. #1
    MahsaN is offline Senior Member
    Join Date
    Jul 2010
    Posts
    58

    Default problem in showing DetailView of custom module

    Hi

    I have a custom module which name is invoicemaster and in the invoicemaster.php file I override the save function and at the end of save function return the id which was saved in table but when I click the save button in editview .I can not see detailview , instead I see the error below:

    Error retrieving record. This record may be deleted or you may not be authorized to view it.

    the code which is written in save function is:
    HTML Code:
    function save($check_notify = FALSE){
    $GLOBALS['log']->debug("Mahsa: in the save function");
    			$p_id = $GLOBALS['current_user']->account_id;
    			$customtype = $this->customtype; 
    			$GLOBALS['log']->debug("Mahsa : customtype".$customtype);
    			$sex = $this->sex;
    			$religion = $this->religon; 
    			$status = $this->status ; 
    			$billingdate = $this->billingdate; 
    			$shippingdate = $this->shippingdate;
    			$phone = $this->phone;
    			$shippingaddress_city = $this->shippingaddress_city; 
    			$shippingaddress_postalcode = $this->shippingaddress_postalcode;
    			$shippingaddress_country = $this->shippingaddress_country;
    			$shippingaddress_subway = $this->shippingaddress_subway; 
    			$shippingaddress_street1 = $this->shippingaddress_street1;
    			$shippingaddress_street2 = $this->shippingaddress_street2;
    			$shippingaddress_street3 = $this->shippingaddress_street3;
    			$shippingaddress_alley = $this->shippingaddress_alley;
    			$region = $this->region ;
    			$description = $this->description;
    		  $this->db->query("BEGIN", true , "Error in begining the transaction");
    		  $this->db->query("START TRANSACTION" , true , "Error in starting transaction");
    		  $GLOBALS['log']->debug("Mahsa : account id = ".$GLOBALS['current_user']->account_id);
              $query = "SELECT last_invoice_id FROM accounts WHERE id = '18b18262-8e93-6b47-b720-4c1d9e13352b'";
              $result = $this->db->query($query,true,"Error in finding invoice id");
              $row = $this->db->fetchByAssoc($result);
              $last_invoice_id= $row['last_invoice_id'];
              $last_invoice_id +=1;
    		  $GLOBALS['log']->debug("Mahsa : last invoice id = ".$last_invoice_id);
              $query = "UPDATE accounts SET last_invoice_id = '".$last_invoice_id."' WHERE id = '18b18262-8e93-6b47-b720-4c1d9e13352b'";
              $result = $this->db->query($query, true , "Error in updating account table");
    		  $GLOBALS['log']->debug("Mahsa the result of update the table :".$result);
              if( $this->db->mysql_error){
            
                $this->db->query("ROLLBACK", true , "Error in Rolling back");
              }
              else
              { 
              	$id = create_guid();
                $GLOBALS['log']->debug("Mahsa: else statement before insert query");
              	$query = "INSERT INTO np_invoicemaster ( id , name , customtype , sex , religion ,status , billingdate ,shippingdate , phone ,
              	shippingaddress_city , shippingaddress_postalcode , shippingaddress_country , shippingaddress_subway ,
              	shippingaddress_street1 , shippingaddress_street2 , shippingaddress_street3 , 
              	shippingaddress_alley , region , description )VALUES( '$id' , '$last_invoice_id', '$customtype' , '$sex' , '$religion' ,
              	'$status' , '$billingdate' , '$shippingdate' , '$phone' , '$shippingaddress_city' ,
              	'$shippingaddress_postalcode' , '$shippingaddress_country' , '$shippingaddress_subway' ,
              	'$shippingaddress_street1' , '$shippingaddress_street2' , '$shippingaddress_street3' ,
              	'shippingaddress_alley' , '$region' , '$description')";
              	$result = $this->db->query($query, true ,"Error in inserting data into invoice master table");
    			$GLOBALS['log']->debug("Mahsa : the result of inserting in invoice master".$result);
    			$this->db->query("COMMIT" , true);
    			
              }
    		  $GLOBALS['log']->debug("Mahsa : the id is =".$id);
             return $id;
    			 
    		}
    So...what should i do?

  2. #2
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: problem in showing DetailView of custom module

    Hi,

    Do you see record ID when you are redirected to detail view?
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  3. #3
    MahsaN is offline Senior Member
    Join Date
    Jul 2010
    Posts
    58

    Default Re: problem in showing DetailView of custom module

    hi

    when i checked the $id in return id in my save function I can see the value.
    but it is not in address bar and at the end of url I see: record=

  4. #4
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: problem in showing DetailView of custom module

    Hi,

    I can see you have used debug to fill log file, do you have the ID in that?
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

  5. #5
    MahsaN is offline Senior Member
    Join Date
    Jul 2010
    Posts
    58

    Default Re: problem in showing DetailView of custom module

    yes.
    i have it.

  6. #6
    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: problem in showing DetailView of custom module

    Quote Originally Posted by MahsaN View Post
    yes.
    i have it.
    Please, attach the whole php script containing the function save you created.

    Cheers
    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.

  7. #7
    MahsaN is offline Senior Member
    Join Date
    Jul 2010
    Posts
    58

    Default Re: problem in showing DetailView of custom module

    ok.
    this is my whole php code inNP_ InvoiceMaster.php file and it is attached in this post.
    PHP Code:
    <?PHP
     
    require_once('modules/NP_InvoiceMaster/NP_InvoiceMaster_sugar.php');
    class 
    NP_InvoiceMaster extends NP_InvoiceMaster_sugar {
        
        
    //.....Mahsa...///////////////
        
    var $np_payment_header_id;
        
    //...........//////////////////
        
    var $np_good_id;
        function 
    NP_InvoiceMaster(){    
            
    parent::NP_InvoiceMaster_sugar();
        }
        
        function 
    save($check_notify FALSE){
           if( 
    $this->is_issue == FALSE)
           {
                   return 
    parent::save();
           }
           else
           {
                
                
    $GLOBALS['log']->debug("Mahsa: in the save function");
                
    $p_id $GLOBALS['current_user']->account_id;
                
    $customtype $this->customtype
                
    $GLOBALS['log']->debug("Mahsa : customtype".$customtype);
                
    $sex $this->sex;
                
    $religion $this->religon
                
    $status $this->status 
                
    $billingdate $this->billingdate
                
    $shippingdate $this->shippingdate;
                
    $phone $this->phone;
                
    $shippingaddress_city $this->shippingaddress_city
                
    $shippingaddress_postalcode $this->shippingaddress_postalcode;
                
    $shippingaddress_country $this->shippingaddress_country;
                
    $shippingaddress_subway $this->shippingaddress_subway
                
    $shippingaddress_street1 $this->shippingaddress_street1;
                
    $shippingaddress_street2 $this->shippingaddress_street2;
                
    $shippingaddress_street3 $this->shippingaddress_street3;
                
    $shippingaddress_alley $this->shippingaddress_alley;
                
    $region $this->region ;
                
    $description $this->description;
              
    $this->db->query("BEGIN"true "Error in begining the transaction");
              
    $this->db->query("START TRANSACTION" true "Error in starting transaction");
              
    $GLOBALS['log']->debug("Mahsa : account id = ".$GLOBALS['current_user']->account_id);
              
    $query "SELECT last_invoice_id FROM accounts WHERE id = '18b18262-8e93-6b47-b720-4c1d9e13352b'";
              
    $result $this->db->query($query,true,"Error in finding invoice id");
              
    $row $this->db->fetchByAssoc($result);
              
    $last_invoice_id$row['last_invoice_id'];
              
    $last_invoice_id +=1;
              
    $GLOBALS['log']->debug("Mahsa : last invoice id = ".$last_invoice_id);
              
    $query "UPDATE accounts SET last_invoice_id = '".$last_invoice_id."' WHERE id = '18b18262-8e93-6b47-b720-4c1d9e13352b'";
              
    $result $this->db->query($querytrue "Error in updating account table");
              
    $GLOBALS['log']->debug("Mahsa the result of update the table :".$result);
              if( 
    $this->db->mysql_error){
            
                
    $this->db->query("ROLLBACK"true "Error in Rolling back");
              }
              else
              { 
                  
    $id create_guid();
                
    $GLOBALS['log']->debug("Mahsa: else statement before insert query");
                  
    $query "INSERT INTO np_invoicemaster ( id , name , customtype , sex , religion ,status , billingdate ,shippingdate , phone ,
                  shippingaddress_city , shippingaddress_postalcode , shippingaddress_country , shippingaddress_subway ,
                  shippingaddress_street1 , shippingaddress_street2 , shippingaddress_street3 , 
                  shippingaddress_alley , region , description )VALUES( '$id' , '$last_invoice_id', '$customtype' , '$sex' , '$religion' ,
                  '$status' , '$billingdate' , '$shippingdate' , '$phone' , '$shippingaddress_city' ,
                  '$shippingaddress_postalcode' , '$shippingaddress_country' , '$shippingaddress_subway' ,
                  '$shippingaddress_street1' , '$shippingaddress_street2' , '$shippingaddress_street3' ,
                  'shippingaddress_alley' , '$region' , '$description')"
    ;
                  
    $result $this->db->query($querytrue ,"Error in inserting data into invoice master table");
                
    $GLOBALS['log']->debug("Mahsa : the result of inserting in invoice master".$result);
                
    $this->db->query("COMMIT" true);
                
              }
              
    $GLOBALS['log']->debug("Mahsa : the id is =".$id);
             return 
    $id;
            }     
            }


    }
    ?>
    Attached Files Attached Files

  8. #8
    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: problem in showing DetailView of custom module

    At the else clause you have the id hardcoded ('18b18262-8e93-6b47-b720-4c1d9e13352b'). Is that exactly what you want?
    If this is what you really want so you have to set $id as this hardcoded id.

    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.

  9. #9
    MahsaN is offline Senior Member
    Join Date
    Jul 2010
    Posts
    58

    Default Re: problem in showing DetailView of custom module

    No that's not the id which i want.
    at the last ELSE statement I have a insert query , and i created the id of table myself with create_guid() . after inserting new record in table i want to return the id of that record to show data in detailview.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Account module Detailview problem
    By Coonen in forum Help
    Replies: 2
    Last Post: 2009-01-07, 04:07 PM
  2. detailview problem in own custom module
    By rraushan2007 in forum Developer Help
    Replies: 1
    Last Post: 2008-08-30, 09:27 AM
  3. detailview problem in custom module
    By rraushan2007 in forum Developer Help
    Replies: 3
    Last Post: 2008-08-30, 04:49 AM
  4. Problem on Case DetailView on custom field
    By Pdor in forum General Discussion
    Replies: 3
    Last Post: 2008-07-01, 02:37 PM
  5. Replies: 0
    Last Post: 2007-11-21, 12:08 PM

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
  •