Showing posts with label sfdc. Show all posts
Showing posts with label sfdc. Show all posts

Friday, 17 January 2014

Use Tab Color Dynamically on VF page from JS.





Hi guys,

I am writing this post because recently i used it and feel must share it,

Here I am creating a VF with some colored arrow on page (Created by using CSS) and color of arrows automatically changes according to the color and style of the Custom-Tab,

This requirement is mainly needed when you are creating a detail VF page

Now magic is to use arrow color same as the Tab color of your object.

I achieved this using Javascript and CSS,

Here is the VF page code:-


Screen Shots:


Now, i just changed Tab Style and color by following these steps:-

Setup -> Create -> Tabs -> Custom_Object__c

Here is the new Tab style and color:-


arrows and highlighted section color changes automatically.


Hope it will help u guys, Happy Coding....:)

Monday, 6 January 2014

Genrate Bar Codes from UPC or SKU by REST API.







Hi friends,

By this post I’ll show how to save Bar Code in Salesforce by using UPC code,

I call web service of third party which gives the image of Barcode (by using REST Api’s) and that image is Saved in the Notes and Attachment of Product.

Here the Sample code for same:-

Screen Shots:-







Tuesday, 17 December 2013

Show Radio Button on the VF page


Hi Guys,

here the example to show the Radio buttons on the VF Page and toggle between them,

Controller Class And VF Page:-


this is the screen shot of the VF page.

Tuesday, 26 November 2013

Shows Standard Salesforce Report Chart to Standard Salesforce Sidebar.





Hi guys,

   I’m writing this post because it may be the requirement of your clients and their is not direct way to show chart on Standard sidebar of salesforce.

This is actually the new type of requirement form one of my client, he wants to see the report chart on every page of its salesforce account, so solve it in this way to put chart on sidebar and show make visible the sidebar on every page.

Basically i opens an "iframe" on the html of Home Page Components.

So here the steps:
1.      Create a Report chart according to you requirements, make sure that this chart is of Tiny in size so that it can easily come in sidebar window.
2.      then go to Setup > Customize > Home > Home Page Components > Custom Components > New,
then choose the “HTML Area” then next and selects Narrow(Left) Column, click on show html check box on the right  corner and put the following code in it:

<iframe src="https://cs14.salesforce.com/Report_Id" scrolling="no" height="620px" width="150%" style="margin-top: -445px; margin-left: -70px;"/>
 
3.      Now add this component to the home page layout
(Note: make sure you assigned the page to the profile in the Home Page Layout.)
Now you can see that report chart is showing to the home page side bar as,

If you want to show it on every page then,
Go to Setup > Customize > User Interface > Sidebar
then true the “Show Custom Sidebar Components on All Pages” check box and save it,

That’s it, now the report chart is showing on every page of you Salesforce where sidebar is visible as:

Happy Coding…:)

Thanks,
Anurag Jain,



Friday, 22 November 2013

Run Once logic for avoiding multiple or recursive calling of trigger in Salesforce


             
Hi guys,
This is my first blog, so please correct my if I am wrong somewhere,
Here the simple but tricky question asked in many interviews of salesforce because it’s a common scenario comes many times that’s why I’m writing this,

Suppose you have to update a record in a trigger with after update event then what happens???

Here example:
trigger updateAccount on Account (after update) {
     List<Account> accList = new List<Account>();
     for (Account a : Trigger.new) {
        // some logic……
        //…………………………….
          accList.add(a);
     }
     update acclist;
}

If you execute the above code then, the trigger is recursively called and thoughts exception
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateAccount: maximum trigger depth exceeded 

Because you trying to do updation in trigger which is also updating same record so it called itself again and again and again upto its limit,

Here the solution of this problem,
1         1.  Make a public class.
2      2.    In that class take a static Boolean variable.
3      3Then create a static method, which has if statement which returns true first time only.

 Code:

-->> A class with static boolean variable and method:-


public class runOnce{
    public static Boolean firstRun = false;   
    public static Boolean run(){
        if(!firstRun){
            firstRun = true;
            return firstRun;
        }
        return false;
    }
}

-->> Now change in trigger,

trigger updateAccount on Account (after insert, after update) {   
     if(runOnce.run()){
         List<Account> accList = new List<Account>();
         for (Account a : [Select ID from Account where Id in :Trigger.new]) {
        // some logic……
        //…………………………….
              accList.add(a);
         }
         update acclist;
     }
}

Hope it helps, Happy Coding...:)

Anurag Jain