• nbeekman
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hello,

 

I am working on developing a tabbed page in Visualforce but would like to know which tab the user is viewing.  If there is a way to determine this, I can cut a lot of code and buttons from the page view.

 

Anyone have a suggestion or a fast code example?

 

Thanks

Hello,

 

Have a issue and cannot figure out a solution.  I have an opportunity trigger on insert or update that I need to get information from another object who's lookup Id is in the opportunity.  I can write a SOQL to retrieve it but this trigger is also fired off on a bulk update of 8k plus records so a SOQL will not work.

 

example:  This will trigger whenever an opportunity is updated singlely or in bulk. The Opportunity has a lookup relationship of building__c (which is a custom object), I need to retrieve two fields FieldA__c and FieldB__c from Building within the trigger.  This update the field with new values.

 

Any sugguestions

 

Thanks

Hello,

 

I am getting an error on line 3 - Unexpected "=".  Here is what is wierd that it gives this erron in Eclipse and the Development Console but executes fine when done in Execute Anonymous.  But last week before summer 13 release it worked fine.

 

The CreateBaseForTesting() is a class that creates a temporary Oppportunity, Account, Contacts, etc.

 

Doesn't make sense... 

 

Any suggestions.

 

    Static list<Opportunity> opp;
    Create_Objects_Helper.CreateBaseForTesting();
	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test for Deployment' limit 1];
	if(opp.isEmpty())
		throw new MyException('>>>>>> No Opportunities found. <<<<<<');
    
	//get the factors in the static object
	Opportunity temp_opp = opp.get(0);
	temp_opp.Sales_Path__c = 'Operations input required';
	temp_opp.Inst_Discount__c = 0.30;
		
	System.debug('Updating Opportunities :' + temp_opp);
	update temp_opp;

 

I have an issue and cannot find any good help or explanation of why I am getting this error ' below is the code calling another class to create Temp SObjects.    Or is there a better way to call a class method to create temp objects?  I am new to Apex programming and any comments appreciated.

 

Error message

 

"Method must define a body" on CommissionTestSuite.cls

 

 
Code calling the code at the end of this message.
 
/**
 * This class contains unit tests for validating the behavior of Commission feature
 * of Calculate Pricing trigger 
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
public with sharing class CommissionTestSuite {

// ********************** ERROR IS ON THE LINE BELOW ************************************
// ********************** METHOD MUST DEFINE A BODY ************************************

	Create_Objects_Helper.CreateBaseForTesting();

	static list<Opportunity> opp;
	static
	{
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
		if(opp.isEmpty())
			throw new MyException('No Opportunities found.');
	}
	
	
		
	// This static method calculates the Commission for the VP when the Payment model is Upfront
	static testMethod void Calculate_VP_Commission_Upfront() {
		
        //get the selected Opportunity
        opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
        Opportunity temp_opp = opp.get(0);
        temp_opp.SW_Pay_MD__c = 'Upfront';
        update temp_opp;
    }
    
    // This static method calculates the Commission for the VP when the Payment model is Monthly
	static testMethod void Calculate_VP_Commission_Monthly() {
		
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
        //get the selected Opportunity
        Opportunity temp_opp = opp.get(0);
        temp_opp.SW_Pay_MD__c = 'Monthly';
        update temp_opp;
    }
    
    // This static method calculates the Commission for the VP when the Payment model is Monthly
	static testMethod void Calculate_DIR_Commission_Monthly() {
		list<User> user = [select Id, Name from User where Name = 'Platform Integration' limit 1];
		User temp_user = user.get(0);
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
		temp_user.Title = 'Sales VP';
		update temp_user;
        //get the selected Opportunity
        Opportunity temp_opp = opp.get(0);
        temp_opp.OwnerId = user.get(0).Id;
        temp_opp.SW_Pay_MD__c = 'Monthly';
        Commision.Cal_Up_Commision_Dir('36 months', 544);
        Commision.Cal_MO_Commision_Dir(1000,'36 months',100);
        update temp_opp;
    }
    
    // This static method calculates the Commission for the VP when the Payment model is Monthly
	static testMethod void Calculate_DIR_Commission_Upfront() {
		list<User> user = [select Id, Name from User where Name = 'Platform Integration' limit 1];
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
		 User temp_user = user.get(0);
		 temp_user.Title = 'Sales VP';
		 update temp_user;
        //get the selected Opportunity
        Opportunity temp_opp = opp.get(0);
        temp_opp.SW_Pay_MD__c = 'Upfront';
        update temp_opp;
    }
    
    static testmethod void Calculate_Commission_12_Months()
    {
    	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
    	//get the Opp and set the Term to 12 months
    	Opportunity temp_opp = opp.get(0);
    	temp_opp.Term_1__c = '12 months';
    	update temp_opp;
    }
    
    static testmethod void Calculate_Commission_24_Months()
    {
    	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
    	//get the Opp and set the Term to 12 months
    	Opportunity temp_opp = opp.get(0);
    	temp_opp.Term_1__c = '24 months';
    	update temp_opp;
    }
    
    static testmethod void Calculate_Commission_60_Months()
    {
    	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
    	//get the Opp and set the Term to 12 months
    	Opportunity temp_opp = opp.get(0);
    	temp_opp.Term_1__c = '60 months';
    	update temp_opp;
    }
    

}

 

 
I am trying to call this class.
 
//	Helper class to create Objects required for testing.
//
//		Account			'Envysion Test Account'
//		Opportunity 	'Envysion Test Opportunity'
//		Location	 	'Envysion Test Location' First Name = 'Envysion Test' Last Name = 'Location'
//		Bill To			'Envysion Test Bill To' First Name = 'Envysion Test' Last Name = 'Bill To'
//		Contact 		'Envysion Test Spokesperson' First Name = 'Envysion Test' Last Name = 'Spokesperson'
//		Site 			'Envysion Test Site'
//		Add Parts		'Test 25\' Cable'
//						'Test EnVR'
//						'Test Insight Software'
//						'Test Labor'
//
//	Created by: Norman Beekman 6/1/2013

public with sharing class Create_Objects_Helper {

	public void CreateBaseForTesting() {
        //	Delete any found Opportunity
		list<Opportunity> OpportunityList = new list<Opportunity>();
		OpportunityList = [Select Id, Sales_Status__c from Opportunity where Name = 'Envysion Test for Deployment'];
		
		if (!OpportunityList.isEmpty()) {
			system.debug('******************* Deleting any Opportunity - Envysion Test for Deployment *******************');
			//	Make sure we can delete the Opportunity
    		for (Opportunity op: OpportunityList) {
				if(op.Sales_Status__c != '3 - Committed'){
					op.Sales_Status__c = '3 - Committed';
				}
    		}
    		update OpportunityList;
			delete OpportunityList;
			OpportunityList.clear();
		}

        //	Delete any found Account
		list<Account> AccountList = new list<Account>();
		AccountList = [Select Id from Account where Name = 'Envysion, Inc Test'];
		
		if (!AccountList.isEmpty()) {
			system.debug('******************* Deleting any Account - Envysion, Inc *******************');
			Delete AccountList;
			AccountList.clear();
		}

        //	Delete any found Contact	Select r.Id, r.Name From RecordType r Where r.SobjectType = 'Contact'
		list<Contact> ContactList = new list<Contact>();
		ContactList = [Select Id from Contact where Name = 'Envysion Test Location' or Name = 'Envysion Test Bill To' 
			or Name = 'Envysion Test Spokesperson'];
		
		if (!ContactList.isEmpty()) {
			system.debug('******************* Deleting any Contact - Envysion, Inc *******************');
			delete ContactList;
			ContactList.clear();
		}

        //	Create a fresh Account
		if (AccountList.isEmpty()) {
			system.debug('******************* Creating Account - Envysion, Inc *******************');
			Account NewAccount = new Account(
        		Name = 'Envysion, Inc Test', BillingStreet  = '400 Centennial Pkwy, Suite 201', BillingCity = 'Louisville',
        		BillingState = 'Colorado', BillingPostalCode = '80027', BillingCountry = 'United States',
        		Phone = '303-590-2357'); 
			AccountList.add(NewAccount);
			if (!AccountList.isEmpty()) {
				insert AccountList;
			} 
		} 

        //	Create a fresh Contact
		system.debug('******************* CREATING Contacts - Envysion Test Bill To, Location, Spokesperson *******************');
		list<RecordType> RecordTypeList = new list<RecordType>();
		RecordTypeList = [Select r.Id, r.Name From RecordType r Where r.SobjectType = 'Contact'];
		Id BillToRecordID, SoldToRecordId, PersonRecordID;
    	for (RecordType rt: RecordTypeList) {
			if(rt.Name == 'Bill To'){
				BillToRecordID = rt.Id;
				system.debug('>>>>>>>>>>>>>>>>>>>> bill to ' + rt.Id);
			}
			if(rt.Name == 'Location (Sold To)'){
				SoldToRecordId = rt.Id;
				system.debug('>>>>>>>>>>>>>>>>>>>> Sold to ' + rt.Id);
			}
			if(rt.Name == 'Person'){
				PersonRecordID = rt.Id;
				system.debug('>>>>>>>>>>>>>>>>>>>> Person ' + rt.Id);
			}
    	}

		ContactList.add(new Contact(
			RecordTypeId = BillToRecordID, 
			FirstName = 'Envysion Test', LastName = 'Bill to',
			Account = AccountList.get(0), MailingStreet = '400 Centennial Pkwy Suite 201',
			MailingCity = 'Louisville', MailingState = 'Colorado', MailingPostalCode = '80027',
			MailingCountry = 'United States', Phone = '303-590-2357', Email = 'nbeekman@envysion.com')); 
		ContactList.add(new Contact(
			RecordTypeId =  SoldToRecordId, 
			FirstName = 'Envysion Test', LastName = 'Location',
			Account = AccountList.get(0), MailingStreet = '400 Centennial Pkwy Suite 201',
			MailingCity = 'Louisville', MailingState = 'Colorado', MailingPostalCode = '80027',
			MailingCountry = 'United States', Phone = '303-590-2357', Email = 'nbeekman@envysion.com')); 
		ContactList.add(new Contact(
			RecordTypeId = PersonRecordID, 
			FirstName = 'Envysion Test', LastName = 'Spokesperson',
			Account = AccountList.get(0), MailingStreet = '400 Centennial Pkwy Suite 201',
			MailingCity = 'Louisville', MailingState = 'Colorado', MailingPostalCode = '80027',
			MailingCountry = 'United States', Phone = '303-590-2357', Email = 'nbeekman@envysion.com')); 

		if (!ContactList.isEmpty()) {
			insert ContactList;
		}

        //	Create a fresh Opportunity and set its Properties
		//	NOTE: BillToID = ContactList.get(0), SoldToId= ContactList.get(1), PersonID= ContactList.get(2);
		system.debug('******************* CREATING Opportunity - Envysion Test for Deployment *******************');
		list<Pricebook2> PriceBooklist = [select Id, Name from Pricebook2 PB where PB.Name = 'Zuora Standard Pricebook march 2012'];
        Opportunity NewOpportunity = new Opportunity(
        	Name = 'Envysion Test for Deployment', Type = 'Initial Sale', AccountId = AccountList.get(0).Id, 
			CloseDate = System.today(), StageName = 'Closed Won', Sales_Status__c = '3 - Committed', 
			SW_Discount__c = 0.20, HW_Discount__c = 0.30, Inst_Discount__c = 0.20,
			Sold_To_Contact__c = ContactList.get(1).Id, Bill_To_Contact__c = ContactList.get(0).Id,
			BrandsonSite__c = 'Wendy', Multiplier__c = 1, of_EnVRs__c = 1, Sales_Path__c = 'Standard Order',
			Software_Cost__c = 0.0, Install_Cost__c = 0.0, Equipment_Cost__c = 0.0, Pricebook2Id = PriceBooklist.get(0).Id, 
			Extended_Warranty__c = 1, Term__c = 36, Term_1__c = '36 months', Lic_Fee_U__c = 0.0,
			HW_Pay_MD__c = 'Upfront', Inst_Pay_MD__c = 'Upfront', SW_Pay_MD__c = 'Monthly', TestOpp__c = false); 

		//Pbooklist.get(0).Id,
        
		OpportunityList.add(NewOpportunity);
			
		if (!OpportunityList.isEmpty() && !AccountList.isEmpty()) {
			insert OpportunityList;
			//	OpportunityList.get(0).Id)
		}
		
		//	Insert Product into new Opportunity
		list<OpportunityLineItem> OpportunityLineItemList = new list<OpportunityLineItem>();
		list<product2> Product2List = [Select p.Id From Product2 p Where p.Name = 'Test 25\' Cable' Limit 1];
		list<PricebookEntry> PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Not Applicable',
			SalesDescript__c = 'Test 25\' Cable',
			HasEnVR__c = False,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test 25\' Cable',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 1,
			UnitPrice = 24.925,
			SKU__c = 'TEST-01'
			)); 
		Product2List = [Select p.Id From Product2 p Where p.Name = 'Test EnVR'];
		PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Video',
			SalesDescript__c = 'Test EnVR',
			HasEnVR__c = true,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test EnVR',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 1,
			UnitPrice = 53.89,
			SKU__c = 'TEST-03'
			)); 
		Product2List = [Select p.Id From Product2 p Where p.Name = 'Test Insight Software'];
		PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Insight',
			SalesDescript__c = 'Test Insight Software',
			HasEnVR__c = False,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test Insight Software',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 1,
			UnitPrice = 53.89,
			SKU__c = 'TEST-04'
			)); 
		Product2List = [Select p.Id From Product2 p Where p.Name = 'Test Labor'];
		PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Not Applicable',
			SalesDescript__c = 'Test Labor',
			HasEnVR__c = False,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test Labor',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 10,
			UnitPrice = 124.75,
			SKU__c = 'TEST-02'
			)); 

		if (!OpportunityLineItemList.isEmpty()) {
			insert OpportunityLineItemList;
		}

		
	}	// End CreateBaseForTesting

}	// End Class

 

Hello,

 

I'm a bit concerned, the Apex Explorer tells me that the Unique ID length is 18 but when you run reports pulling this number its 15.  All URL's say its 18.  We are in the process of automating Salesforce with SAP in which SAP uses a 15 Character Unique Identifier.

 

So my question is, does it use a 15 or 18 character ID? 

Hello,

 

I am working on developing a tabbed page in Visualforce but would like to know which tab the user is viewing.  If there is a way to determine this, I can cut a lot of code and buttons from the page view.

 

Anyone have a suggestion or a fast code example?

 

Thanks

Hello,

 

I have a Visual Force Page that I need to test the controller.  Both are attached.  I cannot figure out how to create a testmethod to perform test against this page.  The controller code needs to execute so it can pass testing.

 

Any help with code would be appreciated.

 

Thanks

 

Visual Page Code:

<apex:page showheader="false" controller="systemStatusController">
	<style>
		ul li {
			margin: 10px 0;
		}
		ul.supportLevels li {
			margin: 5px 0;
			list-style: none;
			width:375px;
		}
		ul.supportLevels li span {
			float:right;
		}
	</style>
	<p class="systemDetails">
		<ul>
			<li>You have <a href="#">{!envrCount}</a> Locations with Envysion&nbsp;&nbsp;<a href="mailto:sales@envysion.com?subject=Add%20a%20Site%20to%20my%20Envysion%20Service">add new location</a></li>
			<li>You have {!cameraCount} Cameras across your Locations&nbsp;&nbsp;<a href="mailto:sales@envysion.com?subject=New%20Cameras%20for%20a%20Site">add/replace cameras</a></li>
			<li>Your support levels are:
				<ul class="supportLevels">
					<li>{!notifiesCount} Sites with <i>Envysion Notifies</i><span><a href="mailto:sales@envysion.com?subject=Upgrade%20my%20Envysion%20Support">upgrade</a></span></li>
					<li>{!respondsCount} Sites with <i>Envysion Responds</i><span><a href="mailto:sales@envysion.com?subject=Upgrade%20my%20Envysion%20Support">upgrade</a></span></li>
					<li>{!maintainsCount} Sites with <i>Envysion Maintains</i><span><a href="mailto:sales@envysion.com?subject=Upgrade%20my%20Envysion%20Support">upgrade</a></span></li>
				</ul>
			</li>
		</ul>
	</p>
</apex:page>

 

 

Class Controller code:

public with sharing class systemStatusController {
	private User currentUser;
	private Account currentAccount;
	private String defAcct;
	
	public void setDefaultAccount(String acctID) {
		this.defAcct = acctID;
	}
	
	public User getCurrentUser() {
		if(this.currentUser == NULL) {
			this.currentUser = [SELECT Id, FirstName, LastName, Alias, AccountId FROM User WHERE id = :UserInfo.getUserId()];
		}
		return this.currentUser;
	}
	
	public Account getCurrentAccount() {
		if(this.currentAccount == NULL) {
			User curUser = this.getCurrentUser();
			String accID = curUser.AccountId;
			if(accID == NULL || accID == '') {
				accID = this.defAcct;
			}
			this.currentAccount = [SELECT Id, Name FROM Account WHERE Id = :accID];
		}
		return this.currentAccount;
	}
	
	public Integer getEnvrCount() {
		Account curAcct = this.getCurrentAccount();
		Integer envrCount = [SELECT COUNT() FROM Envr__c WHERE Account__c = :curAcct.Id];
		return envrCount;
	}
		
	public Integer getCameraCount() {
		Account curAcct = this.getCurrentAccount();
		Integer camCount = [SELECT COUNT() FROM Camera__c WHERE Account__c = :curAcct.Id];
		return camCount;
	}
			
	public Integer getNotifiesCount() {
		Account curAcct = this.getCurrentAccount();
		Integer siteCount = [SELECT COUNT() FROM EnvySite__c WHERE Account__c = :curAcct.Id AND Support_Level__c = 'Notifies'];
		return siteCount;
	}
				
	public Integer getRespondsCount() {
		Account curAcct = this.getCurrentAccount();
		Integer siteCount = [SELECT COUNT() FROM EnvySite__c WHERE Account__c = :curAcct.Id AND Support_Level__c = 'Responds'];
		return siteCount;
	}
				
	public Integer getMaintainsCount() {
		Account curAcct = this.getCurrentAccount();
		Integer siteCount = [SELECT COUNT() FROM EnvySite__c WHERE Account__c = :curAcct.Id AND Support_Level__c = 'Maintains'];
		return siteCount;
	}
}

 

Hello,

 

I am getting an error on line 3 - Unexpected "=".  Here is what is wierd that it gives this erron in Eclipse and the Development Console but executes fine when done in Execute Anonymous.  But last week before summer 13 release it worked fine.

 

The CreateBaseForTesting() is a class that creates a temporary Oppportunity, Account, Contacts, etc.

 

Doesn't make sense... 

 

Any suggestions.

 

    Static list<Opportunity> opp;
    Create_Objects_Helper.CreateBaseForTesting();
	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test for Deployment' limit 1];
	if(opp.isEmpty())
		throw new MyException('>>>>>> No Opportunities found. <<<<<<');
    
	//get the factors in the static object
	Opportunity temp_opp = opp.get(0);
	temp_opp.Sales_Path__c = 'Operations input required';
	temp_opp.Inst_Discount__c = 0.30;
		
	System.debug('Updating Opportunities :' + temp_opp);
	update temp_opp;

 

I have an issue and cannot find any good help or explanation of why I am getting this error ' below is the code calling another class to create Temp SObjects.    Or is there a better way to call a class method to create temp objects?  I am new to Apex programming and any comments appreciated.

 

Error message

 

"Method must define a body" on CommissionTestSuite.cls

 

 
Code calling the code at the end of this message.
 
/**
 * This class contains unit tests for validating the behavior of Commission feature
 * of Calculate Pricing trigger 
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
public with sharing class CommissionTestSuite {

// ********************** ERROR IS ON THE LINE BELOW ************************************
// ********************** METHOD MUST DEFINE A BODY ************************************

	Create_Objects_Helper.CreateBaseForTesting();

	static list<Opportunity> opp;
	static
	{
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
		if(opp.isEmpty())
			throw new MyException('No Opportunities found.');
	}
	
	
		
	// This static method calculates the Commission for the VP when the Payment model is Upfront
	static testMethod void Calculate_VP_Commission_Upfront() {
		
        //get the selected Opportunity
        opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
        Opportunity temp_opp = opp.get(0);
        temp_opp.SW_Pay_MD__c = 'Upfront';
        update temp_opp;
    }
    
    // This static method calculates the Commission for the VP when the Payment model is Monthly
	static testMethod void Calculate_VP_Commission_Monthly() {
		
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
        //get the selected Opportunity
        Opportunity temp_opp = opp.get(0);
        temp_opp.SW_Pay_MD__c = 'Monthly';
        update temp_opp;
    }
    
    // This static method calculates the Commission for the VP when the Payment model is Monthly
	static testMethod void Calculate_DIR_Commission_Monthly() {
		list<User> user = [select Id, Name from User where Name = 'Platform Integration' limit 1];
		User temp_user = user.get(0);
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
		temp_user.Title = 'Sales VP';
		update temp_user;
        //get the selected Opportunity
        Opportunity temp_opp = opp.get(0);
        temp_opp.OwnerId = user.get(0).Id;
        temp_opp.SW_Pay_MD__c = 'Monthly';
        Commision.Cal_Up_Commision_Dir('36 months', 544);
        Commision.Cal_MO_Commision_Dir(1000,'36 months',100);
        update temp_opp;
    }
    
    // This static method calculates the Commission for the VP when the Payment model is Monthly
	static testMethod void Calculate_DIR_Commission_Upfront() {
		list<User> user = [select Id, Name from User where Name = 'Platform Integration' limit 1];
		opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
		 User temp_user = user.get(0);
		 temp_user.Title = 'Sales VP';
		 update temp_user;
        //get the selected Opportunity
        Opportunity temp_opp = opp.get(0);
        temp_opp.SW_Pay_MD__c = 'Upfront';
        update temp_opp;
    }
    
    static testmethod void Calculate_Commission_12_Months()
    {
    	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
    	//get the Opp and set the Term to 12 months
    	Opportunity temp_opp = opp.get(0);
    	temp_opp.Term_1__c = '12 months';
    	update temp_opp;
    }
    
    static testmethod void Calculate_Commission_24_Months()
    {
    	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
    	//get the Opp and set the Term to 12 months
    	Opportunity temp_opp = opp.get(0);
    	temp_opp.Term_1__c = '24 months';
    	update temp_opp;
    }
    
    static testmethod void Calculate_Commission_60_Months()
    {
    	opp = [select Name, Id, SW_Pay_MD__c from Opportunity where Name = 'Envysion Test Opportunity' limit 1];
    	//get the Opp and set the Term to 12 months
    	Opportunity temp_opp = opp.get(0);
    	temp_opp.Term_1__c = '60 months';
    	update temp_opp;
    }
    

}

 

 
I am trying to call this class.
 
//	Helper class to create Objects required for testing.
//
//		Account			'Envysion Test Account'
//		Opportunity 	'Envysion Test Opportunity'
//		Location	 	'Envysion Test Location' First Name = 'Envysion Test' Last Name = 'Location'
//		Bill To			'Envysion Test Bill To' First Name = 'Envysion Test' Last Name = 'Bill To'
//		Contact 		'Envysion Test Spokesperson' First Name = 'Envysion Test' Last Name = 'Spokesperson'
//		Site 			'Envysion Test Site'
//		Add Parts		'Test 25\' Cable'
//						'Test EnVR'
//						'Test Insight Software'
//						'Test Labor'
//
//	Created by: Norman Beekman 6/1/2013

public with sharing class Create_Objects_Helper {

	public void CreateBaseForTesting() {
        //	Delete any found Opportunity
		list<Opportunity> OpportunityList = new list<Opportunity>();
		OpportunityList = [Select Id, Sales_Status__c from Opportunity where Name = 'Envysion Test for Deployment'];
		
		if (!OpportunityList.isEmpty()) {
			system.debug('******************* Deleting any Opportunity - Envysion Test for Deployment *******************');
			//	Make sure we can delete the Opportunity
    		for (Opportunity op: OpportunityList) {
				if(op.Sales_Status__c != '3 - Committed'){
					op.Sales_Status__c = '3 - Committed';
				}
    		}
    		update OpportunityList;
			delete OpportunityList;
			OpportunityList.clear();
		}

        //	Delete any found Account
		list<Account> AccountList = new list<Account>();
		AccountList = [Select Id from Account where Name = 'Envysion, Inc Test'];
		
		if (!AccountList.isEmpty()) {
			system.debug('******************* Deleting any Account - Envysion, Inc *******************');
			Delete AccountList;
			AccountList.clear();
		}

        //	Delete any found Contact	Select r.Id, r.Name From RecordType r Where r.SobjectType = 'Contact'
		list<Contact> ContactList = new list<Contact>();
		ContactList = [Select Id from Contact where Name = 'Envysion Test Location' or Name = 'Envysion Test Bill To' 
			or Name = 'Envysion Test Spokesperson'];
		
		if (!ContactList.isEmpty()) {
			system.debug('******************* Deleting any Contact - Envysion, Inc *******************');
			delete ContactList;
			ContactList.clear();
		}

        //	Create a fresh Account
		if (AccountList.isEmpty()) {
			system.debug('******************* Creating Account - Envysion, Inc *******************');
			Account NewAccount = new Account(
        		Name = 'Envysion, Inc Test', BillingStreet  = '400 Centennial Pkwy, Suite 201', BillingCity = 'Louisville',
        		BillingState = 'Colorado', BillingPostalCode = '80027', BillingCountry = 'United States',
        		Phone = '303-590-2357'); 
			AccountList.add(NewAccount);
			if (!AccountList.isEmpty()) {
				insert AccountList;
			} 
		} 

        //	Create a fresh Contact
		system.debug('******************* CREATING Contacts - Envysion Test Bill To, Location, Spokesperson *******************');
		list<RecordType> RecordTypeList = new list<RecordType>();
		RecordTypeList = [Select r.Id, r.Name From RecordType r Where r.SobjectType = 'Contact'];
		Id BillToRecordID, SoldToRecordId, PersonRecordID;
    	for (RecordType rt: RecordTypeList) {
			if(rt.Name == 'Bill To'){
				BillToRecordID = rt.Id;
				system.debug('>>>>>>>>>>>>>>>>>>>> bill to ' + rt.Id);
			}
			if(rt.Name == 'Location (Sold To)'){
				SoldToRecordId = rt.Id;
				system.debug('>>>>>>>>>>>>>>>>>>>> Sold to ' + rt.Id);
			}
			if(rt.Name == 'Person'){
				PersonRecordID = rt.Id;
				system.debug('>>>>>>>>>>>>>>>>>>>> Person ' + rt.Id);
			}
    	}

		ContactList.add(new Contact(
			RecordTypeId = BillToRecordID, 
			FirstName = 'Envysion Test', LastName = 'Bill to',
			Account = AccountList.get(0), MailingStreet = '400 Centennial Pkwy Suite 201',
			MailingCity = 'Louisville', MailingState = 'Colorado', MailingPostalCode = '80027',
			MailingCountry = 'United States', Phone = '303-590-2357', Email = 'nbeekman@envysion.com')); 
		ContactList.add(new Contact(
			RecordTypeId =  SoldToRecordId, 
			FirstName = 'Envysion Test', LastName = 'Location',
			Account = AccountList.get(0), MailingStreet = '400 Centennial Pkwy Suite 201',
			MailingCity = 'Louisville', MailingState = 'Colorado', MailingPostalCode = '80027',
			MailingCountry = 'United States', Phone = '303-590-2357', Email = 'nbeekman@envysion.com')); 
		ContactList.add(new Contact(
			RecordTypeId = PersonRecordID, 
			FirstName = 'Envysion Test', LastName = 'Spokesperson',
			Account = AccountList.get(0), MailingStreet = '400 Centennial Pkwy Suite 201',
			MailingCity = 'Louisville', MailingState = 'Colorado', MailingPostalCode = '80027',
			MailingCountry = 'United States', Phone = '303-590-2357', Email = 'nbeekman@envysion.com')); 

		if (!ContactList.isEmpty()) {
			insert ContactList;
		}

        //	Create a fresh Opportunity and set its Properties
		//	NOTE: BillToID = ContactList.get(0), SoldToId= ContactList.get(1), PersonID= ContactList.get(2);
		system.debug('******************* CREATING Opportunity - Envysion Test for Deployment *******************');
		list<Pricebook2> PriceBooklist = [select Id, Name from Pricebook2 PB where PB.Name = 'Zuora Standard Pricebook march 2012'];
        Opportunity NewOpportunity = new Opportunity(
        	Name = 'Envysion Test for Deployment', Type = 'Initial Sale', AccountId = AccountList.get(0).Id, 
			CloseDate = System.today(), StageName = 'Closed Won', Sales_Status__c = '3 - Committed', 
			SW_Discount__c = 0.20, HW_Discount__c = 0.30, Inst_Discount__c = 0.20,
			Sold_To_Contact__c = ContactList.get(1).Id, Bill_To_Contact__c = ContactList.get(0).Id,
			BrandsonSite__c = 'Wendy', Multiplier__c = 1, of_EnVRs__c = 1, Sales_Path__c = 'Standard Order',
			Software_Cost__c = 0.0, Install_Cost__c = 0.0, Equipment_Cost__c = 0.0, Pricebook2Id = PriceBooklist.get(0).Id, 
			Extended_Warranty__c = 1, Term__c = 36, Term_1__c = '36 months', Lic_Fee_U__c = 0.0,
			HW_Pay_MD__c = 'Upfront', Inst_Pay_MD__c = 'Upfront', SW_Pay_MD__c = 'Monthly', TestOpp__c = false); 

		//Pbooklist.get(0).Id,
        
		OpportunityList.add(NewOpportunity);
			
		if (!OpportunityList.isEmpty() && !AccountList.isEmpty()) {
			insert OpportunityList;
			//	OpportunityList.get(0).Id)
		}
		
		//	Insert Product into new Opportunity
		list<OpportunityLineItem> OpportunityLineItemList = new list<OpportunityLineItem>();
		list<product2> Product2List = [Select p.Id From Product2 p Where p.Name = 'Test 25\' Cable' Limit 1];
		list<PricebookEntry> PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Not Applicable',
			SalesDescript__c = 'Test 25\' Cable',
			HasEnVR__c = False,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test 25\' Cable',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 1,
			UnitPrice = 24.925,
			SKU__c = 'TEST-01'
			)); 
		Product2List = [Select p.Id From Product2 p Where p.Name = 'Test EnVR'];
		PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Video',
			SalesDescript__c = 'Test EnVR',
			HasEnVR__c = true,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test EnVR',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 1,
			UnitPrice = 53.89,
			SKU__c = 'TEST-03'
			)); 
		Product2List = [Select p.Id From Product2 p Where p.Name = 'Test Insight Software'];
		PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Insight',
			SalesDescript__c = 'Test Insight Software',
			HasEnVR__c = False,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test Insight Software',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 1,
			UnitPrice = 53.89,
			SKU__c = 'TEST-04'
			)); 
		Product2List = [Select p.Id From Product2 p Where p.Name = 'Test Labor'];
		PricebookEntryList = [Select p.Id From PricebookEntry p 
			Where p.Pricebook2Id = :PriceBooklist.get(0).Id and p.Product2Id = :Product2List.get(0).Id];
		OpportunityLineItemList.add(new OpportunityLineItem(
			Unit__c = 'Each',
			Service_Type__c = 'Not Applicable',
			SalesDescript__c = 'Test Labor',
			HasEnVR__c = False,
			EnVRinSub__c = 'False',
			Component_Name__c = 'Test Labor',
			BOM__c = 'None',
			PricebookEntryId = PricebookEntryList.get(0).Id,
			OpportunityId = OpportunityList.get(0).Id,
			Quantity = 10,
			UnitPrice = 124.75,
			SKU__c = 'TEST-02'
			)); 

		if (!OpportunityLineItemList.isEmpty()) {
			insert OpportunityLineItemList;
		}

		
	}	// End CreateBaseForTesting

}	// End Class

 

Hello,

 

I'm a bit concerned, the Apex Explorer tells me that the Unique ID length is 18 but when you run reports pulling this number its 15.  All URL's say its 18.  We are in the process of automating Salesforce with SAP in which SAP uses a 15 Character Unique Identifier.

 

So my question is, does it use a 15 or 18 character ID?