• Patrick Maxwell Appfolio
  • NEWBIE
  • 25 Points
  • Member since 2014
  • Salesforce Analyst
  • Appfolio

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
First off, sorry for the long title, but I couldn't' think of a way to shorten it.

Currently I have a test class that creates accounts, users, and tasks that are all related to each other.

I have a batch class that I'm trying to test which queries tasks and has custom logic to populate a custom field based on values related to the task.  Some examples of fields I'm making conditional statements agains are Owner.ProfileId, and Account.RecordtypeId.

It seems that no matter what I do, when I call the batch class from my test class, all those related fields are NULL.  There isn't even an OwnerId or AccountId value on the task anymore.   I can provide code samples, but I don't want to include them until someone (anyone?) can direct me on what to provide, so I'm not just putting an entire class in here that is a huge eyesore.
 
Hello,

I just made this formula and thought it could save someone in the future some time.  Entering this into a formula field will give you the full state name based on abbreviation, just do a simple find and replace for "Field" in excel to edit the formula for your specific need.

if(Field='AL','Alabama',if(Field='AK','Alaska',if(Field='AZ','Arizona',if(Field='AR','Arkansas',if(Field='CA','California',if(Field='CO','Colorado',if(Field='CT','Connecticut',if(Field='DE','Delaware',if(Field='FL','Florida',if(Field='GA','Georgia',if(Field='HI','Hawaii',if(Field='ID','Idaho',if(Field='IL','Illinois',if(Field='IN','Indiana',if(Field='IA','Iowa',if(Field='KS','Kansas',if(Field='KY','Kentucky',if(Field='LA','Louisiana',if(Field='ME','Maine',if(Field='MD','Maryland',if(Field='MA','Massachusetts',if(Field='MI','Michigan',if(Field='MN','Minnesota',if(Field='MS','Mississippi',if(Field='MO','Missouri',if(Field='MT','Montana',if(Field='NE','Nebraska',if(Field='NV','Nevada',if(Field='NH','New Hampshire',if(Field='NJ','New Jersey',if(Field='NM','New Mexico',if(Field='NY','New York',if(Field='NC','North Carolina',if(Field='ND','North Dakota',if(Field='OH','Ohio',if(Field='OK','Oklahoma',if(Field='OR','Oregon',if(Field='PA','Pennsylvania',if(Field='RI','Rhode Island',if(Field='SC','South Carolina',if(Field='SD','South Dakota',if(Field='TN','Tennessee',if(Field='TX','Texas',if(Field='UT','Utah',if(Field='VT','Vermont',if(Field='VA','Virginia',if(Field='WA','Washington',if(Field='WV','West Virginia',if(Field='WI','Wisconsin',if(Field='WY','Wyoming','Other'))))))))))))))))))))))))))))))))))))))))))))))))))

Have a great day!
Hello Salesforce Coders,

I have a problem, and it's not giving me warm fuzzies inside.  Quick disclaimer, I'm not experienced at coding, but I'm learning, and I'm very interested in it.  I have written some APEX that will update a field on one SObject based on a field being updated on another SObject.  I've bulkified it, and it works great in our sandbox.  Even when I dataload 200+ records, it's great, I'm happy.  However, now that I've gotten to the step to write test code, I am confounded by my predicament.  When I run the code via test the field that needs to be updated (after the update of the other field) will not update, so my final assertion is wrong and my test code fails.  I can get more detailed, but I figured I would keep things vague for now, and if anyone is interested, they can respond to this post and throw down some knowledge.

Thanks for your time!
Patrick
I recently wrote my first trigger and I'll just say now that I'm not a formally trained software developer.  By researching online I was abe to bulkify my code and it seems to be working great in Sandbox with either a singular update or with Data Loader, however I'm sure that I've done something wrong, so I wanted to throw my work to the sharks and see what I have done incorrectly before I start trying to learn how to write test classes and push to Production.  Thank you very much for your time.

trigger MyCaseCustomerStatusUpdate on Vertical__c (after insert, after update) {
 
// create a set of related account IDs
 
set <ID> accountIDs = new set <ID>();
 
//create set of all verticals
 
set <Vertical__c> verticals = new set <Vertical__c>();
 
//create list of accounts to update at end of code
 
list <Account> accountList = new list <Account>();
 
//create Account object for later reference
 
Account accountRecord;
 
// for every Vertical, add its related to account to the set and create set of Verticals for later reference


for(Vertical__c v: Trigger.new){
accountIDs.add(v.account__c); 
verticals.add(v);

}
 
// create a Map to match the Vertical related to Account IDs to their corresponding account
 
Map<ID, Account> accountMap = new Map<ID, Account> ([Select ID FROM Account WHERE ID in :accountIDs]);   

//loop through all accounts added to account map

for(Account a:accountMap.values()){

//add account to list to update

accountList.add(a);

//loop through verticals

for(Vertical__c v : verticals){
  
   //if the ID on the account and the account ID on the vertical match, update the status field.
  
   if (a.Id == v.account__c){
  
   // update Account object
  
   accountRecord = a;
   
   // update the status on the account object
   
     accountRecord.MyCase_Status__c = v.Status__c;
   }
  }
}
  
update accountList;
 
}

Hello,

I just made this formula and thought it could save someone in the future some time.  Entering this into a formula field will give you the full state name based on abbreviation, just do a simple find and replace for "Field" in excel to edit the formula for your specific need.

if(Field='AL','Alabama',if(Field='AK','Alaska',if(Field='AZ','Arizona',if(Field='AR','Arkansas',if(Field='CA','California',if(Field='CO','Colorado',if(Field='CT','Connecticut',if(Field='DE','Delaware',if(Field='FL','Florida',if(Field='GA','Georgia',if(Field='HI','Hawaii',if(Field='ID','Idaho',if(Field='IL','Illinois',if(Field='IN','Indiana',if(Field='IA','Iowa',if(Field='KS','Kansas',if(Field='KY','Kentucky',if(Field='LA','Louisiana',if(Field='ME','Maine',if(Field='MD','Maryland',if(Field='MA','Massachusetts',if(Field='MI','Michigan',if(Field='MN','Minnesota',if(Field='MS','Mississippi',if(Field='MO','Missouri',if(Field='MT','Montana',if(Field='NE','Nebraska',if(Field='NV','Nevada',if(Field='NH','New Hampshire',if(Field='NJ','New Jersey',if(Field='NM','New Mexico',if(Field='NY','New York',if(Field='NC','North Carolina',if(Field='ND','North Dakota',if(Field='OH','Ohio',if(Field='OK','Oklahoma',if(Field='OR','Oregon',if(Field='PA','Pennsylvania',if(Field='RI','Rhode Island',if(Field='SC','South Carolina',if(Field='SD','South Dakota',if(Field='TN','Tennessee',if(Field='TX','Texas',if(Field='UT','Utah',if(Field='VT','Vermont',if(Field='VA','Virginia',if(Field='WA','Washington',if(Field='WV','West Virginia',if(Field='WI','Wisconsin',if(Field='WY','Wyoming','Other'))))))))))))))))))))))))))))))))))))))))))))))))))

Have a great day!
I want to create a validation rule to prevent EchoSign Agreement to be sent for signing until the Opportunity Probability has reached 90%. Please help it's urgent.
I have three objects. Two standard and one custom.
The standard objects are: Account and Opportunity.
The custom object is an object called Billing_Profile__C.

AccountId is the common field in all three objects. I am able to write a SOQL query like this.

Select o.Name, o.Id, o.Competitor__c, o.Amount, o.AccountId From Opportunity o WHERE o.AccountId NOT IN (Select  b.Account__c From Billing_Profile__c b)


This gives me a list of all the opportunities that have been created on accounts that do not have a billing profile. I want to put this in a validation rule on the opportunity object so that my user is not able to create an opportunity for any account that does not have a billing profile.

Firstly, instead of my query that simply returns a list of opportunities, how do I get the count of billing profiles for an account on an opportunity.

Secondly, how can I use that information in a validation rule when the user is creating this opportunity.

I have attempted to write a validation using VLOOKUP function. This is the rule I wrote.

VLOOKUP(
$ObjectType.Billing_Profile__c.Fields.Account__c,
$ObjectType.Billing_Profile__c.Fields.Name,
AccountId) <> AccountId
I am not sure if this rule is working as expected. I am getting an error on every save, regardless of the data. How can I correct this situation? Is there some way to log the values for each of the parameters I am sending? Can I test my function in the execute anonymous window?

Hello,

I just made this formula and thought it could save someone in the future some time.  Entering this into a formula field will give you the full state name based on abbreviation, just do a simple find and replace for "Field" in excel to edit the formula for your specific need.

if(Field='AL','Alabama',if(Field='AK','Alaska',if(Field='AZ','Arizona',if(Field='AR','Arkansas',if(Field='CA','California',if(Field='CO','Colorado',if(Field='CT','Connecticut',if(Field='DE','Delaware',if(Field='FL','Florida',if(Field='GA','Georgia',if(Field='HI','Hawaii',if(Field='ID','Idaho',if(Field='IL','Illinois',if(Field='IN','Indiana',if(Field='IA','Iowa',if(Field='KS','Kansas',if(Field='KY','Kentucky',if(Field='LA','Louisiana',if(Field='ME','Maine',if(Field='MD','Maryland',if(Field='MA','Massachusetts',if(Field='MI','Michigan',if(Field='MN','Minnesota',if(Field='MS','Mississippi',if(Field='MO','Missouri',if(Field='MT','Montana',if(Field='NE','Nebraska',if(Field='NV','Nevada',if(Field='NH','New Hampshire',if(Field='NJ','New Jersey',if(Field='NM','New Mexico',if(Field='NY','New York',if(Field='NC','North Carolina',if(Field='ND','North Dakota',if(Field='OH','Ohio',if(Field='OK','Oklahoma',if(Field='OR','Oregon',if(Field='PA','Pennsylvania',if(Field='RI','Rhode Island',if(Field='SC','South Carolina',if(Field='SD','South Dakota',if(Field='TN','Tennessee',if(Field='TX','Texas',if(Field='UT','Utah',if(Field='VT','Vermont',if(Field='VA','Virginia',if(Field='WA','Washington',if(Field='WV','West Virginia',if(Field='WI','Wisconsin',if(Field='WY','Wyoming','Other'))))))))))))))))))))))))))))))))))))))))))))))))))

Have a great day!
Hello Salesforce Coders,

I have a problem, and it's not giving me warm fuzzies inside.  Quick disclaimer, I'm not experienced at coding, but I'm learning, and I'm very interested in it.  I have written some APEX that will update a field on one SObject based on a field being updated on another SObject.  I've bulkified it, and it works great in our sandbox.  Even when I dataload 200+ records, it's great, I'm happy.  However, now that I've gotten to the step to write test code, I am confounded by my predicament.  When I run the code via test the field that needs to be updated (after the update of the other field) will not update, so my final assertion is wrong and my test code fails.  I can get more detailed, but I figured I would keep things vague for now, and if anyone is interested, they can respond to this post and throw down some knowledge.

Thanks for your time!
Patrick
Hi Guys,

I want to redirec to a url basing on the IF codntion on clicking on the standard page. For this i am creating a custom button and i am exectuing javascript.

i.e., using this condtion {!IF(logical_test, value_if_true, value_if_false)}  ..how to redirec to a url

Thanks,
Bujji
  • April 11, 2014
  • Like
  • 0

I'm a relative newbie looking for some help.  Don't laugh, you were there once, too..  :(  

 

Here's the deal.  We have a custom link (button) on a standard account page.  The javascript is supposed to take the value of the custom physical_address__c field (textarea) and copy it to the standard BillingAddress fields (BillingStreet, BillingCity, etc).

 

Everything works when there is only one line in the custom field; but if the user has entered a line feed / carriage return (as many do), the script produces an ILLEGAL TOKEN error.

 

I've read everything I could find about stripping line feeds out using javascript, but so far no luck.  I suspect it's because I haven't figured out how to strip the characters before assigning the field value to a javascript variable.  Original code is below, for reference.

 

Any help out there?  I would really appreciate it..

 

Thanks,

 

Lewis 

 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
var a = new sforce.SObject("Account");
a.id = "{!Account.Id}";

a.BillingStreet = "{!Account.Physical_Address__c}";
a.BillingCity = "{!Account.Physical_City__c}";
a.BillingState = "{!Account.Physical_State__c}";
a.BillingPostalCode = "{!Account.Physical_Postal_Code__c}";
a.BillingCountry = "{!Account.Physical_Country__c}";
result = sforce.connection.update([a]);
window.location.reload();

Hi all, i'm working on a Manual Request pushbutton that send a chatter post to some other user for alerting.

 

I succesfully create the code, something like this:

 


var msg='bla bla bla bla';

var cm=new sforce.SObject("FeedItem"); 
cm.ParentId='{!Opportunity.Id}'; 
cm.Body=msg; 


How can i introduce the mention for user that i need to alert?

Can i put it in msg string directly, like...

var msg='@user bla bla bla';

have to enclose in brakets?

 

thank you all

Not really a question, but  solution I thought might be helpful to others:

 

Due to the nature of most backoffice (and frontoffice, for that matter) systems, the standard Address object in salesforce does not work well with integrations, especially if you are using Salesforce.com as the system of record for some addresses.  Most of these systems use a dedicated field for each address line.   We need our street address field to fit into our accounting system limitations, which are:

1. Maxium of 30 characters per line

2. No more than two lines

 

Anyway, the answer for me was some fairly basic Regex for the BillingStreet Field:

NOT(
OR(
REGEX(
BillingStreet,
".{0,30}"
),
REGEX(
BillingStreet,
".{0,30}\r\n.{0,30}"
)
)
)

My regex logic:

Must be:
Empty or Single line less than 31 characters:
.{0,30}
Two lines with less than 31 characters each line:
.{0,30}\r\n.{0,30}

You can also do this with negative enforcement, but the positive model is much cleaner (example shown with 60 character limit instead of 30):

NOT:
2 or more CRLFs
(.*\r\n){2,}.*
More than 60 characters on single line
.{61,}
More than 60 characters on first line of two
.{61,}\r\n.*
More than 60 characters on second line of two
.*\r\n.{61,}

I learned the following about SF regex while doing this:

1. It does not appear to operate in multi-line mode (IE the $ zero-width match does not match the end of each line, just the end of the field)

2. The dot (.) does not match EOL characters (\r and \n)

3. Your regex has to match the entire field - all lines to be true.   In other workds, .* will not match a multi-line field.

4. To match the entire field regardless of the number of lines you would use (.*\r\n){*}

5. SF Address field uses \r\n as their EOL for the purposes of regex (I think this is different than the export, which is supposed to use just \n).

 

Enjoy,

 

Brandy Peterson