Showing posts with label Salesforce. Show all posts
Showing posts with label Salesforce. Show all posts

Thursday, 4 August 2016

Unmanaged package & GitHub repo to get LEX Opportunity progress bar inside Salesforce Classic



With reference to my previous post "Replicate Lightning Experience Opportunity Progress Bar into Salesforce Classic UI" , since people are asking for easy way to replicate this, I am going to provide an unmanaged package to help people get this beautiful view at a click away.
Step #1
XperienceProgressBarForSalesforceClassic
Version 1.3

Use this URL to install the package into any organization:
https://login.salesforce.com/packaging/installPackage.apexp?p0=04t90000000NOPH 
Note: If you are installing into a sandbox organization you must replace the initial portion of the URL withhttp://test.salesforce.com
Step #2
Click Install button.

Some post-installation steps are identified below to help you get going.
Step #3
After installation, edit your Opportunity page layout to add a one column Section with '.'(a dot) as its name just above detail section as shown in screen shot below.

Step #4
Drag and drop this VF page "Slds_OpportunityProgressBar_Page" inside the added section.

Step #5
Set the VF properties(width= 100%; height=80) by clicking on wrench icon as shown in image below.

Step #6

Save your page layout to get the view as shown in this image.
Quite simple. Isn't it?   :)
Note: This is designed exclusively for Opportunity stage field. However it can be tweaked to get it working for other objects as well.
Get to the source code repository @GitHub         http://bit.ly/2aTa3pl 

Friday, 15 January 2016

Simplifying Salesforce.com Security Model pictorially

This blog is a small step to amalgamating the different aspects of Salesforce Security Model by displaying how Record Access is defined in an org. This security model is an important area to understand while building a Salesforce application.

**Please note that these info are consolidated from various Salesforce webinars so that some important concepts can be tracked at a single place in a lucid manner. This could be primarily helpful for the beginners to have a 360 degree view of security settings.



                        












                 


             

               


     

               

In Short or At a Glance, you can refer the below two images.

     

So, referring the image below, the approach should firstly look at the foundation which is Object CRUD(controlled by Profiles) and then move upwards following horizontally through OWD, Role Hierarchy, Sharing Rules, Manual Sharing, Apex Sharing.



Please note that these info are consolidated from various SFDC webinars so that the important concepts can be tracked at a single place.

Happy Salesforce.com Evangelism..  

Thursday, 17 December 2015

You have reached the maximum number of 10 object references on ObjectName

We all love using Spanning Relationships(or Cross-Object References) while creating Formula Field, Validation Rules, Workflow Rules, Lookup Filters. Don't we?  


However there is a caveat which we should keep in mind before using it; and that is, "Salesforce allows a maximum of 10 unique relationships per object in cross-object formulas".
Some of you may agree with me here. I was very much uncomfortable in comprehending this limit. However I found this excellent Salesforce knowledge article which simplifies the way one should look at this limit.



                              Sharing the link here:  Understanding Spanning Relationships

Monday, 14 December 2015

How to deal with: "System.TypeException: Cannot have more than 10 chunks in a single operation" in SFDC

In one of the interfaces, I designed and developed, between SFDC & SAP/PI, there was once incident where an end user encountered that her pricing agreement is not pushed to SAP.
When I looked into the Integration Logger object, I find this error message for the first time.


"Cannot have more than 10 chunks in a single operation. Please rearrange the data to reduce chunking.StackTrace:: Class.SfdcSapPricingInterface_Async.execute: line 2120, column 1"





When you go and look into SFDC document related to preparing list of SObjects, you will find that SFDC enforces a governor limit on the way it chunks different data types in the list<SObject>. Subsequently the number of data types that can be DML operated is limited to 10.


The order of the items in this list seems to play a part in the 'chunking'. It chunks everytime you switch object types.


Let's consider an example here. Keeping the same number of items in the list, If you are passing 12 items in a list of types A and B, this list contains 2 chunks:

          A, A, A, A, A, A, B, B, B, B, B, B  (which will not exceed this limit)

But this list contains 12 chunks:

          A, B, A, B, A, B, A, B, A, B, A, B  (which will exceed this limit)


You can find multiple solutions to this issue on the community forums et al. However I think a simple solution is this issue can be this:

     Just before your DML statement, sort your list of SObject:

               listSObjects.sort()
               insert/update listSObjects ;

This will align data of one type at one place together and other data type at other place. So in fact the chunking is now defined by number of data type present in list of SObject which can at max be 10.


Happy Apex coding   :) 

Friday, 30 October 2015

Brief Steps To Setup "Force.com Continuous Integration"

Continuous Integration may help in following ways:

  • Maintain a code repository
  • Automate the build
  • Make the build self-testing
  • Everyone commits to the baseline every day
  • Every commit (to baseline) should be built
  • Keep the build fast
  • Test in a clone of the production environment,ie., sandbox
  • Make it easy to get the latest deliverables
  • Everyone can see the results of the latest build
  • Automate deployment


Software Requirements


1. ANT
2. Force.com Migration Tool
3. Git
4. Eclipse
5. Jenkins war file

Set up environment variables for Git(/bin), JDK(/bin), ANT(/bin)


ECLIPSE  <------>  BITBUCKET

Step 1: Add the components in your Force.com project

Step 2: Configure Local Repository

Team --> Share Project --> Create --> Local Repo Name and Location --> Finish button --> Question mark '?' on folders (Git doesn't know what to do with files because they are not indexed) --> Add Index to the componenet you wnat to commit --> Cross mark 'x' on folders --> Commit --> Cylinder mark on indexed folders.

Step 3: Create Bitbucket remote repository. Get the repo URL.

In Eclipse, go to GIT perspective --> Get all local repository --> under Remote, Create Remote --> Select Configure Push --> Ok button --> Change button --> Git repo URL --> Username, Password --> Check Store in Secure Store --> Finish button --> On parent window, click Add --> In new window, Local branch and Remote Branch to "refs/heads/master" or "ctrl+space bar" --> Ok --> Dry Run --> Save and Push to move changes from local repository to remote repository.

BITBUCKET  ------>  JENKINS   --------> Target SFDC INSTANCE


Step 1: Go to http://localhost:8080/

Step 2: New Item (Freestyle project)

Sep 3: Manage Jenkins --> Manage Plugins --> Check/Install GitBucket plugin --> Check/Install Chatter Notifier plugin --> Check/Install Release plugin

Step 4: Select your project --> Configure  --> SCM : Git --- Provide Bitbucket repo URL and Credentials --- Specify branch to build (*/master  OR refs/tags/DEV)  --> Build Triggers : Build when a change is pushed to BitBucket  OR  Build periodically  --- Invoke ANT   --> Post-build Actions : Chatter results

Step 5: Set up web hooks in bitbucket

Go back to your Jenkins main page, click on “People” link in the sidebar
In the People page, click on our newly created account’s entry
Click on the “Configure” link in the sidebar
Under “API Token”, click on the “Show API Token” button and copy that token.

Under the repository’s admin page, click on “Services” at the sidebar:
Choose “Jenkins” from the “Select a service…” drop-down and click on “Add Service”.

Endpoint: http://bitbucketusername:apitoken@yourjenkinsurl.com/
Project name: Jenkins project name
Token:Authentication token from Jenkins
Module name: (Optional)


For more info, let's collaborate in here.  :)

Tuesday, 27 October 2015

Considerations for Approval Process: Field updates don’t evaluate custom validation rules on fields


Requirement
I came across one scenario where the requirement was to prevent an approval process field update action when a Credit/Debit record is in Invoiced status though the record is still in the approval process.

Background
When a Credit/Debit record is submitted for approval process, there may be scenario where the approver may be on leave or may delay in approving that request. In the meantime, SAP, an external integrated system, can make an update on this record by invoicing the data even without any approval notification from Salesforce.com to SAP.

Actions taken
I thought of keeping a validation rule to prevent the approver from making any change if the record is invoiced from SAP.
However this didn't happen because of this simple fact below.

Facts
One of the considerations for Approval Process is "Field updates don’t evaluate custom validation rules on fields". So in this case, a custom validation rule won’t fire inside an approval process.

To be continued..
The search for some other workaround is ON..  

Friday, 16 October 2015

Scheduling Batch Job To Run Every N-Minutes in Salesforce.com


Have you ever wondered or come across scheduling batch job to run every N-Minutes( for example 1 minute or 5 minutes)?
Yes, I have! Since this is not possible to do thru standard Salesforce UI.

Sometimes  in order to do so, we go for scheduling multiple times; for example 11 times if it has to be scheduled every 5 minutes. Here is the next question: Can't it be done in a single scheduling attempt? Yes, it can be. The next is the solution..  


So here is a small code to do so for every 5 minutes. You can customize your logic for every N_minutes. You can execute this piece of code in developer console as well.

DateTime myDateTime = System.Now() ;
System.debug('Sudhir myDateTime:: ' + myDateTime) ;


static Integer iHour = myDateTime.hour() ;

System.debug('Sudhir iHour :: ' + iHour) ;

static Integer iMinute = myDateTime.minute() ;
System.debug('Sudhir iMinute:: ' + iMinute) ;

static Integer iSecond = myDateTime.second() ;
System.debug('Sudhir iSecond:: ' + iSecond) ;

for(Integer i = 0; i < 60 ; i = i + N){ 
    if(iSecond > 59){
        iSecond = 0 ;
    }  
  if(iMinute > 55){
        iMinute = 0 ;
        iHour = iHour + 1 ;
    } else{
        iMinute = iMinute + N ;
    }
    String sExpression = String.valueOf(iSecond) + ' ' + String.valueOf(iMinute) + ' ' + '*' +  ' ' + '*' + ' ' + '*' + ' ' + '?' + ' ' + '*' ;
    System.debug('Sudhir sExpression:: ' + sExpression) ;

     ScheduledBatchJob_APIName oScheduledBatchJob_APIName = new ScheduledBatchJob_APIName () ;
     System.schedule('Comment for Scheduled batch Job' + '-' + i, xpression, oScheduledBatchJob_APIName) ;
}








Happy Apex coding and sharing..