Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Performing webservice calls using validation
#1
I would like to perform webservice calls, but run the system validations when doing so. I remember we had special way of running the validations when performing webservices, but couldn't find it in the docs.
Reply
#2
https://corebos.com/documentation/doku.php?id=en:devel:corebosws:methodreference#validations_create_update_and_revise_with_validations
Joe
TSolucio
Reply
#3
Nice, couldn't find that through the search method in the wiki
Reply
#4
So this is not working for me. I refactored my webservice call from:
PHP Code:
$client->doCreate('Assets'$params); 
to
PHP Code:
$client->doInvoke('CreateWithValidation', array('elementType' => 'Assets''element' => json_encode($params))); 
But that just created the asset, while I was using a duplicate serial no., which I prohibit in my custom validation function:
PHP Code:
function isUniqueSerial($fieldname$fieldvalue$params$entity) {
    global 
$adb;
    
$recordid $entity['record'] == '' $entity['record'];
    
$r $adb->query("SELECT vtiger_assets.serialnumber
                        FROM vtiger_assets
                        INNER JOIN vtiger_crmentity ON vtiger_assets.assetsid = vtiger_crmentity.crmid
                        WHERE vtiger_assets.product = 
{$entity['product']}
                        AND vtiger_assets.serialnumber = '
{$entity['serialnumber']}'
                        AND vtiger_assets.assetsid != 
{$recordid}
                        AND vtiger_crmentity.deleted = 0"
);
    return 
$adb->num_rows($r) > false true;

Reply
#5
check if your function is being called and dump the parameters to see if the query is correct
Joe
TSolucio
Reply
#6
What query? Ah you mean the validation query. I already spot the issue. The validation receives webservice ID's, where when inside the application, it receives non-webservice regular ID's.
Reply
#7
great. adapt your code accordingly
Joe
TSolucio
Reply
#8
Done, works like a charm now, thanks for the help
Reply
#9
great!
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)