Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sometimes the save method takes an admin user as current user
#1
I frequently use the 'save' CRMEntity method to alter records through AJAX calls. This way we can easily track (through the 'view history' button) who did what at what time. I also use it in my custom webservice methods. No harm there, but sometimes the user swtiches to myself (because I am the first available admin user). This seemd to be regardless of the user doing the actual change: sometimes the user stays intact, sometimes it changes, even though he is on the same profile as other users, where this does not happen. Am I missing some rights management here?
Reply
#2
It is rather odd as the application usually does try to keep the user connected in order to maintain that history information. That said I am sure that there are places where we check for the current_user variable and if it is not set we will pick the first admin user we find which would adapt to the case you describe.

Does this happen only with the custom webservice? Can you reproduce the issue consistently?
Joe
TSolucio
Reply
#3
No, it doesn't only happen when from webservices, also when I save records through workflows and for instance in my Schedular module through an AJAX call. Haven't found any common things yet, but I'll keep an eye open and report back.
Reply
#4
Strange. Can you share the URL of the AJAX call?
Joe
TSolucio
Reply
#5
Well this is one of the webservice calls, no real standard URL's since they are all custom:

PHP Code:
    $worksheet json_decode($_REQUEST['data'], true);

    
$hdnGrandTotal number_format($worksheet['data']['mandatoryFields']['mand_hdnGrandTotal'], 2","".");
    
$hdnSubTotal number_format($worksheet['data']['mandatoryFields']['mand_hdnSubTotal'], 2","".");

    
$params = array(
            
'id' => $worksheet['data']['id'],
            
'sostatus' => $worksheet['data']['newStatus'],
            
'subject' => $worksheet['data']['mandatoryFields']['mand_subject'],
            
'contact_id' => $worksheet['data']['mandatoryFields']['mand_contact_id'],
            
'account_id' => $worksheet['data']['mandatoryFields']['mand_account_id'],
            
'bill_street' => $worksheet['data']['mandatoryFields']['mand_bill_street'],
            
'ship_street' => $worksheet['data']['mandatoryFields']['mand_ship_street'],
            
'hdnGrandTotal' => $hdnGrandTotal,
            
'hdnSubTotal' => $hdnSubTotal,
            
'assigned_user_id' => $worksheet['data']['mandatoryFields']['mand_assigned_user_id']
        );

    
// Add custom fields to params, if any
    
if (count($worksheet['data']['customFields']) > 0) {
        foreach (
$worksheet['data']['customFields'] as $cf_no => $value) {
            
$params[$cf_no] = $value;
        }
    }

    
$client->doInvoke('createWorkSheetHTML',
                        array(    
'id'             => $worksheet['data']['id'], 
                                
'autograph'     => $worksheet['data']['signature'],
                                
'lines'         => json_encode($worksheet['data']['materials']),
                                
'autogr_name'    => $worksheet['data']['autogr_name'],
                                
'times'            => json_encode($worksheet['data']['times'])
                                ),
                        
'POST');

    
// Convert materials to a string
    
$materials '';
    foreach(
$worksheet['data']['materials'] as $material) {
        
$materials .= $material['qty'] . ' X ' $material['desc'] . ', ';
    }
    
$params['cf_968'] = $materials;

    
$r $client->doUpdate('SalesOrder'$params); 

And here is an event listener for after a relation has been created, that does some specific functions on the related module record. Sometimes this related record gets related to me, sometimes it doesn't...
Reply
#6
I don't see any obvious reason why the user would change there.

More or less what commit are you on in that install? I remember we changed a user override in the workflows but that was a LONG time ago.
Joe
TSolucio
Reply
#7
This install is probably around a year old, maybe older...
Reply
#8
I searched for the fix and found it September 2015. That was a while back!!

commit 6f132cedb61223db8b0dc5cc14ade9d0d5df3a0a
Author: Omar Llorens <omar@tsolucio.com>
Date:   Thu Sep 17 15:00:40 2015 +0200

So I suppose this isn't your issue.

I would suggest activating debugging and adding a log->fatal of current_user in the CRMEntity->save() function to see when it changes
Joe
TSolucio
Reply
#9
Then I suppose that's not the issue. The weird thing is, when I click the 'view history' link for the affected records, I see the original change I made done by the correct user, and right after that I see another change (always about ten seconds interval) where the users gets switched to me, and that's the only action... Maybe some forgotten workflow...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)