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.......