Friday, February 3, 2017

SALESFORCE: Split Types

Error:
Validation Errors While Saving Record(s) There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "You do not have sufficient access to modify splits of this split type.


Solution:
Verify which fields are being used under Opportunity Split and set the correct permissions on that field.

1. Go to Setup->Customize->Opportunities->Opportunity Split->Settings
2. Check which fields are set to split
3. Go to the Opportunity object and set the correct security permissions for those fields

SALESFORCE: Permission Issues


Error:

"INVALID_FIELD: Select Id, Name from User Where ProfileId in ('') AND UserRoleId ^ ERROR at Row:1:Column:33 No such column 'ProfileId' on entity 'User'. If you are attempting to use a custom field, 
be sure to append the '__c' after the custom field name. Please reference your WSDL or 
the describe call for the appropriate names."

 
Solution:

Go to the Profile having the issue, and make sure "View Setup and Configuration" option is checked.

Monday, January 30, 2017

SUGARCRM: Package Deployment

Problem:

You get the following error when trying to deploy a new package from Admin:

"An error has occurred during deploying process, your package may not have installed correctly."

 Analyzing the logs, we get:

[FATAL] ERROR: rmdir_recursive(): argument  is not a file or a dir.

Solution:

Open config.php and make sure both group and user are set to the correct values.

array (
    'dir_mode' => 493,
    'file_mode' => 493,
    'user' => '',
    'group' => '',
  ),


 

Thursday, October 13, 2016

Salesforce: Obtaining Current User

Apex: 
Id userId = UserInfo.getUserId();
 
Visual Force Page:
{!$User.Id}
{!$User.FirstName}
etc. 

Tuesday, October 11, 2016

GIT: Creating Branches

git checkout -b branch_name

git push -u remote-name branch-name

git pull branch-name

Monday, September 26, 2016

SUGAR CRM: Retrieving Relationships Programatically in Logic Hooks

1. Create Logic Hook Trigger in your corresponding module (Assume this is a before_save trigger)
 
$hook_array['before_save'][] = 
 Array(     
       1,     
       'Some Description',     
       'custom/modules/<your_module>/<your_file_name>.php', 
       '<your_class_name>',     
       '<your_method_name>'
 );
   
2. Create class and logic

class <your_class_name>
{ 
   public function <your_method_name>($bean, $event, $args) 
   {         
      try         
      { 
         if (isset($bean->fetched_row['id'])) 
         {
             // Assume we're using documents
             $bean->load_relationship("documents");         
             foreach($bean->documents->getBeans() as $doc)
             {                     
                $GLOBALS['log']->fatal($doc->category_id);
             } 
         } 
      }              
      catch (Exception $ex) 
      {             
          $GLOBALS['log']->fatal($ex->getTraceAsString()); 
      } 
   } 
}
 
NOTE: Make sure you're retrieving the correct relationship name.
A common mistake is to grab the relationship name from Studio under
Admin. Try to obtain the relationship name from 
cache\modules\<your_module>\<your_module>vardefs.php

Finally, get the array name value not the relationship value:
'documents' => array  
(   
   'name' => 'documents', 
   'type' => 'link',   
   'relationship' => 'documents_opportunities', 
   'source' => 'non-db',   
   'vname' => 'LBL_DOCUMENTS_SUBPANEL_TITLE',
 ),
 
In this case we need "documents" and not "documents_opportunities"
for the relationship name. 

Wednesday, September 21, 2016

JavaScript: Replacing All Instances of a Character

Let's assume that we want to replace all hyphens with blank spaces.

We can either loop through the string character by character until we replace all hyphens,
or we can create a regular expression as follows:

var myStr = 'This-is-a-test';
var replacedString = myStr.replace(/-/g, ' ');
Where g represents a global match.