• chris.noe
  • NEWBIE
  • 240 Points
  • Member since 2012
  • Salesforce Consultant
  • Independent


  • Chatter
    Feed
  • 8
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 54
    Replies
HI ,

We have a trigger on Account which have logic to change Opportunity Owner as Account Owner.
I did disable(inactive) the  trigger.

Still I observe that if Account and Opportunity have same owner and I change Account owner then Opportunity owner get change.

This is happen only when Account and Opportunity have same owner.

Is there anybody have some idea?


Thanks,
Dhanraj

I can't seem to get my formula correct---

I want to have an image displayed if Named_Account__c = true

 

IF (Named_Account__c, IMAGE(servlet/servlet,filedownload?file=xxxxxxx"), 'blank")

 

and i get this message

Error: Incorrect number of parameters for function 'IMAGE()'. Expected 2, received 1

 

What am i missing?

Hi,

 

I have a visualforce page which overrides the standard account page. I'm trying to make it so that I can display the Account History related list on this page.

 

I found some code to do this in apex;

 

<apex:dataTable value="{!Account.histories}" var="accountHistory" width="100%" rows="5">
<apex:column >
<apex:facet name="header">Date</apex:facet>
<apex:outputText value="{0,date,MM/dd/yyyy HH:mm }">
<apex:param value="{!accountHistory.createddate}" />
</apex:outputText>
</apex:column>
<apex:column >
<apex:facet name="header">Field</apex:facet>
<b> <apex:outputText value="{!IF(CONTAINS(accountHistory.field,'__c'),LEFT(accountHistory.field, LEN(accountHistory.field) -3),accountHistory.field)}"/></b>
</apex:column>
<apex:column >
<apex:facet name="header">Edited By</apex:facet>
<apex:outputText value="{!accountHistory.createdby.name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Old Value</apex:facet>
<apex:outputText value="{!accountHistory.oldvalue}"/>
</apex:column>
<apex:column >
<apex:facet name="header">New Value</apex:facet>
<apex:outputText value="{!accountHistory.newvalue}"/>
</apex:column>
</apex:datatable>

 However the data is not sorted, I was wondering if it possible to sort this data to put the most recent changes at the top of the list?

 

Any help would be appreciated!

 

Thanks,

 

Andrew

 

 

  • March 22, 2013
  • Like
  • 0

Hi,

 

How can I get a string representing today's date in the format YYYYMMDD ?

 

Thanks

Hi,

 

We have web to lead forms that create leads for us.  I want to be able to have the lead source populate based on the URL the web to lead form came from.  I tried the formula below, but it keeps giving me syntax errors.....help!

 

IF((Inhouse_URL__c)="http://www.petroskills.com/EmailUs.aspx?id=8") "Middle_East_Web_Form", null)

Hi,

I am migrating Data from one organisation to another .the probleme is that Closed Tasks are displayed in the open activities.

Please how can i resolve this problem!!! thanks  a lot

We created a new custom object which I want everyone to be able to see. Under Security -> Sharing it is set (by default?) to Public Read/Write. I have not applied any additional security and assume this is the Org-Wide Default.

 

The problem is, when a normal user calls up the list page (via a link) it returns an "Insufficient Priveleges" message. The link is just: my.salesforce.com/a0F (is this an invalid way to link? Must I create pages and tabs??)

 

The fields appear as visible but under each profile's field-level security. However, in the "Custom Record Type Settings" for that object nothing is checked. Do I need to go through each profile and check "View All"?

I have a use case where I would like to access the masked value of an encrypted field via Apex.  I am actually writing the value of the masked field to a regular text field on a separate object.  The text field on the other object cannot be defined as encrypted because it will accept encrypted text fields with different formats.  As a result, I just want to update this field with the masked value of the encrypted field.  When I attempt this via Apex, it always writes the unmasked value.  Anyone found a way to access the masked value of an encrypted field via Apex?

 

Thank you,

So I'm working away in the Force.com IDE, saving occassionally to my sandbox org to check for compilation errors.  Everything is working great (saving to server) and then for no reason at all, the IDE stops saving to the server.  It saves locally, but not to the server and no warning or error is returned.  I have checked the API call limits in my sandbox and I am no where near them so I don't know what the issue is.  I have to delete my project and create a new one in Eclipse in order to get it working again.  Very frustrating.  Anyone else having this issue?

Greetings,

If I understand the "with sharing" correctly, it takes the org wide sharing model into account when retrieving data in a SOQL query.  I have a situation with a customer portal user that is not aligning with what I would expect.  Here is the scenario.

 

+ Private org-wide sharing model for Cases.

 

+ Customer portal profile is NOT set up as a super user profile, meaning the user who is logged in only sees their cases and no one elses from their organization.

 

+ I have enabled one account and one contact with access to my customer portal in a developer org.

 

+ I have logged 3 cases in an open status under this account.  Each case has a different contact from the account associated with it.  One of those cases is associated to my customer portal contact user.

 

+ When I log into the portal as the contact associated with one of the open cases and go to the Cases tab, I see just one Case under the "All Open Cases" list view that I created.  Same behavior when I run an "all open cases report" as the portal user.  This is what I expect to see based on the org wide defaults and customer portal profile that I have created.

 

+I have created a Visualforce homepage component with a section for "All Open Cases".  This should display all the open cases that the logged in user has access to.  Here is my controller code that is used to retrieve the open case records:

public with sharing class custPortalHomepageController {
    public List<Case> openCases {get; set;}

    public custPortalHomepageController() {
        openCases = [select Id, CaseNumber, Subject, Status, Contact.Name, CreatedDate from Case where IsClosed=false order by CreatedDate desc];
    }
}

 

+When I log into the portal, the homepage component shows me all 3 open cases for the portal user's account.  I would expect it to only show the 1 case where the portal user is the contact on the case.  It appears that the "with sharing" is being ignored by this SOQL query.

 

I realize that I can just add a filter to the query that only returns open cases where the ContactId is equal to the portal users ContactId but I am curious as to why all cases are being returned when "with sharing" was declared as part of the class.  Has anyone seen this issue before?

I've got a visualforce page the is outputting a data table with a list of accounts in the account hierarchy.  One of the columns displayed is the account record type.  We have translated the record type values in the translation workbench and they display correctly translated on the standard acccount page layout.  However, when we try to render them in a dataTable, they show the English values when a non-English user is logged in.  Anyone have any good workarounds for this?  Here is the code we are using:

 

<apex:column >
    <apex:facet name="header">{!$ObjectType.Account.Fields.Type.Label</apex:facet>
    <apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value="{!pos.account.RecordType.Name}" />
</apex:column>

 

I've got a visualforce page the is outputting a data table with a list of accounts in the account hierarchy.  One of the columns displayed is the account record type.  We have translated the record type values in the translation workbench and they display correctly translated on the standard acccount page layout.  However, when we try to render them in a dataTable, they show the English values when a non-English user is logged in.  Anyone have any good workarounds for this?  Here is the code we are using:

 

<apex:column >
    <apex:facet name="header">{!$ObjectType.Account.Fields.Type.Label</apex:facet>
    <apex:outputText style="{!IF(pos.currentNode,'font-weight: bold;','')}" value="{!pos.account.RecordType.Name}" />
</apex:column>

 

I have a trigger I wrote that works great when I test it in the UI, but my test is failing.  I get the following error:
Error Message	System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, triggerTest: execution of BeforeInsert

caused by: System.NullPointerException: Argument cannot be null.

Trigger.triggerTest: line 294, column 1: []
Stack Trace	Class.testtest.myUnitTest: line 61, column 1
If I'm understanding this correctly it says its failing when it tries to insert the opportunitylineitem because when the trigger tries to do "a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);" and it thinks No_Ordered__c or ListPrice is NULL.  I get this error whether or not I use a the test product or a real product already in the system that I know works fine when I test in the UI.  Please tell me what I am doing wrong.  Any help is appreciated.  Here is the code for the trigger and the test.  I trimmed down the test to test only one product.

TRIGGER
trigger triggerTest on OpportunityLineItem (before insert, before update) {

		decimal disc;
		decimal sub;
		decimal servamt;
		decimal billcalc;
		Integer quartercalc;
		Integer enddate;

		for(OpportunityLineItem a : Trigger.New){
			a.Quantity = (a.No_Ordered__c * a.Service_Duration__c);
			sub = (a.Quantity * a.UnitPrice);
			if(a.Discount != NULL){
				disc = (a.Discount * .01);
				a.TotalPrice = (sub - (sub * disc));
			}else{
				a.TotalPrice = sub;	
			}
			servamt = (a.Quantity / a.No_Ordered__c);
			a.Service_Amount__c = (a.TotalPrice / servamt);
			if(a.PB__c == 'Weekly'){
				if(a.Billing_Period__c == 'Weekly'){
					billcalc = 1;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 7);
					a.End_Date__c = a.ServiceDate.addDays(enddate);
				}else if(a.Billing_Period__c == 'Quarterly'){
					billcalc = 13;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 7);
					a.End_Date__c = a.ServiceDate.addDays(enddate);				
				}else if(a.Billing_Period__c == 'Semi-Annual'){
					billcalc = 26;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 7);
					a.End_Date__c = a.ServiceDate.addDays(enddate);				
				}else if(a.Billing_Period__c == 'Annual'){
					billcalc = 52;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);				
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 7);
					a.End_Date__c = a.ServiceDate.addDays(enddate);							
				}

			}else if(a.PB__c == 'Monthly' || a.PB__c == 'Monthly D'){
				if(a.Billing_Period__c == 'Monthly'){
					billcalc = 1;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}else if(a.Billing_Period__c == 'Every Other Month'){
					billcalc = 2;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}else if(a.Billing_Period__c == 'Quarterly'){
					billcalc = 3;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}else if(a.Billing_Period__c == 'Semi-Annual'){
					billcalc = 6;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}else if(a.Billing_Period__c == 'Annual'){
					billcalc = 12;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}

			}else if(a.PB__c == 'Quarterly'){
				if(a.Billing_Period__c == 'Quarterly'){
					billcalc = 1;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 3);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}else if(a.Billing_Period__c == 'Semi-Annual'){
					billcalc = 2;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 3);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}else if(a.Billing_Period__c == 'Annual'){
					billcalc = 4;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 3);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}else if(a.Billing_Period__c == 'Monthly'){
					billcalc = 3;
					a.Billing_Amount__c = (a.Service_Amount__c / billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice / billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c / billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 3);
					a.End_Date__c = a.ServiceDate.addMonths(enddate);
				}

			}else if(a.PB__c == 'Annual'){
				if(a.Billing_Period__c == 'Annual'){
					billcalc = 1;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addYears(enddate);
				}else if(a.Billing_Period__c == 'Monthly'){
					billcalc = 12;
					a.Billing_Amount__c = (a.Service_Amount__c / billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice / billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c / billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addYears(enddate);
				}else if(a.Billing_Period__c == 'Every Other Month'){
					billcalc = 6;
					a.Billing_Amount__c = (a.Service_Amount__c / billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice / billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c / billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addYears(enddate);
				}else if(a.Billing_Period__c == 'Quarterly'){
					billcalc = 4;
					a.Billing_Amount__c = (a.Service_Amount__c / billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice / billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c / billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addYears(enddate);
				}else if(a.Billing_Period__c == 'Semi-Annual'){
					billcalc = 2;
					a.Billing_Amount__c = (a.Service_Amount__c / billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice / billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c / billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addYears(enddate);
				}

			}else if(a.PB__c == 'One Time' || a.PB__c == 'One Time D'){
				if(a.Billing_Period__c == 'Monthly'){
					billcalc = 1;
					a.Billing_Amount__c = (a.Service_Amount__c * billcalc);
					a.List_Price_Svc__c = (a.No_Ordered__c * a.ListPrice);
					a.List_Price_Bill__c = (a.ListPrice * billcalc);
					a.List_Price_Extd__c = (a.List_Price_Svc__c * billcalc);
					a.Billing_Savings__c = (a.Billing_Amount__c - a.List_Price_Extd__c);
					if(a.Billing_Savings__c >= 0){
						a.Billing_Savings__c = NULL;
					}
					a.Per_Item_Bill__c = (a.Billing_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Bill__c = (a.List_Price_Bill__c - a.Per_Item_Bill__c);
					a.Service_Savings__c = (a.Service_Amount__c - a.List_Price_Svc__c);
					if(a.Service_Savings__c >= 0){
						a.Service_Savings__c = NULL;
					}
					a.Per_Item_Svc__c = (a.Service_Amount__c / a.No_Ordered__c);
					a.Discount_Amount_Svc__c = (a.ListPrice - a.Per_Item_Svc__c);
					enddate = (a.Service_Duration__c.intValue() * 1);
					a.End_Date__c = a.ServiceDate.addDays(enddate);
				}

			}

		}


	}

TEST CLASS
 
/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * 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(SeeAllData=true)
private class testtest {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test

        Date now = date.today();
        integer day = now.day();
        
        // CREATE ACCOUNT
        Account newAccount = new Account(Name = 'Test Account', Phone='817-999-9999' );
        insert newAccount;

         // CREATE CONTACT
        Contact newContact = new Contact(LastName = 'Test Contact', AccountId = newAccount.Id );
        insert newContact; 

        // CREATE OPPORTUNITY
        Opportunity newOpp = new Opportunity(Name = 'Test Opportunity', CloseDate = System.today(), AccountId = newAccount.Id, Contact_Name__c = newContact.Id, StageName = 'Initial Interview' );
        insert newOpp;
        
        // GET STANDARD PRICEBOOK
		Pricebook2  standardPb = [select id, name, isActive from Pricebook2 where IsStandard = true limit 1];

		// CREATE CUSTOM PRICEBOOK
		Pricebook2 pbk1 = new Pricebook2 (Name='Test Pricebook Entry 1',Description='Test Pricebook Entry 1', isActive=true);
		insert pbk1;

		// CREATE PRODUCT
		Product2 prd1 = new Product2 (Name='Test Product Entry 1',Description='Test Product Entry 1',productCode = 'ABC', isActive = true, Pricing_Basis__c = 'Annual' );
		insert prd1;

		// CREATE PRICEBOOKENTRY
		PricebookEntry pbe1 = new PricebookEntry (Product2ID=prd1.id,Pricebook2ID=standardPb.id,UnitPrice=50, isActive=true);
		insert pbe1;


        // CREATE OPPORTUNITYPRODUCTS
        OpportunityLineItem newProdAnnual = new OpportunityLineItem (Billing_Period__c = 'Annual', OpportunityId = newOpp.Id, Service_Duration__c = 1, ServiceDate = now, End_Date__c = now, PricebookEntryId = pbe1.Id, No_Ordered__c = 1, UnitPrice = 50, Quantity = 1);       
        insert newProdAnnual;

        //QUERY
        OpportunityLineItem a =[SELECT ID, Quantity, TotalPrice, Discount, UnitPrice, Billing_Amount__c, List_Price_Svc__c, List_Price_Bill__c, List_Price_Extd__c, Billing_Savings__c, Per_Item_Bill__c, Discount_Amount_Bill__c, Service_Savings__c, Per_Item_Svc__c, Discount_Amount_Svc__c, End_Date__c, ServiceDate from OpportunityLineItem WHERE ID =: newProdAnnual.Id ];


        //VALIDATE DATA WAS UPDATED CORRECTLY

		//Annual
		System.assertEquals(a.Quantity, 1);
		System.assertEquals(a.TotalPrice, 50.00);
		System.assertEquals(a.Discount, 0);
		System.assertEquals(a.Billing_Amount__c, 50.00);
		System.assertEquals(a.List_Price_Svc__c, 50.00);
		System.assertEquals(a.List_Price_Bill__c, 50.00);
		System.assertEquals(a.List_Price_Extd__c, 50.00);
		System.assertEquals(a.Billing_Savings__c, NULL);
		System.assertEquals(a.Per_Item_Bill__c, 50.00);		
		System.assertEquals(a.Discount_Amount_Bill__c, 0.00);
		System.assertEquals(a.Service_Savings__c, NULL);
		System.assertEquals(a.Per_Item_Svc__c, 50.00);
		System.assertEquals(a.Discount_Amount_Svc__c, 0.00);
		System.assertEquals(a.End_Date__c, a.ServiceDate.addYears(1));

    }
}



 
  • March 03, 2015
  • Like
  • 1
Hi

Are there any impacts (in native Salesforce functionality such as report etc) I  should be aware of when changing a master-detail field to a lookup ?

Many thanks
Ross

HI ,

We have a trigger on Account which have logic to change Opportunity Owner as Account Owner.
I did disable(inactive) the  trigger.

Still I observe that if Account and Opportunity have same owner and I change Account owner then Opportunity owner get change.

This is happen only when Account and Opportunity have same owner.

Is there anybody have some idea?


Thanks,
Dhanraj
All,

We have deployed the SF community, but when people use the self register link on the site SF creates a contact record and user record on a default account even if the email address matches a current customer.  As you can image managing the default account of contacts is not something I want to deal with.

So I am looking for a way to auto match users to their contacts to their user records if the email addresses match.  I understand that this can done with a controller.  I don't do that level of SF work yet, so any help would be great.

Thanks,

Michael

 

Need help to understand best and easy way to copy custom setting data to newly refreshed sandbox.

Hi,

 

I just would like to inquire if there is a way i can restrict a user to login to salesforce only to one specific computer?

This means, she can only login on her work station and hinders her from loging in when she's outside of the office.

 

Thanks,

Del

Hi,

 

I want to query the records which are modified with last 15 mins.

Please let me know the SOQL query for the same. I tried

 

select name from Opportunity

     where SystemModstamp >  Datetime.now().addMinutes(-15)

 

it did not work.

 

I want to run the query using force.com explorer/workbench

Please let me know if there is any other method to get this.

 

Thanks,

Babu.

  • April 26, 2013
  • Like
  • 0

I have 100 accounts of Account Object.Every account have more than one contact.I need to getting the highest contact by the contact (percent field) in every account.

Is it possible in Map?

 

Its urgent.Please help me

Hello,

 

I am new to force. I have been just using the following site to develop apps

 

https://na15.salesforce.com/

 

I have learned that most use Eclipse to fully develop. *(I am using the free edition right now while my company transitions.)

 

I have downloaded Eclipse and went through the instuctions given at the following link

 

http://wiki.developerforce.com/page/Force.com_IDE_Installation_for_Eclipse_3.5

 

I have loaded the Eclipse but when i try to create a new project i keep getting an error message when creating a new project.

 

Unable to connect to the hostname 'test.salesforce.com'

 

then it says that my credentials fail. *** I am using the correct credentials and resetting my security token... Am I doing something incorrect?

I can't seem to get my formula correct---

I want to have an image displayed if Named_Account__c = true

 

IF (Named_Account__c, IMAGE(servlet/servlet,filedownload?file=xxxxxxx"), 'blank")

 

and i get this message

Error: Incorrect number of parameters for function 'IMAGE()'. Expected 2, received 1

 

What am i missing?

Hi can anyone tell me why i am getting this error for this code? i am at my wits end. I have marked the line where i am getting the error

 

public class FindScope {
  list<list<opportunity>> theList;
  list<String> piclistVals = new list<string>();
  String s;
  list<string> pv;
  list<opportunity> listOfOpp; 
 
  public list<String> getPicklistVals(){
    Schema.DescribeFieldResult fieldResult = opportunity.stageName.getDescribe();
  for(Schema.PicklistEntry f :  fieldResult.getPicklistValues()){
    piclistVals.add(f.getValue());
   
  }
  return piclistVals;
  }
  public list<list<opportunity>> getOpportunities(){
         theList =  new list<list<opportunity>>();
         for(Integer i = 0; i < piclistVals.size(); i++){
         String pvalue = pv[i];  
       listOfOpp = [select id, name, stagename, amount from opportunity where stagename = :pvalue];
       thelist.add(listOfOpp);
         
   }
      return thelist;
  } 
   public list<opportunity> getProspecting(){
     
       oppProspecting = thelist[0];
        list<opportunity> myopp = new list<opportunity>();
         ;     
        return oppProspecting;
    }
     public list<opportunity> getQualification(){
      list<opportunity> oppQualification = new list<opportunity>();
       oppQualification = thelist[0];
        System.debug(oppQualification);       
        return oppQualification;
    }
      public list<opportunity> getNeedsAnalysis(){
      list<opportunity> oppNeedsAnalysis = new list<opportunity>();
       oppNeedsAnalysis = thelist[2];
        return oppNeedsAnalysis;
    } 
     public list<opportunity> getValueProposition(){
      list<opportunity> oppValueProposition = new list<opportunity>();
       oppValueProposition = thelist[3];
        return oppValueProposition;
    }       
    
}

  • March 29, 2013
  • Like
  • 0

Hi,

 

I have a visualforce page which overrides the standard account page. I'm trying to make it so that I can display the Account History related list on this page.

 

I found some code to do this in apex;

 

<apex:dataTable value="{!Account.histories}" var="accountHistory" width="100%" rows="5">
<apex:column >
<apex:facet name="header">Date</apex:facet>
<apex:outputText value="{0,date,MM/dd/yyyy HH:mm }">
<apex:param value="{!accountHistory.createddate}" />
</apex:outputText>
</apex:column>
<apex:column >
<apex:facet name="header">Field</apex:facet>
<b> <apex:outputText value="{!IF(CONTAINS(accountHistory.field,'__c'),LEFT(accountHistory.field, LEN(accountHistory.field) -3),accountHistory.field)}"/></b>
</apex:column>
<apex:column >
<apex:facet name="header">Edited By</apex:facet>
<apex:outputText value="{!accountHistory.createdby.name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Old Value</apex:facet>
<apex:outputText value="{!accountHistory.oldvalue}"/>
</apex:column>
<apex:column >
<apex:facet name="header">New Value</apex:facet>
<apex:outputText value="{!accountHistory.newvalue}"/>
</apex:column>
</apex:datatable>

 However the data is not sorted, I was wondering if it possible to sort this data to put the most recent changes at the top of the list?

 

Any help would be appreciated!

 

Thanks,

 

Andrew

 

 

  • March 22, 2013
  • Like
  • 0