• Datajunkie
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies

First off, I confess to being a complete newbie when it comes to Apex development. So I set up a code consult at Dreamforce, and was thrilled to get the help of two wonderful guys, who were able to show me how to write a really simple, basic trigger that we badly need. They also told me that before I could deploy it, I had to have a test class first. I already had a test class in my Sandbox (and in production, for that matter) written by Astadia for a previous project. It appeared to work fine as a test, so they told me all I needed to do was go home and deploy both the new trigger and the test class. Unfortunately, when I tried to do that, the deployment failed - with four errors. Two were new validation rules that weren't in place the last time my Sandbox had been refreshed (and that only applied to the functions called by the test class, not those in my new trigger), and two others were errors I don't understand, but seem to be telling me that my test code isn't sufficient. Namely:

 

*OpportunityAfterUpdate - Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

*Deploy Error - Average test coverage across all Apex Classes and Triggers is 20% at least 75% test coverage is required

 

BTW - I'm trying to deploy the code from the Sandbox using the new Deploy Change Sets function. Maybe the problem is that I have to use a different tool? Honestly, I'm kind of clueless.

 

So it looks like I need new test code, but I'm at a total loss for where to even start. My trigger is really pretty small and only calls a few functions, so it seems like my test code should only need to be simple too, but like I said - I'm at a total loss for where to even start. I'm hoping one of you can help me out!

 

My trigger simply creates a new record in a related list whenever a new Opportunity is created with a certain record type. We have 3 record types, and the only one that this should *not* fire for is called "ADM Opportunity", so we used that as a "not equals" instead of specifying two types for "equals".  The related object is called shared_sale__c, and only 3 fields need to be filled in with the new record. The opportunity_ss__c field (which is the master-detail relationship), the rep__c field (lookup to user table, populated with the owner of the opportunity) and the percent_share__c field (set to 100). I've copied the full trigger below, if that helps.

 

What all should I put in the test code? The one created by Astadia actually creates a new account, then a new related opportunity, and then populates a bunch of fields. And apparently that's not sufficient to test my new trigger.

 

Any help, advice, tips - anything at all - would be welcome!

 

trigger OpportunitySplitTrigger on Opportunity (after insert) {

list <recordtype> soqlret = [select id from recordtype where name = 'ADM Opportunity'];

id nosplitid = null;
if (soqlret.size()>0){
nosplitid = soqlret[0].id;
}

list<shared_sale__C> listOpportunitysplits = new list<shared_sale__C>();

for (Opportunity o :trigger.new){

if (o.recordtypeid != nosplitid){

shared_sale__C ss = new shared_sale__C();
ss.percent_share__c =100;
ss.rep__c = o.ownerid;
ss.opportunity_ss__c = o.id;

listOpportunitysplits.add(ss);
}
}
insert listOpportunitysplits;

}

I have a user who just installed the Office Connector from inside SF (in the Desktop Integration section of Personal Setup), and it appears to have installed a version 4.0 of the toolkit.

 

He's getting the "Can't find project or library" error that others have reported getting as a result of a mismatch between Version 2.0 of the toolkit and Version 6.16 of the Excel Connector.

 

Has there been an updated version of the Excel Connector that will work with Version 4.0 of the toolkit? If not, how do I downgrade him back to Version 3.0, since the only version that will download from SF setup is version 4.0?  

 

This is not the most technical of users, and I'm supporting him from 200 miles away, so I can't just go to his computer and do it for him. So asking him to go to the Developer Toolkit type sites and figure out what to do is asking for disaster. Please help!

I need a custom formula field in the User object to calculate YTD Quota per person. So far, every formula I try runs into the "No Formula >5,000 Characters" rule, or it's so simple that too much falls through the cracks. Can anyone think of a way to simplify?

 

The rules are deceptively simple...

 

1) Each rep can have a different annual quota, split into a monthly goal.

2) Each rep gets two months "free" after their hire date before quotas start accumulating. If hired after the 15th of the month, they get that month "free" too.

3) Our fiscal year goes from 2/1 to 1/31

4) I've been determining the current fiscal month being reported by extracting the month from today's date,  and if it's January, setting the fiscal month # to 11 (December), or if it's February, setting the fiscal month # to 12, otherwise taking the month number - 2.

 

I've been approaching this by trying to capture the date the quota starts, then using that to determine where in the fiscal year this falls, and then determine how many months they get "free" that year versus the number of months elapsed so far this year.  But like I said, that's running into the character limit. Ultimately, I've been trying to find a way to capture the # of months I should multiply by the monthly quota (bold, italic, underlined below). But if someone can think of another way to go about it, I'm all ears.

 

I'm probably missing something terribly obvious, so I'm hoping a fresh set of eyes will see something that I'm overlooking because I'm trying to be too complicated.

 

Example:

 

Rep A

Hire Date  4/1/06

Date Quota Starts  6/1/06 (far prior to current FY)

Annual Quota  $500,000

Monthly Quota  $41,666.67

Current Reporting Month:  November 2009, which is fiscal month #10 of the current year

YTD Quota should be $416,667 or Monthly Quota *10 (same as fiscal month #)

 

Rep B

Hire Date  5/1/09

Date Quota Starts  7/1/09

Annual Quota  $600,000

Monthly Quota  $50,000

Current Reporting Month - November, fiscal month #10

YTD Quota should be $500,000 or Monthly Quota *5 (this is where I get complicated, trying to capture the month of the Date Quota Started and adjusting to the fiscal month by -2 if it's March-December, or forcing if it's Jan or Feb)

 

Rep C

Hire Date 11/28/09

Date Quota Starts  1/28/10

Annual Quota $480,000

Monthly Quota $40,000

Current Reporting Month - November, fiscal month #10

YTD Quota should be $0 or Monthly Quota * 0 , since the Date Quota Starts > the start of the current fiscal month  (and this is where I've totally failed, since this goes into another year, and the month has to be forced because it's calendar month #1, but fiscal month #12)

 

Ideas? Suggestions? Anything? I'm desperate!

I'm trying to determine if something is possible, and before I tell management it's not, I wanted to make sure that there wasn't any other way to get around this.
 
We are buying a cross-reference database that shows every valid Zip Code in the US and matches them up to a Metropolitan Statistical Area, as well as the County. Management wants to have a field for County and MSA in the Account record that pulls the values from this database.
 
i.e. if the Account has a ShippingPostalCode of 30004, he wants the County field to automatically be filled in with "Fulton" and the MSA field to be filled in with "Atlanta" (which comes from this database).
 
I can get the data from the database into a custom object in Salesforce, but how do I match up the ShippingPostalCode to this custom object so that the formula field will automatically populate the County and MSA fields?
 
It sounds like the VLOOKUP formula is exactly what I need, but it only works in validation rules - which will do me no good at all.
 
For obvious reasons, I can't write a workflow rule for every possible zip code in the US and then tie it to a field update that will fill in the County and MSA, but it sounds like that's the only way to do this.
 
Please tell me I'm wrong! Is there some other way to do this?
I need some help finding a "best practices" kind of formula to handle this. We are changing to using a custom fiscal year (based on 4.4.5) The idea is that 3 days after the close of the fiscal month, you can no longer close a sale in that prior month. On the 4th day after the month closes, we run reports, and we can't have anyone going back and making entries in a month that's already been reported to the public. (Much like the way Accounting has to close each month. with no retroactive entries)
 
Example:  Fiscal June (2008) ended June 21st.  The reps have until June 24th to update any opportunities as having closed in June. I need a validation rule that, on June 25th, if someone tried to close a sale in fiscal June (or earlier), it will error out and say, "You've tried to close an opportunity during a month that is already closed. Please close this sale during the current month."
 
Before we moved to a custom fiscal year, I had a single formula that worked forever, using the MONTH() and DAY() functions. (Saying if it was greater than the 4th day of the month, the close date can't be less than the first day of the current month.) But those won't work for fiscal months.
 
Even trying to write a formula with the exact date ranges is giving me trouble. I can't get a single formula that can handle all 12 months in the year. I can't even get one that will handle two months, for that matter. I keep getting syntax errors. Too many OR and AND statements nested. (I can't say if it's a salesforce limitation or just my own problems with writing the formula!)
 
I could write 12 different validation rules for each year - one for each month. In that case, I'd write something like:
 
AND(
          OR(
                  ISNEW(),
                  ISCHANGED( StageName ),
                  ISCHANGED( CloseDate)
                  ),
           IsClosed = true,
           TODAY()>DATE(2008,6,24),
           CloseDate <DATE(2008,6,22)
         )
 
for each month (this one being June).
 
But I'd prefer to have it in one formula. Even something like this would have to be re-written every year, but I'd rather re-write one formula a year isntead of 12! So I'd rather have one formula that could handle it forever - like the one I could use when it was a Calendar Month.  But that may be asking for too much.
 
Any suggestions?
 
Thanks!!


Message Edited by Datajunkie on 06-27-2008 10:37 AM
I need to write some code to create a new record in a related list whenever a record is first created in the main object, and I don't even know where to start.
 
Bottom line, I'm trying to find a way to capture shared sale information without having to wait for SFDC to get around to it. (Management won't wait.) I've got a custom object "Shared Sale" that's a child to the master object Opportunities. It has 3 basic fields:
 
Rep
Percent Share
Volume Credit (calculated, based on Percent Share times Opportunity.Amount)
 
Whenever a new opportunity is created (just the first time), I need code that will create a "default record" in the Shared Sale object with the "Rep" field populated with the Owner, and the "Percent Share" set to 100. (Volume credit will take care of itself.) Otherwise, the sales person will have to remember to always create that record themselves - which means it will happen about 15% of the time, if I'm lucky. If it is a shared sale, they will go into the default record and change their own percent, then add the 2nd or 3rd person and their respective percents. But if it isn't shared, I still need a record in that related object with the owner given 100% credit.
 
I don't even know where to start looking to find the tools I need to do this. I think I need to write a Trigger, but that's just a guess. I'm a total newbie to programming in SFDC, but I've got a little coding under my belt in other apps. I'm very good at teaching myself, but I don't want to spend days hunting through the DFC trying to find the one piece of information I need. Can anyone point me in the right direction? Code words to search on, areas on DFC to focus my search on? Any help is greatly appreciated!
Long story shortened...
 
Our Opportunities are often shared sales with other reps. The Sales Team related list is nice to capture who they are, but that's all it can do. I need to capture not only who they are, but what percent of the sale they get credit for, what that equates to in terms of "volume credit", the commission amount paid to each, and the date paid.
 
The end product will simply be a report that shows the total dollars sold for each rep - which will sometimes include a partial credit sale. Example:
 
Jane Smith sold one Opp by herself, for $100 (is listed as the owner of the Opp)
John Doe sold one Opp by himself, for $200 (is listed as the owner of the Opp)
Jane and John cooperated on another Opp, for $100. Jane is the owner of the Opp, and for this sale, she should receive 75% credit, with John to get 25%
 
The report needs to show:
 
Jane Smith  $175
John Doe   $225
 
Sounds really simple, but is driving me up the wall.
 
I tried creating multiple fields on the Opportunity object, which worked just fine. The data entry would be easy, and the display of information very easy to understand. But then I can't report on it in a useful way, because I can't combine the Amount field with the two Shared Volume fields I created, and match up the rep at the same time. I think the right thing to do is to have a related list, similar to that Sales Team list, but with more fields.
 
I created a custom object - Shared_Sales, with a master-detail relationship to Opportunity. Then I created the fields for Rep, Percent Credit, Commission Paid, and Commission Date. But the "Volume Credit" field should be a calculation of the Opportunity Amount times the Percent Credit (my custom field in the custom object). I can't seem to make the formula "reach back" to the Opportunity record to capture the Amount.
 
I made an S-Control which can do it, but I can't make that S Control show up in the related list on the Opportunity page. Having just the name and percent is good, but they're going to want to see the exact $ volume that they'll receive credit for.
 
That's not even to mention the problem of trying to figure out how to populate the related list with a default record if there are no additional reps. (i.e. - the Owner needs to get 100% credit if there is no one else involved, so I can report on the "Volume Credit" field as a whole).
 
If I'm totally barking up the wrong tree, please tell me! This seems like such a simple function, and management is absolutely adamant that we *must* be able to do this. I've already spent 2 days on this, and I'm no closer to a solution than when I started.
 
HELP!
I need to be able to repeat the name of the Opportunity Owner in a second section of the page, but so far, the only field I can merge with is OwnerID - and a string of random letters and numbers isn't exactly what I'm looking for.
 
The idea is that we have "shared sales" where two or three people share credit for a particular sale. We need to store their names and the percentages of credit for each one. I've added fields for the extra two reps (lookups to Users), and for their percentages (defaulting to 0%). But to make things crystal clear, I want the owner's name to appear in the section too - defaulted to 100%, but with a validation rule that makes sure the sum of all 3 percent fields = 100%. Obviously, I don't want them changing the duplicate Owner field. I'm hoping I can make it read-only. But I do want it to show up to make it absolutely clear who has what percentage credit.
 
Is there a way to merge my duplicate field with the Owner's name instead of the ID? It's obviously a two-step link - it starts with the OwnerID on the current object, but then has to link to the Users Object to grab the associated Name. Fancy formula work, maybe?
I need some help finding a "best practices" kind of formula to handle this. We are changing to using a custom fiscal year (based on 4.4.5) The idea is that 3 days after the close of the fiscal month, you can no longer close a sale in that prior month. On the 4th day after the month closes, we run reports, and we can't have anyone going back and making entries in a month that's already been reported to the public. (Much like the way Accounting has to close each month. with no retroactive entries)
 
Example:  Fiscal June (2008) ended June 21st.  The reps have until June 24th to update any opportunities as having closed in June. I need a validation rule that, on June 25th, if someone tried to close a sale in fiscal June (or earlier), it will error out and say, "You've tried to close an opportunity during a month that is already closed. Please close this sale during the current month."
 
Before we moved to a custom fiscal year, I had a single formula that worked forever, using the MONTH() and DAY() functions. (Saying if it was greater than the 4th day of the month, the close date can't be less than the first day of the current month.) But those won't work for fiscal months.
 
Even trying to write a formula with the exact date ranges is giving me trouble. I can't get a single formula that can handle all 12 months in the year. I can't even get one that will handle two months, for that matter. I keep getting syntax errors. Too many OR and AND statements nested. (I can't say if it's a salesforce limitation or just my own problems with writing the formula!)
 
I could write 12 different validation rules for each year - one for each month. In that case, I'd write something like:
 
AND(
          OR(
                  ISNEW(),
                  ISCHANGED( StageName ),
                  ISCHANGED( CloseDate)
                  ),
           IsClosed = true,
           TODAY()>DATE(2008,6,24),
           CloseDate <DATE(2008,6,22)
         )
 
for each month (this one being June).
 
But I'd prefer to have it in one formula. Even something like this would have to be re-written every year, but I'd rather re-write one formula a year isntead of 12! So I'd rather have one formula that could handle it forever - like the one I could use when it was a Calendar Month.  But that may be asking for too much.
 
Any suggestions?
 
Thanks!!


Message Edited by Datajunkie on 06-27-2008 10:37 AM

I need a custom formula field in the User object to calculate YTD Quota per person. So far, every formula I try runs into the "No Formula >5,000 Characters" rule, or it's so simple that too much falls through the cracks. Can anyone think of a way to simplify?

 

The rules are deceptively simple...

 

1) Each rep can have a different annual quota, split into a monthly goal.

2) Each rep gets two months "free" after their hire date before quotas start accumulating. If hired after the 15th of the month, they get that month "free" too.

3) Our fiscal year goes from 2/1 to 1/31

4) I've been determining the current fiscal month being reported by extracting the month from today's date,  and if it's January, setting the fiscal month # to 11 (December), or if it's February, setting the fiscal month # to 12, otherwise taking the month number - 2.

 

I've been approaching this by trying to capture the date the quota starts, then using that to determine where in the fiscal year this falls, and then determine how many months they get "free" that year versus the number of months elapsed so far this year.  But like I said, that's running into the character limit. Ultimately, I've been trying to find a way to capture the # of months I should multiply by the monthly quota (bold, italic, underlined below). But if someone can think of another way to go about it, I'm all ears.

 

I'm probably missing something terribly obvious, so I'm hoping a fresh set of eyes will see something that I'm overlooking because I'm trying to be too complicated.

 

Example:

 

Rep A

Hire Date  4/1/06

Date Quota Starts  6/1/06 (far prior to current FY)

Annual Quota  $500,000

Monthly Quota  $41,666.67

Current Reporting Month:  November 2009, which is fiscal month #10 of the current year

YTD Quota should be $416,667 or Monthly Quota *10 (same as fiscal month #)

 

Rep B

Hire Date  5/1/09

Date Quota Starts  7/1/09

Annual Quota  $600,000

Monthly Quota  $50,000

Current Reporting Month - November, fiscal month #10

YTD Quota should be $500,000 or Monthly Quota *5 (this is where I get complicated, trying to capture the month of the Date Quota Started and adjusting to the fiscal month by -2 if it's March-December, or forcing if it's Jan or Feb)

 

Rep C

Hire Date 11/28/09

Date Quota Starts  1/28/10

Annual Quota $480,000

Monthly Quota $40,000

Current Reporting Month - November, fiscal month #10

YTD Quota should be $0 or Monthly Quota * 0 , since the Date Quota Starts > the start of the current fiscal month  (and this is where I've totally failed, since this goes into another year, and the month has to be forced because it's calendar month #1, but fiscal month #12)

 

Ideas? Suggestions? Anything? I'm desperate!

I'm trying to determine if something is possible, and before I tell management it's not, I wanted to make sure that there wasn't any other way to get around this.
 
We are buying a cross-reference database that shows every valid Zip Code in the US and matches them up to a Metropolitan Statistical Area, as well as the County. Management wants to have a field for County and MSA in the Account record that pulls the values from this database.
 
i.e. if the Account has a ShippingPostalCode of 30004, he wants the County field to automatically be filled in with "Fulton" and the MSA field to be filled in with "Atlanta" (which comes from this database).
 
I can get the data from the database into a custom object in Salesforce, but how do I match up the ShippingPostalCode to this custom object so that the formula field will automatically populate the County and MSA fields?
 
It sounds like the VLOOKUP formula is exactly what I need, but it only works in validation rules - which will do me no good at all.
 
For obvious reasons, I can't write a workflow rule for every possible zip code in the US and then tie it to a field update that will fill in the County and MSA, but it sounds like that's the only way to do this.
 
Please tell me I'm wrong! Is there some other way to do this?
Hello
As a solution to a question I posted the other day (http://community.salesforce.com/sforce/board/message?board.id=general_development&thread.id=23809) someone suggested using a VLOOKUP (which is a brilliant idea :smileyhappy:)

Now I've been brave and set up a custom object with two fields in it:

Custom object = Membership_Category_for_Lookup (that's the object name)
Fields = Base_Fee and Membership_Category

So looking at the help section, I thought my VLOOKUP formula should be:

VLOOKUP($ObjectType.Membership_Category_for_Lookup.Fields.Base_Fee,
$ObjectType.Membership_Category_for_Lookup.Fields.Name,
 Membership_Category__c )

But I'm getting an error that says the field $ObjectType.Membership_Category_for_Lookup.Fields.Base_Fee doesn't exist.

I'm a bit stumped. I've tried several things like using the API name and so on, but no luck.

Anyone got any suggestions?

Thanks
Nicole
Long story shortened...
 
Our Opportunities are often shared sales with other reps. The Sales Team related list is nice to capture who they are, but that's all it can do. I need to capture not only who they are, but what percent of the sale they get credit for, what that equates to in terms of "volume credit", the commission amount paid to each, and the date paid.
 
The end product will simply be a report that shows the total dollars sold for each rep - which will sometimes include a partial credit sale. Example:
 
Jane Smith sold one Opp by herself, for $100 (is listed as the owner of the Opp)
John Doe sold one Opp by himself, for $200 (is listed as the owner of the Opp)
Jane and John cooperated on another Opp, for $100. Jane is the owner of the Opp, and for this sale, she should receive 75% credit, with John to get 25%
 
The report needs to show:
 
Jane Smith  $175
John Doe   $225
 
Sounds really simple, but is driving me up the wall.
 
I tried creating multiple fields on the Opportunity object, which worked just fine. The data entry would be easy, and the display of information very easy to understand. But then I can't report on it in a useful way, because I can't combine the Amount field with the two Shared Volume fields I created, and match up the rep at the same time. I think the right thing to do is to have a related list, similar to that Sales Team list, but with more fields.
 
I created a custom object - Shared_Sales, with a master-detail relationship to Opportunity. Then I created the fields for Rep, Percent Credit, Commission Paid, and Commission Date. But the "Volume Credit" field should be a calculation of the Opportunity Amount times the Percent Credit (my custom field in the custom object). I can't seem to make the formula "reach back" to the Opportunity record to capture the Amount.
 
I made an S-Control which can do it, but I can't make that S Control show up in the related list on the Opportunity page. Having just the name and percent is good, but they're going to want to see the exact $ volume that they'll receive credit for.
 
That's not even to mention the problem of trying to figure out how to populate the related list with a default record if there are no additional reps. (i.e. - the Owner needs to get 100% credit if there is no one else involved, so I can report on the "Volume Credit" field as a whole).
 
If I'm totally barking up the wrong tree, please tell me! This seems like such a simple function, and management is absolutely adamant that we *must* be able to do this. I've already spent 2 days on this, and I'm no closer to a solution than when I started.
 
HELP!
I need to be able to repeat the name of the Opportunity Owner in a second section of the page, but so far, the only field I can merge with is OwnerID - and a string of random letters and numbers isn't exactly what I'm looking for.
 
The idea is that we have "shared sales" where two or three people share credit for a particular sale. We need to store their names and the percentages of credit for each one. I've added fields for the extra two reps (lookups to Users), and for their percentages (defaulting to 0%). But to make things crystal clear, I want the owner's name to appear in the section too - defaulted to 100%, but with a validation rule that makes sure the sum of all 3 percent fields = 100%. Obviously, I don't want them changing the duplicate Owner field. I'm hoping I can make it read-only. But I do want it to show up to make it absolutely clear who has what percentage credit.
 
Is there a way to merge my duplicate field with the Owner's name instead of the ID? It's obviously a two-step link - it starts with the OwnerID on the current object, but then has to link to the Users Object to grab the associated Name. Fancy formula work, maybe?