Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to limit field access throuhg workflow
My validation suddenly started to work! I think it was a caching issue. That has tripped me before...

One catch: When you try to change the status my custom validation does not allow certain groups to change, and then cancel (because you were not allowed to), you're not able to change any other field. If you start out by editing a field (let's say an address) you're fine. But once you've tried to change a non-allowed field the screen value changes and stays like that, so after that you'd have to reload the page to be able to change the address again. Here's the code:
PHP Code:

global $log,$currentModule,$adb,$current_user;

$screen_values json_decode($_REQUEST['structure'],true);

$q "SELECT vtiger_groups.groupname FROM vtiger_groups INNER JOIN vtiger_users2group ON vtiger_groups.groupid = vtiger_users2group.groupid WHERE vtiger_users2group.userid = ?";
$p = array($current_user->id);
$r $adb->pquery($q$p);

$groups = array();

while (
$groupname $adb->fetch_array($r)) {
$groups[] = $groupname['groupname'];

$q "SELECT sostatus FROM vtiger_salesorder WHERE salesorderid = ?";
$p = array(vtlib_purify($screen_values['record']));
$r $adb->pquery($q$p);
$current_status $adb->query_result($r0'sostatus');

if (!
in_array('Debitoradministration'$groups) && $current_status == 'Waiting for payment' && $screen_values['sostatus'] != 'Waiting for payment') {
'You are not allowed to change the status from \'Waiting for payment\'';


Field value and groupname are translated into english for clarity. I also checked this by using the JS console:

 Returns "Approved" (in this case, because I tried changing the order status to that). If the value in JS memory would be set to the actual screenvalue (so what you see) when a user clicks 'cancel' this behaviour would not happen.

Messages In This Thread
RE: Trying to limit field access throuhg workflow - Guido1982 - 11-04-2016, 08:06 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)