Sunday, 13 April 2014

Branding Salesforce Login page

Branding is a way to motivates the buyer, concretes user loyalty, and delivers the message clearly.After Salesforce winter 14 release any organization that are using salesforce, able to customize salesforce login page.
What means of Customizing login page ?
Now you can change the look and feel of your login page by adding a background color, custom +logo, and right-frame content.
What is the Prerequisites ?
At least one Domain is enable for your organization.To check this follow the path Name | Setup | Administration Setup | Domain Management | Domains and check whether domain is enabled for your salesforce org or not. If you want to add Domain and don’t know how to do that, then click on link (Adding a Domain).
To customizing your login page follow the instruction.
1. Navigate to Name | Setup | Administration Setup | Domain Management | My Domain.
2. Click on Edit button under ‘Login Page Branding‘ section
Customize branding page
3. If you want to customize your logo, upload an image.
Note :- Images can be .jpg, .gif or .png files up to 100 KB in size. Maximum image size is 250px by 125px.

Header Logo
Header Logo
Here I used below image  as a logo.

Logo
Logo

4. If you want change your login page background, it’s very easy click the color picker or enter a valid hexadecimal color code.

Background Color
Background Color

5. To change right side iframe on the login page, enter URL to ‘Right Frame URL‘ Box

Right Frame URL
Right Frame URL
In above screen shot i am using one of image url from my old blogpost.
Note :-Content must be located at a URL that uses SSL encryption and the https:// prefix. Maximum content size is 478px by 397px.
6. Optionally,You can select additional authentication services to include on your login page.
7. Finally click on Save Button, to save your work.
8. Now logout from salesforce and go to login page by using your domain like for me it’s (https://rakeshistom-dev-ed.my.salesforce.com/)

My dev org login page
My developer org login page

Friday, 11 April 2014

Data import from csv using Visualforce page

  

Sometimes we need to read a csv file in a visualforce page.

Here is a example to read a csv file and display it in a pageblocktable.

Following example reads a csv file having account records in it and displays them in a table when "Read csv" button is pressed.

Csv file format used in this example:













Output screen shot:




Visualforce page

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<apex:page controller="csvFileReaderController">
    <apex:form >  <!-- csv reader demo -->
        <apex:pageBlock >
            <apex:panelGrid columns="2" >
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Read csv" action="{!readcsvFile}"/>
            </apex:panelGrid>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!sObjectList}" var="rec">
              <apex:column value="{!rec.name}" />
              <apex:column value="{!rec.AccountNumber}" />
              <apex:column value="{!rec.Accountsource}" />
              <apex:column value="{!rec.Type}" />
              <apex:column value="{!rec.Website}" />
        </apex:pageblocktable>
     </apex:pageBlock>
   </apex:form>
</apex:page>


Controller

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Public with sharing class csvFileReaderController {
public Blob csvFileBody{get;set;}
Public string csvAsString{get;set;}
Public String[] csvfilelines{get;set;}
Public String[] inputvalues{get;set;}
Public List<string> fieldList{get;set;}
Public List<account> sObjectList{get;set;}
  public csvFileReaderController(){
    csvfilelines = new String[]{};
    fieldList = New List<string>();
    sObjectList = New List<sObject>();
  }
  Public void readcsvFile(){
       csvAsString = csvFileBody.toString();
       csvfilelines = csvAsString.split('\n');
       inputvalues = new String[]{};
       for(string st:csvfilelines[0].split(','))
           fieldList.add(st);  
       
       for(Integer i=1;i<csvfilelines.size();i++){
           Account accRec = new Account() ;
           string[] csvRecordData = csvfilelines[i].split(',');
           accRec.name = csvRecordData[0] ;            
           accRec.accountnumber = csvRecordData[1];
           accRec.Type = csvRecordData[2];
           accRec.website = csvRecordData[3];
           accRec.AccountSource = csvRecordData[4];                                                                              
           sObjectList.add(accRec);  
       }
  }
}

Modifying Salesforce Picklist Values


If you have been using Salesforce for a while, you have probably come across a need to replace or remove a picklist value.
Salesforce Picklists, Salesforce Consultant, Salesforce Support, Salesforce Partner, StarrForce

This may seem like a simple task, but if not thought out properly, it can lead to complications down the road. Below are the options you have when replacing or deleting picklist values in Salesforce.
Rename the Salesforce Picklist Value
If you just want to rename a value, click the “Edit” link next to the value and type in the new value. For instance, if you want to change the Lead Source value from Web to Web Page, edit the value and rename it.
Some Salesforce picklists, like the Salesforce opportunity Stage, do not allow editing of the name and need to use one of the other options. Also, keep in mind that if you change the name of a picklist value, and that value is used in a Salesforce report filter, then that report may not work as expected after the change since that value will be removed from the filter criteria or if it is the only criteria, return an error when running/editing the report.
Replace the Salesforce Picklist Value
Another option is to create a new value and then globally replace an existing value. This is handy when combining values or if you want to keep your report filters intact using new or existing values.
When viewing the picklist values of a Salesforce field, use the “Replace” button and enter the value you want to replace. Then select the value to replace it with. You will need to have any new values added before replacing existing values.
This is a global change and will replace the picklist value for all existing records, including records in the recycle bin. Also, this will update the Modified By date and time for all records where the value was replaced.
Deactivate the Salesforce Picklist Value
When you use the “Del” link next to a picklist value, one of two things will happen. The value will either be removed from the picklist and is no longer selectable or you will be presented with a new screen to choose a value to replace the deleted value with.
If you choose to replace the deleted value with “None” (the default), then existing records are not updated and the value is no longer selectable. Existing records will keep the deleted value until changed to a new value. Replacing the value follows the functionality above.
Keep in mind that if you decide not to replace the value, it will still show up in reports and list views but you will not be able to use it in filters since it is no longer a valid picklist value. You can get around this by using the criteria of “Picklist Field” “not equal to” and then select all available picklist values. This will then return all records that do not have a valid (selectable) picklist value.
Now that you understand the different options and ramifications of deleting or replacing Salesforce picklist values you can make the choice that best meets your needs

Tuesday, 1 April 2014

Handling spaces in a Select Field value in an email template

I'm creating an email template called "case closed with survey". It's used in a workflow rule such that when a case is closed, a link to a customer satisfaction survey will be sent to the customer. The body of the email template looks like this:
Thank you for your support inquiry.  We have changed the status of support ticket {!Case.CaseNumber} to “closed”. Please fill out this brief survey:

https://getfeedback.com/r/iy9Ow4Ms?Case_ID={!Case.Id}&Account_Name={!Case.Account}&Case_Type={!Case.Type}&Application={!Case.Application__c}

Thank you.
"Case.Application__c" is a custom field we added to the case object, and it contains the names of our product.  The product names are multi-word with spaces: meaning an Application name could be "widget one", "widget two", etc.
When I use the template as is above, I get "&Application" as part of the URL, but it drops the Application name value after the first space - meaning that the URL ends in "&Application=widget". I've tried both single and double-quotes...when I do either of these, I don't get anything for the application name.

It was suggested that I use URLENCODE (i.e., "&Application={URLENCODE(!Case.Application__c)}") at the end of the URL.  Unfortunately, that still only gets me the first word of the application name as part of the URL.

Any way I can recode this template so that it gives me the full product name?


Answer
The URLENCODE shoud have worked! Write it like this:
{!URLENCODE(Case.Application__c)}
Meanwhile also give these a trial:
{!SUBSTITUTE(Case.Application__c, ' ', '%20')}
Also this one:
{!SUBSTITUTE(Case.Application__c, ' ', '+')}

Workflow on Opportunity changed Stage not working

Trying to create a workflow to send an email every time an opportunity is changed from  Closed to something else

I can't get it to fire

AND(ISCHANGED(StageName), (OR(PRIORVALUE( StageName )= "Closed Won",PRIORVALUE(StageName )= "Closed Lost")))

It will fire just on the Stage change, but not with the Priorvalue change.  Note, i reordered them and tried Contains instead of using an OR.

Any suggestions?

ANS

So you want it to fire if the stage is changed and the prior status of the opportunity was closed, is that right? That's what your syntax says right now. Assuming that is the case you can simply down to this:
AND(
ISCHANGED(StageName),
PRIORVALUE(ISCLOSED))




View scheduled reports by user?

Q

Is it possible to view the number of scheduled reports per each user?

A


You cannot really view a summary by user, but you can get a list of what is scheduled to run next and who scheduled it.

Go to:
Setup>Monitor>Jobs>Scheduled Jobs

From there you can probably extract who has what scheduled. 

Is there an easy way to run a report that looks at the number of users created by year in an org - cumulative?

QUE

Is there an easy way to run a report that looks at the number of users created by year in an org - cumulative?



ANS

User-added image

You can schedule a time based workflow that fires every month. If that doesn't work, you can leverage the APEX class to send the email.

QUE

why opportunities' and contracts' notes and attachments also are showed under account? any way we can make notes and attachments under Opportunities are not visible under Accounts?

ANS


When a user creates a Note or Attachment, there is a Private checkbox they can use.


Tuesday, 25 March 2014

Follow button in Salesforce Chatter !

Question


Can we by any chance use the 'Follow' button in Salesforce Chatter to send an invite to people to connect apart from its standard functionality of following people and get their regular updates/feeds?

Answer


The follow feature of Chatter doesn't really offer any options to configure - certainly nothing along the lines of what you are describing such as sending an invite.

To do what you want you would have to use quite a considerable amount of customisation using Apex and Visualforce. 

How to write validation Rule for casecomment?

Question


 
I want to write validation Rule for case comments. SO if any users wants to delete/update  the case comments then it wont allowed deletion or modification. But i saw that there is no field like comments in the case fields. Then how could i acheive this ?
User-added image 
 
 

Answer 
 
trigger trgr_Case_CaseCommentLock on CaseComment (before Update, before Delete) {
    
    List<Profile> currentUserProfile = new List<Profile>();
    
    currentUserProfile = 
        [SELECT Name FROM Profile WHERE Id = :UserInfo.getProfileId() LIMIT 1];
    
    if(
        !currentUserProfile.isEmpty() &&
        currentUserProfile[0].Name != 'System Administrator'
    )
        if(trigger.isDelete)
            for(CaseComment cm : trigger.old)
                cm.addError('You cannot Delete a Case Comment!');
        else
            for(CaseComment cm : trigger.new)
                cm.addError('You cannot Edit a Case Comment!');        
}

Help with Opportunity Products Field

Question

I have created a field at the Product level, but when quotes are created the products in the opportunity are Opportunity Products. These Opportunity  Product then do not have the same fields as the simple Products do, so my new field in Products is not showing up, thus my Opportuntiy field does not work

Is their a way to update Opportunity Products rather than just Products? Or, will I need to configure some sort of cross-object flow to communicate the 'Year' from Products to Opportunity Products.


Answer

Create custom formula field on Opportunity Product (setup-customize-opportunity-opportunity product-fields).
In that custom formula put value of that product field you have already created. Formula will be something like this PricebookEntry.Product2.your_field_on_product .

Receive data from external software?

Question

I work with a piece of software that collects data about my customer's activity on an ongoing basis.

In a recent conversation with the software vendor, the told me that other customers have created an integration between the software and SFDC by supplying the software vendor with an endpoint address (within the SFDC org) to which they can send data, and then setting up a mapping that points the data from the software vendor to specific SFDC fields.
 
Does anyone have any idea what they are talking about?  Where can I find this address?  It sounds almost like an FTP.

Has anyone had any experience with pulling in data from external sources on a regular basis?

Answer

What they are talking about is setting up/creating your own web service inside Salesforce that you can then expose and make available to external systems. Example of a simple web service here (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_web_services_methods.htm" target="_blank).

When you make that class and define it as a Web Service, there will be a button to generate a WSDL from the class when you look at it in Salesforce.
Generate WSDL Button

When you generate that WSDL, all the way at the bottom there will be a URL like "https://na13.salesforce.com/services/Soap/class/MyWebService". This is what the external system calls to connect with your system. The external system will also need a username/pw to authenticate and connect to your Salesforce.

Once it is connected, the external service can call the methods inside your web service. For instance, in the example provided they could pass a name and accountid to your system and call makeContact() to generate a new contact on that account inside Salesforce.

Find Percent of Value by Row Grouping

Q
How do I find the percent of a total value grouped by row? I've tried the PARENTGROUPVAL but I don't think I'm using it correctly.

I have a report summing up the Account field "Total Contracted Revenue" for all Customers, broken down into rows by Industry. I want to know what percentage of the Grand Total TCV each Industry has. The chart feature easily allows me to do this ("Show %") but I can't figure out the formula to get this into my report.


So basically, for each row (Industry), I want to know what percentage of the report's Grand Total TCV (Total_Revenue_Received_from_Customer__c) each one has.


Ans



AMOUNT:SUM /PARENTGROUPVAL(AMOUNT:SUM, GRAND_SUMMARY)
User-added image

Sorting related list by hidden field

Question


I have a simple logic which defines the sorting order of a related list, but it's not a VERY simple one like alphabetically of ascending/descending.
I defined an additional field to capture this logic, and i want to sort the related list according to this field, but not to show this field on the layout.
Any ideas?



Answer




I don't think you'll be able to sort without displaying the field unless you use some Visualforce, which sounds like it might be more work than what you want to do. The documentation on related lists says that sorting is only available by selecting the field you want to sort on from the list of fields shown and selecting ascending/descending. (http://help.salesforce.com/HTViewHelpDoc?id=customizing_related_lists.htm&language=en_US" target="_blank)

I know space is a premium, but you can just stick it at the end of the related list and sort, and hopefully your users won't mind too much.

Help with a Case Validation Rule

Question


I need a little help with a validation rule on my case object.

We want to require our case agents to fill "Remedy or Componet Failure" if "RMA Remedy or Componet Failure" is blank when closing a case.

Here is the VR i have so far, but this rule will not allow us to create a case becuase it wants the "Remedy or Componet Failure" filled out.

AND(NOT(ISPICKVAL(Status,"Closed")),(ISBLANK(TEXT(RMA_Remedy_or_Component_Failure__c))), ISBLANK(TEXT( Remedy_or_Component_Failure__c )))



Answer:


AND(
TEXT(Status) = "Closed",
ISBLANK(TEXT(RMA_Remedy_or_Component_Failure__c)),
ISBLANK(TEXT(Remedy_or_Component_Failure__c)))

The reason it wasnt working was because of your 'NOT' clause!


Find and replace text - apex trigger or button

Question


I have an issue where by I need a temporary fix, I am trying to create a method of looking at a string of text on the opportunity and replacing all the $ with £ (custom text field)

A trigger example I found is

trigger YourTrigger on Solution (before update) { 
  for(Solution s : trigger.new) {
    s.replaceAll('Hello World','Goodbye World');
  }
}

but if possible I would rather have a button on the opportunity that could provide this functionality. I also need to limit this trigger to fire only on opptys that match a pre specified field criteria eg checkbox__c = true



Best Answer


Why would you need to this with a Trigger? You could do this with a Workflow Rule+ Field Update. Something like this:
  1. Setup | Create | Workflows & Approvals | Workflow Rules
  2. New Rule
  3. Select the Object: Opportunity
  4. Evaluation Criteria: created and every time it’s edited [2nd Option]
  5. Rule Criteria: formula evluates to true
  6. Formula
    AND(
      Checkbox_Field__c = TRUE,
      NOT(ISBLANK(Text_Field__c)),
      FIND('$', Text_Field__c) >= 1, 
      OR(
        ISNEW(), 
        ISCHANGED(Text_Field__c),
        ISCHANGED(Checkbox_Field__c)
      )
    )
  7. Click Save & Next
  8. From under Immediate Workflow Actions, click Add Workflow Action to select Field Update
  9. Select the Field to Update: Opportunity: Text Field
  10. Select Use a Formula to Set the New Value
  11. Formula
    SUBSTITUTE(Text_Field__c, '$', '£')
  12. Click Save
  13. Click Done
  14. Click Activate
So this one runs whenever some changes the value on the Text Field or the Checkbox/when a new record is created but provided that it has some value and not is EMPTY, the Checkbox is checked(aka TRUE), the Text Field has at least one Dollar sign($).

Chat messenger not showing

Question

I can see the chatter window on all of my custom profiles, except one.  Can anyone tell me exactly what profile permissions are needed to use the chatter messenger?  I have enabled just about anything with the word chatter in it and still can't access see the window at the bottom of the screen.

Answer 

I believe it might be a symptom of logging in as another user.  I logged into this account as an admin and didn't see the chat window so I figured this was a permissions issue

Error in test classe: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PortalType (Account is not enabled for this portal type): [PortalType]

Question

 
I have this scenario:
Account acc = new Account(Name='Partner', Razao_social__c='Partner', CNPJ_CPF__c='98868716000100', Codigo_empresa__c='01')
Database.insert( acc );


Answer






To make a partner portal account, any account is ok. Simply ensure the account's owner has the correct values in the UserRoleId and ProfileId fields.
To make a partner user, any user is ok. Simply ensure the user's profile is a Portal User profile. Then you can specify a value for its ContactId field.

Here's the code that's working for me:

//Create portal account owner
UserRole portalRole = [Select Id From UserRole Where PortalType = 'None' Limit 1];
Profile profile1 = [Select Id from Profile where name = 'System Administrator'];
User portalAccountOwner1 = new User(
 UserRoleId = portalRole.Id,
 ProfileId = profile1.Id,
 Username = System.now().millisecond() + 'test2@test.com',
    Alias = 'batman',
 Email='bruce.wayne@wayneenterprises.com',
 EmailEncodingKey='UTF-8',
 Firstname='Bruce',
 Lastname='Wayne',
 LanguageLocaleKey='en_US',
 LocaleSidKey='en_US',
 TimeZoneSidKey='America/Chicago'
);
Database.insert(portalAccountOwner1);

//Create account
Account portalAccount1 = new Account(
 Name = 'TestAccount',
 OwnerId = portalAccountOwner1.Id
);
Database.insert(portalAccount1);
     
//Create contact
Contact contact1 = new Contact(
    FirstName = 'Test',
     Lastname = 'McTesty',
 AccountId = portalAccount1.Id,
     Email = System.now().millisecond() + 'test@test.com'
);
Database.insert(contact1);
     
//Create user
Profile portalProfile = [SELECT Id FROM Profile WHERE Name LIKE '%Portal User%' Limit 1];
User user1 = new User(
 Username = System.now().millisecond() + 'test12345@test.com',
 ContactId = contact1.Id,
 ProfileId = portalProfile.Id,
 Alias = 'test123',
 Email = 'test12345@test.com',
 EmailEncodingKey = 'UTF-8',
 LastName = 'McTesty',
 CommunityNickname = 'test12345',
 TimeZoneSidKey = 'America/Los_Angeles',
 LocaleSidKey = 'en_US',
 LanguageLocaleKey = 'en_US'
);
Database.insert(user1);


How do I prevent duplicates when importing leads if they are already a Contact?


Question
 
I am importing a list of 10,000 leads.  I am selecting "Matching Type" = email to prevent duplicates.  But I've noticed that some email addresses in the imported database are already contacts.  How do I prevent duplicates of leads that are already contacts?
 
Best Answer
 
Without some third-party-tool, you can't  -> check appexcange for deduplication tools that can perform deduplication on both: contacts&leads.
 

Trying to Write a Formula Field for Margin % on Products at List Price

Question:

I am trying to have a field on products that simply shows the margin % for the product code at list price. (List Price - Product Cost) / List Price.

To do this... I need to get a look- up into the Price List... but am so lost on how Salesforce doesn't allow you to look up into the Standard Price Book (List Price) from Products.

Any ideas on how to get Standard Cost (PriceBook2/Pricebook Entry/etc...) brough into the Product Object so I can have this field calculate.

Using this to ensure our list prices on products are appropriate based on our list margin targets.

Thanks!




Answer 



There is no simple solution for your requirement especially if you have multicurency enviroment. You can not retrieve prices from pricebookentry via formula or workflow rule or via some quick&simple approach.  I would need to do some coding in order to achieve something like that.

I would think in the following directions:
- when setting up product prices make sure that price is also set in some custom field in the product itself; not just in the pricebookentry
- if above is not acceptable then you can do some apex batch code that would automaticaly fill your product price custom field on the product from the pricebook entry. Though, this requires deeper knowledge in apex development.
 

The members of sales team at universal Containers are working togather to close an opportunity. The sales engineer is having trouble keeping up with the most currents quots. How can the sales engineer identify the opportunity's latest quotes?


He can also be part of the sales team, and follow the opportunity record on chatter feed.......