Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Update a record through vtlib within app
#3
Ok, what I have so far:

PHP Code:
global $adb$current_user;

$query 'SELECT salesorderid FROM vtiger_salesorder WHERE salesorder_no=?';
$params = array('ORD3199');
$result $adb->pquery($query$params);
$so_crm_id $adb->query_result($result0'salesorderid');

$so CRMENtity::getInstance('SalesOrder');
$so->retrieve_entity_info($so_crm_id'SalesOrder');

$so->column_fields['sostatus'] = 'Ingepland';
$so->column_fields['duedate'] = '2016-07-28';
$so->mode 'edit';

$handler vtws_getModuleHandlerFromName('HelpDesk'$current_user);
$meta $handler->getMeta();
$so->column_fields DataTransform::sanitizeForInsert($so->column_fields,$meta);
$so->column_fields DataTransform::sanitizeTextFieldsForInsert($so->column_fields,$meta);

$so->save('SalesOrder'); 

Some variables have been filled out with dummy values, but you get the idea. I now get a fatal error:

Code:
Fatal error: Call to a member function FetchRow() on a non-object in {SERVER_PATH}/public_html/crmdevelop/include/database/PearDatabase.php on line 893

Caused by the save method...

(07-28-2016, 09:46 AM)joebordes Wrote: You can do what is said in the wiki, the page you found is more or less correct, but it is much easier to use the webservice interface. Exactly as I recommended with the create:

https://github.com/tsolucio/corebos/blob/master/build/HelperScripts/importcsv.php#L62

you can use vtws_update or vtws_revise to update a record.
update requires ALL fields to be passed in, at least all mandatory fields while revise will only update the fields you give it with no validations.

it is easier than having to retrieve, sanatize and save

let me know how it goes

Same time-reaction here... When I use the webservice way, how do I identify which record I want to update? Add the crmid to the '$row' array?
Reply


Messages In This Thread
RE: Update a record through vtlinb within app - Guido1982 - 07-28-2016, 09:50 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)