• Yuchen
  • 484 Points
  • Member since 2014
  • Salesforce/Java Developer

  • Chatter
  • 14
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
  • 147
Requirement is:
If a "Payment Made" field has a number in it, then do not allow the "Project Date" to be blank.  Here is what I have but not working.

TEXT(Payment_Made__c) = "", 
Hi ,

I have 4 fields containg text values of time it took to complete an application


and the data these fields return are "Consistant enough". Here are all possible  Scenarios
3 min. 41 sec.
13 min. 31 sec
12 min. 1 sec
1 min. 9 sec.
28 sec.
9 sec.

I would like to be able to add up all of those 4 fields to get a total, and not sure how to go about it. I tried many things, Substitute formula being the closest I got to it, but still not good enough

The total could either be in total seconds, mm:ss or whatever idea any of you can help me with 

Thank you in advance :)
  • April 09, 2015
  • Like
  • 0
Hi there,

I have the following situation:
- My Quote has a field that is updated on its afterUpdate trigger, based on a calculation involving its QuoteLineItems
- If I simply update one of the QuoteLineItems via UI (edit item, change value, save), it also does an update on the Quote, firing its triggers which ends up calculating the value of the field I mentioned above, works fine.
- However, If I just make an 'update item' on my test, it does not update the Quote, which ends up not calculating the mentioned field

I can't see a reason why the Quote is also being updated through the UI. So, before going deeper in debug logs, I'm just wandering if there is something very obvious that I might be missing. Any thoughts?

The following trigger is not eveluating past the Prospect Major for some reason. If I comment out the major assignment I get Mid for an account that should be Inside. I am hoping I am missing something small as I need to reassign accounts this evening after 5pm EST. I am sure there is a better way to do it so I am sorry for all the over code. 

trigger AssignTerritoryType on Account (Before insert, Before update) {
    For (Account a :trigger.new){
    IF((a.Current_Account_Status__c == 'Customer' || 
        a.Current_Account_Status__c == 'Customer - In Play') && 
            a.NumberOfEmployees >= 10000 )
            { a.Major__c=true;
    else IF((a.Current_Account_Status__c == 'Customer' || 
             a.Current_Account_Status__c == 'Customer - In Play') && 
                 (a.NumberOfEmployees > 2000 && 
                  a.NumberOfEmployees <= 10000))
            { a.Major__c=False;
    else IF((a.Current_Account_Status__c == 'Customer' || 
             a.Current_Account_Status__c == 'Customer - In Play') && 
                (a.NumberOfEmployees > 0 && 
                 a.NumberOfEmployees <= 2000))
    else if((a.Current_Account_Status__c == 'Prospect' || 
             a.Current_Account_Status__c == 'Prospect - In Play' &&
                 (a.Fortune_1000_Rank__c==NULL) &&
                 (a.NumberOfEmployees >= 9000) && 
                 (a.Industry != 'Education')==True)  ||
                    (a.Current_Account_Status__c == 'Prospect' || 
                     a.Current_Account_Status__c == 'Prospect - In Play' &&
                    (a.Fortune_1000_Rank__c==Null) && 
                     (a.AnnualRevenue >= 1000000000) && 
                     (a.Industry != 'Education')==True)  ||
                          (a.Current_Account_Status__c == 'Prospect' || 
                           a.Current_Account_Status__c == 'Prospect - In Play' &&
                           a.Industry == 'Pharma/BioTech') ||
                                (a.Current_Account_Status__c == 'Prospect' || 
                                 a.Current_Account_Status__c == 'Prospect - In Play' &&
                                 a.Industry == 'Fed - Gov')  ||
                                    (a.Current_Account_Status__c == 'Prospect' || 
                                     a.Current_Account_Status__c == 'Prospect - In Play' &&
                                     a.Fortune_1000_Rank__c <=750 ))

    else if ((a.Current_Account_Status__c == 'Prospect' || 
              a.Current_Account_Status__c == 'Prospect - In Play' &&
             (a.NumberOfEmployees < 9000) && 
             (a.NumberOfEmployees >=3000) &&
             (a.Industry != 'Education')==True ) ||
                     (a.Current_Account_Status__c == 'Prospect' || 
                      a.Current_Account_Status__c == 'Prospect - In Play' &&
                     (a.AnnualRevenue < 1000000000) && 
                     (a.AnnualRevenue >=500000000)) ||
                          (a.Current_Account_Status__c == 'Prospect' || 
                           a.Current_Account_Status__c == 'Prospect - In Play' &&
                          (a.Fortune_1000_Rank__c >=751)) ||
                             (a.Current_Account_Status__c == 'Prospect' || 
                              a.Current_Account_Status__c == 'Prospect - In Play' &&
                             (a.NumberOfEmployees >=8000) && 
                             (a.Industry == 'Education')==True) ||
                                   (a.Current_Account_Status__c == 'Prospect' || 
                                    a.Current_Account_Status__c == 'Prospect - In Play' &&
                                    a.Industry == 'State -Gov')

I would like to allow our salespeople track credit notes on my Salesforce org using an Invoice object that was created. We are going to create a separate record type "Credit Notes" for that.

Are we able to change the signs for the quantities and amounts from positive in the records to negative for reporting? So for example, as a record, I might have 2 items with a value of $100 as a line item, but in our reporting, this reports as -2 items with a value of -$100?

Thanks in advance!

I wrote some apex code that will based on the result of a formula field. It works fine with real data.
But the problem is when I try to generate mock data in test class, the formula field is not evaluating and is always 'Null'.
Can annybody help me how to get the formula field evaluated?

  • December 19, 2014
  • Like
  • 0
Have a text field 'Summary' with ids as values and Summary1 with names as values

Summary = a00o0000001Lgmb,a00o0000001LZRN,a00o0000001id76

Summary1=new product,product1,product2

Have created a formula field 'new' which displays the values of the Summary1 field as hyperlink but when clicked it redirects to the record by the record ids in the Summary field. But this formula is not working correctly when there are 0 -2 parameters. 

Now the formula is gettng displayed correctly as the below when there are 3 values:

new= new product,product1,product test 

Now the problem is when there is just one value or 2 values in the summary1 field , the values get displayed twice.

for eg if,
Summary = a00o0000001Lgmb,
Summary1=new product,

new=new product, new product.

Wanted to know how to display the values correctly when there are 0-3 parameters.

(HYPERLINK("/"&LEFT(Summary__c,18),LEFT(Summary1__c,  FIND(",", Summary1__c,0))))&(',')&

(HYPERLINK("/"&RIGHT(Summary__c,18),RIGHT(Summary1__c, LEN(Summary1__c) - FIND(",", Summary1__c, FIND(",", Summary1__c,0)+1))))&(',')&

(HYPERLINK("/"&MID(Summary__c,20,18),MID(Summary1__c, FIND(",", Summary1__c), 
FIND(",", Summary1__c, FIND(",", Summary1__c)+1)- FIND(",", Summary1__c))))

I tried using IF(FIND) but not sure how to use it
Something like (IF(FIND(Summary1__c, ",")>0   
IF(FIND(Summary1__c, ",",1+FIND(Summary1__c, ","))>0

Please help
  • December 17, 2014
  • Like
  • 0

I'm having trouble creating the correct syntex for a formula field. I have one piece working, which involves inserting a value if another multipick list field has a specific value selected.

(IF(INCLUDES(Account_Types__c , "Clinical"),"Clinical", " "))

But I also want to insert other values if other picklist options are selected. I tried adding an OR operator or OR function but just can't find the correct syntax. For example...

(IF(INCLUDES(Account_Types_c, "Clinical"),"Clinical"," ") OR (IF(INCLUDES(Account_Types__c , "Pharma/Biotech"),"Pharma/Biotech", " "))

Much thanks in advance!


There does not appear to be a way to make a custom date field that updates to todays date whenever a field is edited. Does anyone have some insight?

Basically I have a 'Offer Comments' field, and a corresponding 'Offer Comments Date' field that should show the date the Comments field was last edited. How can I implement this? It does not seem possible with the available criteria with a workflow rule.

Any help is appreciated!!
I can't figure out why my test here isn't working - I get an error message indicating my expected amount is 0 but the actual is 20. 20 is what my test should be (at the end of the code block included), so I'm not sure what's wrong.

Thanks for any help!

private class Test_Line_Item_Invoice_RollupTrigger {

    static testMethod void LineItemInvoiceRollupTrigger() {
    // Create a Billing Entity record, be.
    Account be = new Account();
    be.RecordTypeId = Schema.SobjectType.Account.getRecordTypeInfosByName().get('Organization').getRecordTypeId();
    be.Name = 'Test Church';
    be.Client__c = '02CRC';
    be.Active__c = True;
    be.EFT_Active__c = True;
    be.BillingStreet = '123 Test St';
    be.BillingCity = 'Grand Rapids';
    be.BillingState = 'Michigan';
    be.BillingPostalCode = '49508';
    be.Organization_Original_Auto_Number_Value__c = '1';
    insert be;

    // Create a Participant record, p, related to be.
    Contact p = new Contact();
    p.Ultipro_ID__c = 1;
    p.FirstName = 'Stephanie';
    p.LastName = 'Arce';
    p.AccountId = be.Id;
    insert p;
    // Create an Invoice record, i, related to be and p.
    Invoice__c i = new Invoice__c();
    i.Invoice_Date__c = Date.NewInstance(system.today().year(), system.today().month(), 15);
    i.Billing_Entity__c = be.Id;
    i.RecordTypeId = Schema.SobjectType.Invoice__c.getRecordTypeInfosByName().get('Current Month Invoice').getRecordTypeId();
    insert i;
            // Query the Invoice to ensure Line Item Total and Line Item Total Adjusted are $0.00
            Invoice__c query1 = [select Id, Line_Item_Total__c, Line_Item_Total_Adjusted__c, Number_of_Line_Items__c from Invoice__c where Id = :i.Id];
            system.assertEquals(query1.Line_Item_Total__c, 0);
            system.assertEquals(query1.Line_Item_Total_Adjusted__c, 0);
            system.assertEquals(query1.Number_of_Line_Items__c, 0);

    Insert Test
            // Create a Line Item record, ilicurrentinsert1, related to i and p. Inserting should cause the trigger to run.
            Line_Item__c ilicurrentinsert1 = new Line_Item__c();
            ilicurrentinsert1.Invoice__c = i.Id;
            ilicurrentinsert1.Participant__c = p.Id;
            ilicurrentinsert1.Benefit__c = 'Medical';
            ilicurrentinsert1.Plan_Option__c = 'Single HDHP - Full Time';
            ilicurrentinsert1.Ultipro_Benefit_Group__c = 'US Church';
            ilicurrentinsert1.Ultipro_Deduction_Code__c = 'MED';
            ilicurrentinsert1.Cost__c = 20;
            ilicurrentinsert1.Premium_Month__c = 'Jan';
            ilicurrentinsert1.RecordTypeId = Schema.SobjectType.Line_Item__c.getRecordTypeInfosByName().get('Existing Invoice Line Item').getRecordTypeId();
            insert ilicurrentinsert1;
                    // Query the Invoice to see if the amount in the Line Item was updated to Line Item Total on their record.
                    Invoice__c query2 = [select Id, Line_Item_Total__c, Line_Item_Total_Adjusted__c, Number_of_Line_Items__c from Invoice__c where Id = :i.Id];
                    system.assertEquals(query2.Line_Item_Total__c, 20);
                    system.assertEquals(query2.Number_of_Line_Items__c, 1);

Dear all, below is my trigger to send email from Salesforce. This trigger fires when Visit__c field is checked as True. Trigger works fine, but issue is that I`m not able to populate Created By Name, Assigned To name, Opportunity/Account Name (RelatedTo) etc in my html email body. How can I populate these fields in my email body? If I String E.Whatid or Whoid, it gives me ID in template instead of name.

Also, is there a way I can populate Contact name, phone number etc. tagged to this event? I`m new to Apex so any help will be much appreciated! :)
Trigger VisitNotification on Event (after insert){
    List<Messaging.SingleEmailMessage> newEmails = new List<Messaging.SingleEmailMessage>();
    for(Event e :Trigger.new){
            String fullTaskURL;
            String Facility;
            Datetime startDate;
            Datetime endDate;
            String Purpose;
            String Salesexec;
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setSubject('Automated Alert: A New Record is Created');
            mail.setTargetObjectId('00580000005HreR') ;        

            fullTaskURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + E.Id;
            Facility = E.Facility__c;
            startDate = E.StartDateTime;
            endDate = E.EndDateTime;
            Purpose = E.Purpose__c;
            Salesexec = E. Salesexec__c;
            //Generate email template
                String emailBody;
                emailBody = '<html><body>Hi<br> <br> A New Record has been created: <a href="' + fullTaskURL + '">' + E.Id + '</a><br></body></html>' + '<br> <br> Site/Facility: ' + Facility+ '<br> Start Date/Time: ' + StartDate + '<br> End Date/Time: ' +endDate + '<br> Purpose: ' + Purpose + '<br> Sales VP: '+ Salesexec +  '<br> <br> Thank you <br> <br> Salesforce Admin' ; 
                mail.setHtmlBody(emailBody );



I installed Java, Eclipse, and Force.com IDE on my Windows 7 (32-bit) yesterday and when I tried to pull it up again today, I receive the following error: The Eclipse executable launcher was unable to locate its companion shared library.

I uninstalled Java and Eclipse and re-installed them and am still getting the same error. 

Is there something else I can try?

I understand there isn't a standard function in SF to update a child record type based on the parent object record type. Does anyone have any example I can use to do this with a trigger? What I would like to do is, if the parent record type is changed, then the child Task record type changes as well. Any help would be appriecated! Thanks.
I am using my developer account for preparing for DEV401 certification test.
I remember I can login as another user with the training account but I don't see the option here.
I create a user and would like to login as that user to try some sharing rules.

How can I do that?
So in Apex, is there any way to check whether an sObject supports Apex triggers? We want to check it dynamically in Apex. It would be nice if there is something called "istriggerable" so we can check. 
So the requirement here is to find out whether there is leap year date (ie, 2/29/xxxx) between a date range using Formula in Salesforce.

We have two dates for our custom Object, Start Date and End Date, and the date range is usually within a year, for example:
1) If Start Date is 7/3/2003, End Date is 4/4/2004, then the Formula Output should be "YES" because there is a leap year date(2/29/2004)
2) If Start Date is 2/1/2016, End Date is 1/10/2017, then the Formula Output should be "YES" because there is a leap year date(2/29/2016)
3) If Start Date is 4/2/2004, End Date is 2/15/2005, then the Formula Output should be "NO" because there is no date for leap year for the given date range

Thanks a lot for the help!
  • April 08, 2015
  • Like
  • 0
So in Apex, is there any way to check whether an sObject supports Apex triggers? We want to check it dynamically in Apex. It would be nice if there is something called "istriggerable" so we can check. 
Please help me finding correct answers for the below questions. Explanation for the answers would be more helpful.

1) A developer creates an Apex helper class to handle complex trigger logic. How can the helper class warn users when the trigger exceeds DML governor limits?
 A) By using ApexMessage.Message() to display an error message after the number of DML statements is exceeded.
 B) By using Messaging.SendEmail() to conthtinue the transaction and send an alert to the user after the number DML statements is exceeded.
 C) By using PageReference.setRedirect() to redirect the user to a custom Visualforce page before the number DML statements is exceeded.
 D) By using Limits.getDMLRows() and then displaying an error message before the number of DML statements exceeded.
2) Where can debug log filter settings be set Choose 2 answers?
 A) The Filters link by the monitored user's name within the web UI.
 B) The Show more link on the debug log's record.
 C) On the monitored user's name.
 D) The Log Filters tab on a class or trigger detail page.
3) When can a developer use a custom Visualforce page in a Force.com application? Choose 2 answers
 A) To create components for dashboards and layouts.
 B) To deploy components between two organizations.
 C) To generate a PDF document with application data.
 D) To modify the page layout settings for a custom object.
4) What is an important consideration when developing in a multi-tenant environment?
 A) Polyglot persistence provides support for a global, multilingual user base in multiple orgs on multiple instances.
 B) Governor limits prevent tenants from impacting performance in multiple orgs on the same instance.
 C) Unique domain names take tile place of namespaces for code developed for multiple orgs on multiple instances.
Org-wide data security determines whether other tenants can see data in multiple orgs on the same instance

I am trying to create an Apex Trigger that performs a Rollup from a custom object to Contacts. Here is the error that I am receiving: Didn't understand relationship 'Assignments__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

Below is the code:
trigger RollupActiveAssigmentLevelsToContact on pse__Assignment__c (after insert, after update, after delete) {
    set<Id> set_id = new set<Id>();
    List<Contact> con_list = new List<Contact>();
    if(trigger.isInsert || trigger.isUpdate){
        for(pse__Assignment__c myAssignment : trigger.New) {
    else if(trigger.isDelete){
        for(pse__Assignment__c myAssignment : trigger.Old){
    if(trigger.isAfter && (trigger.isInsert || trigger.isUpdate || trigger.isDelete)){
        con_list = [SELECT id,Total_Levels__c, (SELECT id,name FROM Assignments__r WHERE Active_Assignment__c = TRUE) FROM Contact WHERE id IN :set_id];
        for(Contact con : con_list){
                con.Total_Levels__c = con.Assignments__r.size();
                con.Total_Levels__c = 0;
        update con_list;

Here is a snip of the Child Relationship name:

User-added image

Any and all help would be greatly appreciated!
Hey guys,

Need some help, I have a apex class with soql query on Reports of type (Task & Events) in the UAT, the reports for now returns 0 records as I have some filters as Date = Last 30 Days, I'm not able to cover the query line in test class as the report result 0 count, if the same report result atleat 1 record the query line are covered in the test class. Rest all the code lines are covered except these query lines.

Also a question, while moving the code from sandbox to production through change set will the test class validate against production org data or sandbox.

Thanks in advance,
Jancy Mary
I need to learn salesforce, so i need little guidance. Can anyone help me tell from where should i start as i am bit confused now

I am trying to query contactid of logged in user like this.
But i dont see any value.
Where am i going wrong??
Id Uid=UserInfo.getUserId();
string contid='select contactid from user where id = '+ Uid + '';
List<accountcontactrole> acr =[select accountid,Account.name from accountcontactrole where contactid =:contid];
Thanks in advance!!
I am new to Sales Force/Property Base and I'm not sure how to start going about this task.
I want to add a email/submit button at the bottom of one of my page layouts so that when clicked it emails me a notification.  I looked in the new field section and I don't see an option for that type of button. Any help would be greatly appreacited.
I am a new learner in Sales Force, was trying to create work flow rules and its missing under Setup Option. Please help 
Within financialforce.com, in attempting to upload a bank statement, I am getting the following error: "Unexpected end of line." Can you please assist to let me know what might be causing this error so that I can go and fix either my csv upload file or my bank statement definition. Thank you!
id hack - pull fields from child for new parent recordMy organization sells cars.

After an opportunity has been won, a child record called "Lease Returns" is created from a related list to track the customer. When the lease is up we need to create a new opportunity and we do so from the opportunities related list on the Lease Returns Object. So there is a 1-1 relationship between this parent and child.

New Opportunity -> New Lease Return -> New Opportnity -> New Lease return -> New Opportunity -> New Lease Return -> etc......

When I create a New lease return I pull info from the preceeding opportunity using formula fields. However when I create a new opportunity everything is blank. 

I've been trying to use URL hacking to prepopulate the New opportunity fields but the child records fields arent reconized. What is the way to do this?

I'm using professional edition
Code Coverage: 0%Your overall code coverage is currently 0%. To deploy code to production, you must have at least 75%.

I get this when trying to push my first changeset from sandbox to production.

Tried applying different solutions suggested by this forum like compiling all classes and running the tests from the begining yet nothing seems to change.

Please advise.
Hi friends, I am getting this error " Error: Compile Error: Invalid type: Warehouse__c at line 7 column 39 " while practising the visualforce workbook exercise - Creating the WarehouseUtils Class .
global with sharing class WarehouseUtils {
public WarehouseUtils(ApexPages.StandardSetController controller) { }
// Find warehouses nearest a geolocation
global static List<Warehouse__c> findNearbyWarehouses(String lat, String lon) {
// Initialize results to an empty list
List<Warehouse__c> results = new List<Warehouse__c>();
// SOQL query to get the nearest warehouses
String queryString =
'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
'Street_Address__c, Phone__c, City__c ' +
'FROM Warehouse__c ' +
'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'mi\') < 20 ' +
'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'mi\') ' +
'LIMIT 10';
// Run the query
results = database.Query(queryString);
// Return the query results
Anybode help ?
I have process in salesforce in such a way opportunity we can relate this opportunity to this lookup field parent_opportunity__c . Which relates opportunity to other parent opportunity.

I want to write a query parent to child :select id,(select id from opportunity where parent_opportunity__c!=null) from opportunity where parent_opportunity__c=nullI have worked with different scenarios i cant able to crack it

select id,name,(select id,name from parent_opportunity__r) from opportunity this is showing error and

select id,name,(select id,name from opportunity) from parent_opportunity__c this is also error
Hi All,
which components are not supported  while deploying sanbox to production?
I am getting the following error when I try to run a SOQL relationship query involving external objects: UNKNOWN ERROR: UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 1553848083-42327 (-438141556). I get this same error using the Force.com IDE, Workbench or Developer Console.

Are releationship queries not allowed for external objects? The docs said that up to 4 joins are allowed.

My query looks like this:

Select s.sarahasnolimits__LastName__c, s.sarahasnolimits__FirstName__c, (Select sarahasnolimits__InvDate__c, sarahasnolimits__Status__c, sarahasnolimits__TotalPrice__c From sarahasnolimits__Invoices__r) From sarahasnolimits__Customers__x s
Hi All,
I am attempting to create an email service that creates a lead and processes the information within the body of the email. I have been getting errors for a few days now so I figured its time to ask the community. Below is the code...Thanks in advance!!

global class PurchasedLeads implements Messaging.InboundEmailHandler {
  global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, 
                                                       Messaging.InboundEnvelope env){
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
    String emailBody = email.plainTextBody;
    String companyName = emailbody.Substring(emailbody.IndexOf('Website Entered On:') + 20, emailbody.IndexOf('Practice Area:') - emailbody.IndexOf('Website Entered On:')-20);
    String firstName = emailbody.Substring(emailbody.IndexOf('First Name:') + 12, emailbody.IndexOf('Last Name:') - emailbody.IndexOf('First Name:')-12);
    String lastName = emailbody.Substring(emailbody.IndexOf('Last Name:') + 11, emailbody.IndexOf('Email:') - emailbody.IndexOf('Last Name:')-11);
    String emailAddress = emailbody.Substring(emailbody.IndexOf('Email:') + 7, emailbody.IndexOf('Phone Number:') - emailbody.IndexOf('Email:') - 7);
    String phoneNumber = emailbody.Substring(emailbody.IndexOf('Phone Number:') + 14, emailbody.IndexOf('Request Details') - emailbody.IndexOf('Phone Number:') - 14);

    Lead[] newLead = new Lead[0];
     try {
       Map<String, Schema.SObjectType> sObjectMap = Schema.getGlobalDescribe() ;
       Schema.SObjectType s = sObjectMap.get('Lead') ;
       Schema.DescribeSObjectResult resSchema = s.getDescribe() ;

     newLead.add(new Lead(Company = companyName, LastName = lastName, Email = emailAddress,Phone = phoneNumber));
       insert newLead; 
   catch (QueryException e) {
   result.success = true;
   return result;
Hi all, I have a vf template. it will render as pdf and able send the mail. I have a attachemnt with case object. i want to add this attachment to vf template. Can please help me.