From alexander.allenz at gmail.com Sun May 24 15:16:04 2026 From: alexander.allenz at gmail.com (Alexander Allen) Date: Sun, 24 May 2026 09:16:04 -0600 Subject: [Vtigercrm-developers] Error on vtiger 8.4 Webservice utils In-Reply-To: References: Message-ID: I just fix it doing this, putting the id 0 when creating the Lineitems public function constructFocusObject($element) { $focus = CRMEntity::getInstance($this->getMeta()->getTabName()); $fields = $focus->column_fields; foreach($fields as $fieldName => $fieldValue) { $fieldValue = $element[$fieldName]; if(is_array($fieldValue)) { $focus->column_fields[$fieldName] = $fieldValue; } else if($fieldValue !== null) { $focus->column_fields[$fieldName] = decode_html($fieldValue); } } // paaz ?? Solo asignar id si existe y es v?lido ?? if (!empty($element['id'])) { $ids = vtws_getIdComponents($element['id']); $focus->id = $ids[1]; } else { $focus->id = 0; } return $focus; } On Tue, Jul 22, 2025 at 11:04?AM Rub?n A. Estrada Orozco wrote: > I suspect it is not the invoice_id causing the problem. If you share the > print_r output it would be easier to help you figure it out. > > On Mon, Jul 21, 2025 at 1:25?PM Alexander Allen < > alexander.allenz at gmail.com> wrote: > >> Its correct, but at that moment I dont have a invoice_id. My concern is >> that with vtiger 8.3 it works fine. And the difference between 8.3 and 8.4 >> in the code is that. >> >> >> El vie, 18 jul 2025 a las 20:07, Rub?n A. Estrada Orozco (< >> rulotec1 at gmail.com>) escribi?: >> >>> You should do a print_r of the whole $data array to see the actual >>> contents. You have a $productos variable in the LineItems element. Since >>> the error is here "Stack trace: #0 >>> /vtiger/include/Webservices/LineItem/VtigerInventoryOperation.php(469)" I >>> suspect it's one of your line items that's causing the problem. >>> >>> You could also do a print_r of the $element parameter in >>> VtigerInventoryOperation::constructFocusObject($element) >>> >>> [image: image.png] >>> >>> On Fri, Jul 18, 2025 at 6:02?PM Alexander Allen < >>> alexander.allenz at gmail.com> wrote: >>> >>>> Is in line_items. Id is the invoice id but in invoice creation there is >>>> not an id until its created. >>>> >>>> >>>> >>>> >>>> On Fri, 18 Jul 2025 at 5:57?PM Rub?n A. Estrada Orozco < >>>> rulotec1 at gmail.com> wrote: >>>> >>>>> I presume that the id you are passing as a parameter might be empty. >>>>> >>>>> It seems the change in code aimed at validating the input parameter >>>>> passed to the function. I would change the exception message to: >>>>> >>>>> throw new WebServiceException(WebServiceErrorCode::$INVALIDID,"Id >>>>> specified is incorrect ->" . print_r($elementid, true) . "<-"); >>>>> >>>>> and see what gets printed out. But my guess would be an empty >>>>> $elementid. >>>>> >>>>> On Fri, Jul 18, 2025 at 11:52?AM Alexander Allen < >>>>> alexander.allenz at gmail.com> wrote: >>>>> >>>>>> I'm trying to create an Invoice from webservice. I can create as >>>>>> example products but the error is when it loads lineitems. This is part of >>>>>> my code: >>>>>> >>>>>> include_once 'include/Webservices/Create.php'; >>>>>> $data = array ( >>>>>> 'subject' => 'Pedido', >>>>>> 'productid' => '14x23683', >>>>>> 'ship_street' => $direccion, >>>>>> 'ship_state' => $cliente, >>>>>> 'currency_id' => $moneda, >>>>>> 'account_id' => $clientId, >>>>>> 'invoicestatus' => 'Cancel', >>>>>> 'assigned_user_id' => $propietario, // 19=Users Module ID, 1=First >>>>>> user Entity ID >>>>>> 'LineItems'=>$productos, >>>>>> >>>>>> ); >>>>>> vtws_create('Invoice', $data, $current_user); >>>>>> >>>>>> I get this error >>>>>> *Fatal error*: Uncaught WebServiceException: Id specified is >>>>>> incorrect in /vtiger/include/Webservices/Utils.php:127 Stack trace: #0 >>>>>> /vtiger/include/Webservices/LineItem/VtigerInventoryOperation.php(469): >>>>>> vtws_getIdComponents('') #1 >>>>>> >>>>>> I found that vtiger changes function vtws_getIdComponents in >>>>>> include/Webservice/Utils.php from this: >>>>>> >>>>>> function vtws_getIdComponents($elementid){ >>>>>> return explode("x",$elementid); >>>>>> } >>>>>> >>>>>> to this: >>>>>> >>>>>> function vtws_getIdComponents($elementid){ >>>>>> $elementid = (string)$elementid; >>>>>> >>>>>> if ($elementid && is_numeric($elementid)) return >>>>>> array($elementid); // during (UserId permission check) >>>>>> >>>>>> >>>>>> if (!$elementid || !preg_match("/[0-9]+x[0-9]+/", $elementid)) { >>>>>> throw new WebServiceException(WebServiceErrorCode::$INVALIDID,"Id >>>>>> specified is incorrect"); >>>>>> } >>>>>> >>>>>> return explode("x",$elementid); >>>>>> } >>>>>> >>>>>> Does someone know why this change has made or is an error? >>>>>> >>>>> _______________________________________________ >>>>>> http://www.vtiger.com/ >>>>> >>>>> _______________________________________________ >>>>> http://www.vtiger.com/ >>>> >>>> _______________________________________________ >>>> http://www.vtiger.com/ >>> >>> _______________________________________________ >>> http://www.vtiger.com/ >> >> _______________________________________________ >> http://www.vtiger.com/ > > _______________________________________________ > http://www.vtiger.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 74021 bytes Desc: not available URL: