• Enth
  • SMARTIE
  • 963 Points
  • Member since 2008

  • Chatter
    Feed
  • 35
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 249
    Replies

Hi

In my organization  Users are Using Different Time Zones example( US-07:00, Uk +04:00).  I know whenever a record is saved in Salesforce it will be saved in UTC timing. And when I run a Lead standard report it converts the UtC timings to the Corresponding owner Timing and giving the Report.. But Am trying to write a Custom Report Between certain dates. Fore example I used as

"CreatedDate >=2013-04-01T00:00:00z and CreatedDate <=2013-04-30T23:59:59z"  It gives the report as per UTC timing and it is not converting as per Lead owners time zone. So am getting the difference in  standard and Custom Reports.

Can anyone help me out.

 

ThankYou

I am having errors with compiling in my Test Class. 

 

I have commented out the parts that the errors were occuring below (and put them in bold/underlined) - and now I have 92% code coverage, but I just want to know how I can fix this in the future.  

 

The two errors I am receiving are:

  • Error: Compile Error: Illegal assignment from String to SOBJECT:Product2 at line 61 column 9
  • Error: Compile Error: Illegal assignment from String to Decimal at line 63 column 9

Any help would be greatly appreciated!


Thanks!

Chris

 

 

Here is the code:

 

@isTest
private class AssetTest {
//Classes always have to be uppercase
    static testMethod void testContractLine()
    {      
        Profile pr = [select id from profile where name=: 'System Administrator'];
        User u = new User(alias = 'standt', email='standarduser@vauto.com',emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',localesidkey='en_US', profileid = pr.Id,timezonesidkey='America/Los_Angeles', username='testemail1@vauto.com');
        insert u;
        System.runAs(u)
        {
            Account a = setupAccount();
            Contact co = setupContact();
            Opportunity o = setupOpportunity(a,co);
            Contract c = setupContract(o,a);
            Asset ae = setupAsset(a,c);
            
            Test.startTest();
                ae.Status = 'Active';
                update ae;
                
                List <Contract_Line__c> contractLines = [select Id from Contract_Line__c where Contract__c =: c.Id];
                
                //System.assertEquals(contractLines.size(),1); 
                
            Test.stopTest();
        }
    
    }
    //THE FOLLOWING IS OUR TEST DATA void means we're not returning anything
    static Account setupAccount(){ 
        Account a = new Account();
        a.Name = 'test';
        insert a;
        return a;
    }
    
    static Opportunity setupOpportunity(Account a, Contact c){
        Opportunity o = new Opportunity ();
        o.Name = 'test'; 
        o.CloseDate = System.today();
        o.StageName = 'Prospecting';
        o.AccountId = a.Id;
        o.Syndication_Primary_Contact_2__c = c.Id;
        insert o;
        return o;
    
    }
    
    static Contract setupContract(Opportunity o, Account a){
        Contract c = new Contract();
        c.Name = 'test';
        c.StartDate = System.today();
        c.Opportunity__c = o.Id;
        c.AccountId = a.Id;
        insert c;
        return c;
    }
    
    static Asset setupAsset(Account a, Contract c){
        Asset ae = new Asset();
        
//ae.Product2 = '30 Day Deposit';

 

        ae.Name = '30 Day Deposit';

        //ae.Price = '1400.00';

        ae.PurchaseDate = System.today();
        ae.InstallDate = System.today();
        ae.Contract__c = c.Id;
        ae.AccountId = a.Id;
        insert ae;
        return ae;
    
    }
    
    static Contact setupContact(){
        Contact co = new Contact();
        co.FirstName = 'Test';
        co.LastName = 'McGhee';
        insert co;
        return co;
    }



}

  • February 20, 2013
  • Like
  • 0

Heya,

 

I have a trigger to update ActivityDate field and Purpose__c multiselect picklist when a Task is Inserted or Updated. All of my system.debugs come up with the correct value, but nothing gets updated. Should I put it in an After Insert/Update maybe? I don't know why the fields aren't getting updated. 

 

trigger Task_SwayCard_AssignTask on Task (before insert, before update) {
	/* A trigger on the Task object that if the Task Owner is BDM or BDE,
			and the Subject of the task is like "Sway Card", then 
			the type of the task will change to Email, the due date of the task will
			be for the next coming Wednesday, and Sway Cards will be added
                        to purpose__c if it isn't already there.*/
    
    List<Task> tskSway = [SELECT id, ownerId, subject, purpose__c from Task 
                          where subject like '%Sway Card%' 
                          and id =: trigger.new]; // A list to hold "Sway Cards" tasks
    
    
    Date myDate = date.today();
    Date sunday = myDate.toStartOfWeek();
    Date nextSunday = sunday.addDays(7);
	Integer dayOfWeek = sunday.daysBetween(myDate);
    Date thisWednesday = sunday.addDays(3);
    Date nextWednesday = nextSunday.addDays(3);           
    	    
    System.debug(myDate);
    System.debug(sunday);
    System.debug(nextWednesday);
    
    If (tskSway != NULL){
    	system.debug('tskSway is Not Nulll!!');
        List<User> bdmOwner = [select id, name, userrole.name from user //A list to hold all BDMs in the org
        	                   where userrole.name like '%BDM%'];
    	List<User> bdeOwner = [select id, name, userrole.name from user
            	               where userrole.name like '%BDE%'];
		List<Task> tskToUpdate = new List<Task>();//A list to hold which tasks need to be updated
        
        For (Task t : tskSway) //Populate tskToUpdate based on whether the owner is a BDM or BDE, 
    	{						//and whether the Task is in the tskSway list.
        If (bdmOwner != null)
        {
     	   For (User u : bdmOwner)
        	{
            	If (u.id == t.ownerID)
            	{
                	tskToUpdate.add(t);            
            	}
        	}
        }
        If (bdeOwner != null)
        {
        	For (User u : bdeOwner)
            {
            	If (u.id == t.ownerID)
                {
            		tskToUpdate.add(t);
        		}
        	}
        }
        }
        
        If (tskToUpdate != null){
            System.debug('tskToUpdate is not Null!');
        For (Task t : tskToUpdate)
        {
            If (t.purpose__c.indexOf('Sway Cards') <= 0){
                system.debug('purpose has Sway Cards!' + t.purpose__c);
                t.purpose__c += ';Sway Cards;';
                system.debug(t.purpose__c);
            	}
            t.ActivityDate = nextWednesday;
            system.debug(t.ActivityDate);
        }
    }
    }
}

 

I have the following code  which compiles but gives the following error:

 

Apex trigger Peter1 caused an unexpected exception, contact your administrator:
Peter1: execution of BeforeInsert caused by: System.NullPointerException:
Attempt to de-reference a null object: Trigger.Peter1: line 3, column 1

 

trigger Peter1 on Event (before insert) {

Event myEvent = trigger.old[0];
Event myNewEvent = trigger.new[0];
if (myEvent.IsAllDayEvent = True) {
myNewEvent.Subject = myEvent.Location; 
update myEvent;
}// else nothing

 I've had little experience with SF triggers to date and I'm struggling a bit with trigger.old and trigger.new !   Any help here would be much appreciated.  Thanks.

 

This is my code stub that catches nullPointerException and I am trying to pass coverage on the 2nd test method testAccountTerritoryUpdateNegative() below.  I also know that I am not supposed to hardcode ID or Name in the test method but I will fix this later since I'm just trying to implement the test to see if it passes. How come the soql in my test method brings back zero rows? When I run that soql in the schema explorer, it brings back the record.  hmmmmmmm

 

System.QueryException: List has no rows for assignment to SObject

Class.AccountTests.testAccountTerritoryUpdateNegative: line 51, column 1

 

catch (System.NullPointerException e)
{
for(Account a: aList)
{
a.addError('There was an error with the record since a field was not populated correctly, please contact IT at 1888-888-8888 for asssitance, error number ' + e.getLineNumber());
}
}

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@isTest private static void testAccountTerritoryUpdateNegative()
{
Account testAccount =[select id, billingstreet from account where name = 'test compant'];
try
{
testAccount.BillingStreet ='test negative street';
Test.startTest();
update testAccount;
Test.stopTest();
}
catch(System.NullPointerException e)
{
System.assertEquals('NullPointerException' , e.getTypeName());
}

}

  • October 07, 2012
  • Like
  • 0

Hi,

 

In the Force.com IDE, the content assist works sometimes and not at times (using ctrl+space).

Please let me know, if we have any plugin to avoid this?

 

or any particular thumb rule to get this working everytime?

 

Thanks

Hi,

i am new to this .Can anyone convert this query to Starts with  the given search text value plsss 

 

'select id, name  from Account ' +
'where name LIKE \'%'+searchText+'%\' order by name';

Please if anyone can help me with what should be an easy problem to solve.

 

I just created a new developer account by filling out the form and I have not received any email so i cannot set any password.  If I choose "forgot password" I'm prompted to answer a security question that I have not yet set.  How can I create a developer account that I can actually log into?

 

Thanks,

Ethan

Hi

 

i am trying to write a trigger which will update an email field from contact to customer emailfield in account.But this is not working.

 

 

trigger updatecontact on Contact (before insert, before update) {
Account acc = [SELECT Customer_Email__c FROM Account Limit 1];
  Contact con = [SELECT Email FROM Contact limit 1 ];
  
for(Contact co : Trigger.new){
if(acc.Customer_Email__c == null || acc.Customer_Email__c =='')
   { acc.Customer_Email__c = co.Email;
    }
  }
}
Please help me on this
Thanks
Nasir

 

  • December 01, 2010
  • Like
  • 0

I am trying to build a matix report which has both row groupings and column groups. In the summary section i drop in one of the columns called 'Amount' in one of custom objects. When the report is displayed, the row title for this summary field says 'Sum of Amount'. I want to get rid of this title and call my title as just 'Amount' without the 'Sum of'. There currently didnt seem to be a way to change the title.

To overcome this i created a formula field in the report which sums the amount and called it 'Amount'. However, I am unable to drag this field to the summary section of the report. I can only drag it if I include atleast one other column from the custom object. If i remove the the column, the formula field  i added also is removed. Is this a bug?

 

Is there a way to change the title or get rid of the 'Sum Of' before the column which was my original requirement.

 

Thanks.

  • November 30, 2010
  • Like
  • 0

Hi ,

 

I need  to write a trigger that updates the parent object field 'Status__c' based on its child statuses.

I have a custom parent object Order__c and child object Order_line__c

 

Both have a status field "status__c"

 

Now when the any of the child object status__c ='Open' ,the parent status__c is 'Open'
else the parent object status__c='Closed'.

 

I tried writing a trigger from the docs example,but it was confusing .....

 


Can somebody please help me with this?

Thanks!

 

Hi,

 

Any suggestions on how I may receive a web lead containing the product ID and quantity and have that info appear in the opportunity when it's converted?  I can do the web-to-lead bit with hidden fields etc but it just arrives as a inert  text field and there doesn't seem to be a clear way to map lead fields to the built-in product list and price book. 

 

I'm ready to dive into Apex and do it  manually but I have a feeling that I'm not the only one who has tried this.

 

Anyone been down this path before?  Any ideas?

 

 

Thanks,

 

HNM

  • November 26, 2010
  • Like
  • 0

I have an APEX Class that is used as a controller for a visualforce page.  The visualforce page is called from a button event.  The class's main purpose is to call a webservice. I would like to use the class's method that calls the webservice in workflow.  Is there a way to do that?

I looked but cannot find the following:

 

1. When I log into Sales Force is there a startup event? Something I can run when someone logs in? Or maybe a click event on one of the tabs?

2. Create event when someone creates an item such as a task or email? I see the workflow but was not sure if it can be triggered on a new item event instead of a field event.

 

These seem like quite basic tasks so any help would be appreciated.

Thanks

SFDC sets number/currency/percentage fields RIGHT Aligned by default.

 

Is there any way to set them LEFT Aligned in stardard pagelayout, not using VF page.?

 

 

 

Thanks & Regards,

Atlantis

There is some great documentation on best practices for Enterprise Developers. 

 

I'm working on a product that we're releasing for sale on App Exchange. Our engineers have done a ton of software development on different platforms in the past, but never for Salesforce.

 

In more traditional systems, we'd check code changes into SVN or other repository, and then use a build system such as Hudson to kick off an official nightly build. We know that the build is clean and reproducable - all build content came from SVN.

 

In Salesforce, from what I can see, solid SVN integration is available via the Force .COM IDE in Eclipse. However, this appears to typically take a secondary role for comparing diffs across different file versions rather than acting as the master in a build process. Is this correct?

 

Are there best practices in build automation that we should be aware off? How ISVs typically ensure a reproducible release process?

  • October 12, 2010
  • Like
  • 0

Hi there. I may need some developer help here.

 

I’m trying to create a roll up summary of a field on 1 object, that is created by a Formula, that looks up to another object, but the fields dont appear in the aggregate drop down, when I try to create it,

 

basic background is that I have 3 objects.

 

  1. Advertising Goal. An advertising goal that we need to achieve,
  2. Ad spots. We may have to buy multiple ad spots to fulfill the goal
  3. Websites. Ad spots exist on other websites. We may have to buy 1 or more spots, on 1 or more of the websites.

 

Advertising goal and websites are both currently  master objects to the ad spot, since ad spots and their stats need to be rolled up to view at either level. ie how many spots have we bought on a website, how many spots are we using to support an advertising objective.

 

Ad spots also have an ‘ad type’ which is a picklist of 3 values. Button, banner or text link. Each website may charge differently  for each type of spot, and the record for what they charge is held in 3 fields on the website’s record, called button rate, banner rate and text link rate.

 

To set how much the spot is going to cost on the ad spot record, we have a ‘monthly rate’ field, where  we have developed a case function that references the ‘type’ picklist on the ad spot record, and depending on which value is specified, looks to the website record and returns the appropriate field value. Formula is below.

 

CASE( Placement_type__c ,"button",Partner_Website__r.button_Rate__c,"Banner", Partner_Website__r.Banner_rate__c,"Text link Ad" , Partner_Website__r.Text_Link_Ad_Rate__c, 0)

 

We’re happy with this at least and it seems to work.

 

However, now we need to know how much the advertising goal is going to cost from having secured all these ad spots, so we need to create a rollup summary field, that sums the monthly rate field, across all the associated placements.

 

When we try to create a roll up summary though, the Formula fields do not appear.

 

I'm hitting a wall with this as I'm not a programmer and just don't have the skills to work around, and SF support can’t help me either. They ahve suggested that you can't roll up formulas that involve other objects. So I would love to hear from anyone that can explain what is going on, and offer a solution.

 

Best 

 

Warren Cowan

e warren.cowan@greenlightsearch.com

.

 

Is there a way to have a workflow rule that runs when a case record type is changed but not when it's created?

 

We have 2 queues.  Support and Tech Services.  Each has their own record type, process, etc.  If some changes the record type of an existing case, this means the case has been transferred from Support to Tech Services (or vice versa).  When this happens we want to always change the owner to new the queue and always set the status to 02-Transferred.  This will cause the transferred case to go thru our assignment process for the new department.  I have written the Workflow rules and field updates for this and they do the job, except they also set the status to 02-Transferred on case creation.  So, I need  way to make the workflow rule evaluate to false if the case is just being created.

 

 

I am writing a trigger about the "Timesheet" object and other six objects which have the lookup relationship with the 'Timesheet' and also the Record Types of 'Timesheet' .  There is a field named Hours in the 'Timesheet' and Hours are also in all the other six objects. When i create a new 'Timesheet'  i need to choose the RecordType first. For example, it is a Project Timesheet. Then, when i put number  in the Hours field and click Save button. The Hours of Project should also be updated. I have tested my trigger in a single object, it does work. The problem comes when i need to make it works for six objects. I need to write a if statement to judge which recordType is selected. How can i get the value of the selected recordType? Thanks very much for any help

Hi I have a workflow (formula not criteria driven) that I want to get triggered if a new case comment is created by another user (not the case creator) but it does not seem to work.  Could anyone, someone, please help?!!

 

AND( CreatedById  <>   Parent.CreatedById ,  OR(ISPICKVAL(Parent.Division__c,"Quebec"), ISPICKVAL(Parent.Division__c,"British Columbia"),ISPICKVAL(Parent.Division__c,"Alberta"), ISPICKVAL
(Parent.Division__c,"Atlantic"), ISPICKVAL
(Parent.Division__c,"Ontario")))
 

 

 

Thanks.

 

 

I want to develop an process that pulls documents from an internal, secure, Sharepoint server in the background and makes them available subsequently to our clients via Sites. We can't just serve the files from Sharepoint to the customers as this would break our security model and sharepoint isn't scaled for the number of users we expect.

 

There seems to be two prinicpal options:

1. Store the files on a Cloud based file service, such as Amazon S3.

2. Store the files withing Salesforce.com as Files (preferred but cross-browser rendering issues to overcome).

 

A key challenge with either of these approaches seems to be the governor limit on the max http request/response size of 3Mb. Can anyone advise how they've tackled this before to allow a 5Mb+ file to be pulled down into Salesforce.com ?

  • May 15, 2013
  • Like
  • 0

Trying to create a formula field that formats a set of fields for output in a fixed format. e.g.

 

RPAD(Name, 25) & RPAD(Phone, 20) & RPAD(Fax, 20)

 

When we view the data output all the spaces are automatically trimmed to a single space (i.e. Bloggs Inc 01299 999999 01299 888888). We changed this to use a custom field populated by a workflow instead. The field displays with the spaces trimmed again but is correct when we Edit the record.

 

Anyone know how to get the formula field to output correctly ?

  • March 14, 2013
  • Like
  • 0

I just got off the phone with SFDC support. Had a very quirky problem as follows.

 

Have a Roll Up Summary field on Opportunity to total the value of a custom currency field on Opportunity Products - lets call it Total List Price for example. When we create new Opportunties the value is 0, hurrah, and when we add products the value is correctly calculated.

 

The problem arises when the child records are deleted. When the Roll Up Summary field is recalculated it gets a non-zero floating point value (5.443 x 10-36 in my case). This gets rendered as 0 in the UI, but if you have any formula fields or validation rules checking this value, or comparing it to any other, then beware!

 

The solution (workaround) is you need to use something like ABS(total_list_price__c) > 0.00000001 instead of total_list_price__c != 0 in your formula or validation rule, or manually apply the ROUND function to the desired decimal places for your currencies.

 

Hope this helps someone else, it's like going back 20 years in IT!

  • February 20, 2013
  • Like
  • 1

I've been struggling with the following problem, at heart I'm sure it's a simple error, but the behaviour is confusing and any explanation would be appreciated!

 

In general, I want to refresh a section of the page when a user clicks a row in a table. I would prefer not to use radio buttons or checkboxes. I've repeated the problem in a simple example below using the Account object for demonstration:

 

Visualforce Page:

<apex:page controller="TestActionController">
    <apex:form >
        <apex:pageBlock >
            <apex:outputPanel id="pan">
                <apex:outputText value="{!messy}" id="messyid"/>&nbsp;
                <apex:actionStatus startText="Selecting..." id="statusmsg"/>
            </apex:outputPanel>
            <apex:pageBlockTable value="{!accounts}" var="acc">
                <apex:actionSupport action="{!selectRow}" event="onclick" rerender="pan" status="statusmsg">
                    <apex:param name="selAccId" value="{!acc.Id}" assignTo="{!selectedId}" />
                </apex:actionSupport>                               
                <apex:column value="{!acc.Id}"/>
                <apex:column value="{!acc.Name}"/>            
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 The custom controller:

public with sharing class TestActionController {

    public String messy {get; set;}
    public Id selectedId {get; set;}

    public TestActionController() {
        messy = 'Initialised';
    }

    public List<Account> getAccounts() {    
        return [SELECT Id, Name from Account LIMIT 10];
    }
    
    public PageReference selectRow() {
    
        this.messy = 'Clicked ' + this.selectedId + ' param selAccId is ' + ApexPages.currentPage().getParameters().get('selAccId');
        
        System.debug('>>> Clicked ' + this.selectedId);
        return null;
    }
    
}

 

The behaviour I'm seeing is:

  1. The status message is updated, implying the action has been fired, but the debug logs show the selectRow() method has not been fired.
  2. The debug log shows that when a row is clicked getAccts is fired TWICE

Would appreciate any guidance on better ways to do this, I though actionSupport would be simpler than using Javascript remoting, but I'm about to give up on it and switch.

  • October 06, 2012
  • Like
  • 0

When booking an event in Apex I want to be able to check a user's availability. Currently we make users schedule non-working time as recurring events, but this is very clunky and they can only schedule x events in the future.

 

What I'd like to do is access the same Start of Day/End of Day values from the User's Personal Information that controls the display of the calendar, but these fields are not jumping out from the User object. Anyone have a clue where to find them ?

 

 

  • June 14, 2012
  • Like
  • 0

Has anyone else noticed that when calling DescribeFieldResult on a Custom Object, or just inspecting the field's Access attribute in the Schema browser, the Name field is always 'Defaulted On Create' for a custom object even when it's not an auto-number ? 

 

This differs to standard objects where the Defaulted On Create is never set. OK, I know I can use isAutoNumber to tell the difference but it is an oddity!

 

 

  • June 11, 2012
  • Like
  • 0

Came across an interesting problem today where one of our bulk triggers failed due to a Too Many DML Rows limit exception.

 

We have a custom object (Order__c) with a child object (Order_Line__c).

We have a trigger on the Order to automatically create Order_Line__c records whenever a new Order is created. However, when the number of line items exceeds 100 our trigger fails BUT ONLY WHEN INVOKED VIA A STANDARD page, our unit tests work fine and if we VF the New Order page it works fine:

 

e.g.

 

 

trigger trg_ai_Order on eclone__Order__c (after insert) {
	
	List<Order_Line__c> items = new List<Order_Line__c>();
	
	for (Order__c o : trigger.new) {
		// This is just an example to demonstrate the issue
		for (Integer i=0; i<101; i++) {
			Order_Line__c oi = new Order_Line__c();
			oi.Order_No__c = o.Id;
			items.add(oi);
		}
				
	}
	
	// Insert the items
	insert items;

}

Add a new Order using the standard tab for Order gives:

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger eclone.trg_ai_Order caused an unexpected exception, contact your administrator: eclone.trg_ai_Order: System.LimitException: eclone:Too many DML rows: 101

 Whereas the following anonymous apex works fine (as the limit is 10,000):

 

Order__c o = new Order__c();
insert o;

 

 

 

And creating a Visualforce page with just the standardcontroller works fine too (an easy workaround).

 

Now I can see from the Apex Developers guide there's different limits for the Trigger and Apex and thinking about it I see that the Unit Test etc have a different entry point, hence why the different limit applies, but this seems to invalidate all our bulk trigger unit tests!

 

What's everyone else's experience of this, do you revert to Asynchrous apex instead, or Visualforce your pages ?

  • January 06, 2011
  • Like
  • 0

I'm looking into integrating Salesforce with a client's Active Directory servers. They have a series of 6 AD servers that they'd like to integrate to ensure that when users leave the organisation their Salesforce account will be automatically de-activated. So the initial requirement is single authentication rather than single sign on (though this may be required later).

 

What I need to know is from people's experience, what's the best way to integrate with AD, is it the Delegated Authentication or Federated Authentication using SAML; which is better able to cope with having the failover AD servers without user intervention? I favour SAML but remember past issues with the level of support for SAML in AD.

 

Furthermore, what are the gotcha's, AD versions etc, that work with both and which would people recommend ?

 

Cheers,

 

Richard

  • December 06, 2010
  • Like
  • 0

I'm using a dummy Visualforce page with an action on the apex:page to allow me to connect a custom button with exectuting some Apex code. Everything works fine, as per the many examples.

 

Here's the page:

 

<apex:page standardController="Opportunity" extensions="CloneOppButtonController"  action="{!autoRun}">
  <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
      You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have
      been redirected back to the record you clicked the button from.
  </apex:outputPanel>
</apex:page>

 Here's the relevant bits of the extension controller:

 

ublic with sharing class CloneOppButtonController {

	private final ApexPages.StandardController theController;

	public CloneOppButtonController(ApexPages.StandardController stdController) {
		theController = stdController;
	}

	public PageReference autoRun() {
		Id cloneId;	

		// Call the Apex Method we want to invoke and then show the new page
		try {
			cloneId = CloneOpportunity.cloneWithProducts(theController.getId());
		}
		catch (Exception e) {
			theController.getRecord().addError('Opportunity could not be cloned, check debug log for errors');
		}

		// New page is id of the cloned object if it worked, or previous page otherwise
		if (cloneId == null) cloneId = theController.getId();
		
		return new PageReference('/' + cloneId);
	}

 However, when a user clicks their browser Back button the dummy page is the previous page in the browser history and so it executes again - and creates another clone of the opportunity. As the destination page is a standard Salesforce page, there's little I can do on that - I can't guarantee control over the page layout as this is part of a package being developed.

 

 

 

I've seen on other forums about trying to use javascript to manipulate the browser history but this doesn't seem to fire before the action method.

 

Any other solutions ?

 

  • November 17, 2010
  • Like
  • 0

Has anyone else got the new Highlights Panel feature to work in Winter 11 ? I've tried this out on Opportunities, Cases and Custom Objects and while I can define them they never appear to work when I access a record.

 

Is this feature only for Enterprise or Unlimited Edition or is there a browser restriction ? (I'm using Safari & Firefox on a Macbook Pro).

 

Just to cut off the obvious answers:

Yes, I have assigned the page layout to my profile

Yes I did save it

Yes, I am using the new UI

No, I didn't try and use a text are field

Yes, I've looked at the help but didn't find any restrictions mentioned

 

I'm a certified consultant & developer and I do know how to develop apps on the platform.

  • October 14, 2010
  • Like
  • 0

Does anyone know a way of hiding the reports listed on the Home page of the above standard objects? (e.g. Active Accounts, Neglected Accounts).If I hide the standard report folder the links don't disappear. 

 

Better still anyone found a way to list your own custom reports in this section instead?

  • March 16, 2010
  • Like
  • 0
Salesforce certified Administrator, Consultant and Developer available to provide ad-hoc development, consultancy and administration services.
 
Experienced technical consultant across a number of business sectors applying rigorous config management, unit & system testing to all work. Experience in configuring & administering SalesForce CRM and performing bespoke design & development for ISVs on the Force.Com. All work undertaken, from Force.Com customisation through to Apex & VisualForce development. Solutions delivered as either Packages for you to download or code/changes delivered into your chosen Force.Com Org or Sandbox. Now booking from 31st May 2010 for UK contract positions.
 
Fixed price work undertaken and guaranteed for 30 days from delivery. Contact sf@enth.co.uk with a description of your requirements.
Message Edited by Enth on 03-21-2010 11:42 AM
  • November 10, 2008
  • Like
  • 0

I just got off the phone with SFDC support. Had a very quirky problem as follows.

 

Have a Roll Up Summary field on Opportunity to total the value of a custom currency field on Opportunity Products - lets call it Total List Price for example. When we create new Opportunties the value is 0, hurrah, and when we add products the value is correctly calculated.

 

The problem arises when the child records are deleted. When the Roll Up Summary field is recalculated it gets a non-zero floating point value (5.443 x 10-36 in my case). This gets rendered as 0 in the UI, but if you have any formula fields or validation rules checking this value, or comparing it to any other, then beware!

 

The solution (workaround) is you need to use something like ABS(total_list_price__c) > 0.00000001 instead of total_list_price__c != 0 in your formula or validation rule, or manually apply the ROUND function to the desired decimal places for your currencies.

 

Hope this helps someone else, it's like going back 20 years in IT!

  • February 20, 2013
  • Like
  • 1

Hi

In my organization  Users are Using Different Time Zones example( US-07:00, Uk +04:00).  I know whenever a record is saved in Salesforce it will be saved in UTC timing. And when I run a Lead standard report it converts the UtC timings to the Corresponding owner Timing and giving the Report.. But Am trying to write a Custom Report Between certain dates. Fore example I used as

"CreatedDate >=2013-04-01T00:00:00z and CreatedDate <=2013-04-30T23:59:59z"  It gives the report as per UTC timing and it is not converting as per Lead owners time zone. So am getting the difference in  standard and Custom Reports.

Can anyone help me out.

 

ThankYou

Hi,

 

I am looking at an option where I can integrate Salesforce with SQL database using a salesforce API.

 

Can anybody help me with the steps involved and how much complex it is to write the code. Also any sample code would be very helpful.

 

Thanks in Advance!!!

 

Regards,

Sunay

EG: Validation Rule: Once a quote is generated, lock the field Amount

 

How to achieve this functionality.can any one give your ideas on this.

 

 

  • March 14, 2013
  • Like
  • 0

Hey Guys,

 

Basically I have two fields.

 

Account Number & Account Number Backwards.

 

The reason behind this is to make sure there is no human error when entering the account number by reversing the number and checking for a match.

 

My problem is I can't seem to find anywhere, a way to reverse this back to check its equal!

 

IE:

 

Account Number: 123456

Backwards: 654321


Match: Account Number = Reverse(654321)

 

As a quick example.

 

Has anyone thought of something simliar ? Or a better way of storing clients bank account details within the system?

 

Regards,

 

Richie

I just got off the phone with SFDC support. Had a very quirky problem as follows.

 

Have a Roll Up Summary field on Opportunity to total the value of a custom currency field on Opportunity Products - lets call it Total List Price for example. When we create new Opportunties the value is 0, hurrah, and when we add products the value is correctly calculated.

 

The problem arises when the child records are deleted. When the Roll Up Summary field is recalculated it gets a non-zero floating point value (5.443 x 10-36 in my case). This gets rendered as 0 in the UI, but if you have any formula fields or validation rules checking this value, or comparing it to any other, then beware!

 

The solution (workaround) is you need to use something like ABS(total_list_price__c) > 0.00000001 instead of total_list_price__c != 0 in your formula or validation rule, or manually apply the ROUND function to the desired decimal places for your currencies.

 

Hope this helps someone else, it's like going back 20 years in IT!

  • February 20, 2013
  • Like
  • 1

I am having errors with compiling in my Test Class. 

 

I have commented out the parts that the errors were occuring below (and put them in bold/underlined) - and now I have 92% code coverage, but I just want to know how I can fix this in the future.  

 

The two errors I am receiving are:

  • Error: Compile Error: Illegal assignment from String to SOBJECT:Product2 at line 61 column 9
  • Error: Compile Error: Illegal assignment from String to Decimal at line 63 column 9

Any help would be greatly appreciated!


Thanks!

Chris

 

 

Here is the code:

 

@isTest
private class AssetTest {
//Classes always have to be uppercase
    static testMethod void testContractLine()
    {      
        Profile pr = [select id from profile where name=: 'System Administrator'];
        User u = new User(alias = 'standt', email='standarduser@vauto.com',emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',localesidkey='en_US', profileid = pr.Id,timezonesidkey='America/Los_Angeles', username='testemail1@vauto.com');
        insert u;
        System.runAs(u)
        {
            Account a = setupAccount();
            Contact co = setupContact();
            Opportunity o = setupOpportunity(a,co);
            Contract c = setupContract(o,a);
            Asset ae = setupAsset(a,c);
            
            Test.startTest();
                ae.Status = 'Active';
                update ae;
                
                List <Contract_Line__c> contractLines = [select Id from Contract_Line__c where Contract__c =: c.Id];
                
                //System.assertEquals(contractLines.size(),1); 
                
            Test.stopTest();
        }
    
    }
    //THE FOLLOWING IS OUR TEST DATA void means we're not returning anything
    static Account setupAccount(){ 
        Account a = new Account();
        a.Name = 'test';
        insert a;
        return a;
    }
    
    static Opportunity setupOpportunity(Account a, Contact c){
        Opportunity o = new Opportunity ();
        o.Name = 'test'; 
        o.CloseDate = System.today();
        o.StageName = 'Prospecting';
        o.AccountId = a.Id;
        o.Syndication_Primary_Contact_2__c = c.Id;
        insert o;
        return o;
    
    }
    
    static Contract setupContract(Opportunity o, Account a){
        Contract c = new Contract();
        c.Name = 'test';
        c.StartDate = System.today();
        c.Opportunity__c = o.Id;
        c.AccountId = a.Id;
        insert c;
        return c;
    }
    
    static Asset setupAsset(Account a, Contract c){
        Asset ae = new Asset();
        
//ae.Product2 = '30 Day Deposit';

 

        ae.Name = '30 Day Deposit';

        //ae.Price = '1400.00';

        ae.PurchaseDate = System.today();
        ae.InstallDate = System.today();
        ae.Contract__c = c.Id;
        ae.AccountId = a.Id;
        insert ae;
        return ae;
    
    }
    
    static Contact setupContact(){
        Contact co = new Contact();
        co.FirstName = 'Test';
        co.LastName = 'McGhee';
        insert co;
        return co;
    }



}

  • February 20, 2013
  • Like
  • 0

Heya,

 

I have a trigger to update ActivityDate field and Purpose__c multiselect picklist when a Task is Inserted or Updated. All of my system.debugs come up with the correct value, but nothing gets updated. Should I put it in an After Insert/Update maybe? I don't know why the fields aren't getting updated. 

 

trigger Task_SwayCard_AssignTask on Task (before insert, before update) {
	/* A trigger on the Task object that if the Task Owner is BDM or BDE,
			and the Subject of the task is like "Sway Card", then 
			the type of the task will change to Email, the due date of the task will
			be for the next coming Wednesday, and Sway Cards will be added
                        to purpose__c if it isn't already there.*/
    
    List<Task> tskSway = [SELECT id, ownerId, subject, purpose__c from Task 
                          where subject like '%Sway Card%' 
                          and id =: trigger.new]; // A list to hold "Sway Cards" tasks
    
    
    Date myDate = date.today();
    Date sunday = myDate.toStartOfWeek();
    Date nextSunday = sunday.addDays(7);
	Integer dayOfWeek = sunday.daysBetween(myDate);
    Date thisWednesday = sunday.addDays(3);
    Date nextWednesday = nextSunday.addDays(3);           
    	    
    System.debug(myDate);
    System.debug(sunday);
    System.debug(nextWednesday);
    
    If (tskSway != NULL){
    	system.debug('tskSway is Not Nulll!!');
        List<User> bdmOwner = [select id, name, userrole.name from user //A list to hold all BDMs in the org
        	                   where userrole.name like '%BDM%'];
    	List<User> bdeOwner = [select id, name, userrole.name from user
            	               where userrole.name like '%BDE%'];
		List<Task> tskToUpdate = new List<Task>();//A list to hold which tasks need to be updated
        
        For (Task t : tskSway) //Populate tskToUpdate based on whether the owner is a BDM or BDE, 
    	{						//and whether the Task is in the tskSway list.
        If (bdmOwner != null)
        {
     	   For (User u : bdmOwner)
        	{
            	If (u.id == t.ownerID)
            	{
                	tskToUpdate.add(t);            
            	}
        	}
        }
        If (bdeOwner != null)
        {
        	For (User u : bdeOwner)
            {
            	If (u.id == t.ownerID)
                {
            		tskToUpdate.add(t);
        		}
        	}
        }
        }
        
        If (tskToUpdate != null){
            System.debug('tskToUpdate is not Null!');
        For (Task t : tskToUpdate)
        {
            If (t.purpose__c.indexOf('Sway Cards') <= 0){
                system.debug('purpose has Sway Cards!' + t.purpose__c);
                t.purpose__c += ';Sway Cards;';
                system.debug(t.purpose__c);
            	}
            t.ActivityDate = nextWednesday;
            system.debug(t.ActivityDate);
        }
    }
    }
}

 

Hi guys,

when i have to create a new record of an object X, i would can to select the record type A (that i already have) and then in base of value selected in this one, then choose a second record type B with determinated values. Finally in base of values selected i will have a new page with determinated field in visualization. In practice i would a record type dependent on another record type....

tks

Hi

I Want insert one pdf file into salesforce ,what ever the data in the pdf i want store in salesforce  reocrds


Actually my pdf file containg the some records with numbers so i want insert these records in salesforce.

 

How can i achive these?

 

 

can any one help me how can i do that.

 

 

Thanks

Venkatesh

 

this is my query...plzz help me out...
 
¢Create a custom object “Revenue”. Create a field named “Total Revenue”.
¢Create another custom object Revenue Line Items. Create field named “Add Revenue” and lookup to Revenue.
¢Create a trigger on Revenue Line Items to update “Total Revenue” field on Revenue with the total(sum) of “Add Revenue” on all child records to the parent revenue record.
¢Handle insert, update and delete. Also handle change of parent revenue on child record.
 
BRIEF SUMMARY :
suppose “Total Revenue” = 30 and “Add Revenue” = 20...if i add 10 in “Add Revenue” than 
  “Total Revenue” should become 40 automatically and if i subtract 10 from “Add Revenue” than
  “Total Revenue” should become 20....
 
Any help would be appreciated....!!!

Hi

I have a Contact Object in case Detail

Now whenever i change the contact in case the last modified date must be update

How can i acheive this??

Thanks

 

 

  • February 20, 2013
  • Like
  • 0

Hello,

 

I was wondering if someone would be able to help me make this helper apex class and trigger more bulk friendly.  I highlighted the lines that seem failing with the bulk load:

 

public class GooalAndActuals {

 public Opportunity opportunityNew
 {
    get;set;
 }
 
 Actual__c l_oActual;
 AL_Goal__c l_oTarget;
 
 
 public String getGoalType(String aOpportunityType){
    if(aOpportunityType=='New Ad Sales') return 'NASR';
    else if(aOpportunityType=='Acct. Mgmt. Renewal') return 'Renewal';
    else if((aOpportunityType=='Acct. Mgmt. New Ad Only') || (aOpportunityType=='Acct. Mgmt. Late Renewal') || (aOpportunityType=='Acct. Mgmt. TER') || (aOpportunityType=='Acct. Mgmt. Supercede'))return 'Upsell';
    else if(aOpportunityType=='Big Deal') return 'Big Deal';
    else if(aOpportunityType=='Storefront') return 'Storefront';
    else if(aOpportunityType=='HR / FS') return 'HR / FS';
    else return '';
 }
 
 
 
 public ID CreateGoal(Id OwnerID)
 {
    System.debug('****Goal Method Call*****');
    ID GoalID;
    if(opportunityNew!=null)
    {       
        String GoalType = getGoalType(opportunityNew.Type);
        
        if((GoalType=='Renewal') || (GoalType=='Upsell'))
            return null;
        System.debug('Goal Type:'+GoalType);
            System.debug('Select id From Goal__c   Where  Year_Month__c=:'+opportunityNew.CloseDate.Year()+'-'+opportunityNew.CloseDate.Month() + ' And   Goal_Owner__c=:'+OwnerID);
            l_oTarget=null;
            for(AL_Goal__c l_oLoopTarget : [Select id, Year_Month__c, Goal_Owner__c,Goal_Type__c From AL_Goal__c 
                                                       Where 
                                                       Year_Month__c=:opportunityNew.CloseDate.Year()+'-'+opportunityNew.CloseDate.Month()
                                                       And 
                                                       Goal_Owner__c=:OwnerID]
                            )
                            {
                                l_oTarget=l_oLoopTarget;
                                break;
                            }
                        
                                            
            if(l_oTarget==null)
            {
                Date l_oNewTargetDate = Date.newInstance(opportunityNew.CloseDate.Year(), opportunityNew.CloseDate.Month(), 1);
                l_oTarget= new AL_Goal__c();
                l_oTarget.Goal_Amount__c=0;
                l_oTarget.Goal_Date__c=l_oNewTargetDate;
                l_oTarget.Goal_Owner__c=OwnerID;
                l_oTarget.Goal_Type__c = GoalType;
                insert l_oTarget;
            }
            GoalID=l_oTarget.Id;
                
    }   
    return GoalID;  
 }
 
public String getPaymentType()
 {
    String paymentType = null;
    if(opportunityNew!=null)
    {
        List<Recon_Detail__c> reconDetails = [Select id, Payment_Type__c From Recon_Detail__c Where Contract_Id__c=:opportunityNew.Contract_ID__c limit 1];
        if (reconDetails.size() > 0) {
            paymentType = reconDetails[0].Payment_Type__c;
        }
    }
    return paymentType;
 }
 
 public void CreateActual(Id OwnderID,ID GoalID)
 {
          
    if((opportunityNew!=null) && (GoalID!= null))
    {
            
            String getPaymentType = getPaymentType();
            
            l_oActual = new Actual__c();
            l_oActual.Opportunity__c=opportunityNew.Id;
            l_oActual.Opportunity_Amount__c=opportunityNew.Amount;
            l_oActual.AccountName__c=opportunityNew.AccountId;
            l_oActual.Goal__c=GoalID;
            l_oActual.Actual_Owner__c=OwnderID;
            l_oActual.Payment_Type__c=getPaymentType();
            insert l_oActual;
    }
 }
 
 public void DeleteActual(Id OpportunityID)
 {
    if(opportunityNew!=null)
    {
        List<Actual__c> l_olstActual = [Select id From Actual__c Where Opportunity__c=:opportunityNew.Id];
        delete l_olstActual;            
    }
 }
}

 

trigger CreateActualsAndTargets 
on 
Opportunity (after insert, after update) 
{
 if(Trigger.isUpdate || Trigger.isInsert)   
    {
      Map<ID,Opportunity> l_OpportunityOwners = new Map<ID,Opportunity> ([Select id, Opportunity_Owner_Manager__c, Contract_ID__c,StageName,Amount,AccountId,CloseDate, o.OwnerId, Type From Opportunity o where id in:trigger.newMap.keySet()]);
      GooalAndActuals l_oGooalAndActuals = new GooalAndActuals ();
        
      for(Opportunity l_oOpportunityNew:l_OpportunityOwners.values())
      {
        System.debug('********************Trigger Start***********************');
        if(l_oOpportunityNew.StageName=='Closed/Won')
        {
          ID SalesRepGoalID,ManagerGoalID;
          //modified
          l_oGooalAndActuals = new GooalAndActuals ();
          l_oGooalAndActuals.opportunityNew=l_oOpportunityNew;
          
          
          //Goal Creation
          SalesRepGoalID=l_oGooalAndActuals.CreateGoal(l_oOpportunityNew.OwnerId);//SalesRep Goal Creation
          if(l_oOpportunityNew.Opportunity_Owner_Manager__c!= null)
          {
            ManagerGoalID=l_oGooalAndActuals.CreateGoal(l_oOpportunityNew.Opportunity_Owner_Manager__c);//Manager Goal Creation
          }
          
          
          //Actual Deletion
          if(Trigger.isUpdate)
          {
            l_oGooalAndActuals.DeleteActual(l_oOpportunityNew.Id);
            
          }
          
          //Actual Creation
          l_oGooalAndActuals.CreateActual(l_oOpportunityNew.OwnerId,SalesRepGoalID);//SalesRep Actual Creation
          if(l_oOpportunityNew.Opportunity_Owner_Manager__c!= null)
          {
            l_oGooalAndActuals.CreateActual(l_oOpportunityNew.Opportunity_Owner_Manager__c,ManagerGoalID);//Manager Actual Creation
          }
          
          
          
        }
        
        /*
        Start:  Project
        *   Author          |Author-Email            |Date       |Comment
        *   ----------------|------------------------|-----------|--------------------------------------------------
        *   Sakonent Admin  |abrar.haq@sakonent.com  |02.16.2012 |Initial code 
        *   Purpose: It will remove Actual record(s) associated to Opportunity if Stage goes from 'Closed/Won' to some other stage.
        */        
        else if(Trigger.isUpdate)
        {
            if(Trigger.oldMap.get(l_oOpportunityNew.Id).StageName == 'Closed/Won' && l_oOpportunityNew.StageName != 'Closed/Won')
            {
                l_oGooalAndActuals = new GooalAndActuals ();
                l_oGooalAndActuals.opportunityNew=l_oOpportunityNew;
                l_oGooalAndActuals.DeleteActual(l_oOpportunityNew.Id);
            }
        }
        /*End: Project */        
        
      }
    }
   
}

 

 

 

How can i add an another filed in this to check

 

in this validation i am trying to check if lead follow up is false when only status is qualified  and it keeps on throwing errors.

 

this is the workingone 

 

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 

if('{! Lead.Follow_up_done__c }' == false ){ 
alert('Lead can only be converted if status is Qualified.'); 
}else{ 
window.location.href = "/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}&id={!Lead.Id}&nooppti=1"; 
}

 

this is the one not working   - Ami doing the && part ri8

 

{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}

if('{! Lead.Follow_up_done__c }' == false &&' {! Lead.Sales_Lead_Follow_up__c }' == 24 hrs)

{
alert('Lead can only be converted if status is Qualified.');
}else{
window.location.href = "/lead/leadconvert.jsp?retURL=%2F{!Lead.Id}&id={!Lead.Id}&nooppti=1";
}

 

Thanks

Akhil

 

  • November 14, 2012
  • Like
  • 0

HI ,

 

I am trying to have an add to camapgin buttonon my custom object list page but unfortunately i could not do it and asked for SF help they said we can only have add to campaign func in leads and contacts . 

 

So my Idea is to put a list button on my custom object list page which takes them to a standard report where they have ADD TO CAMPAIGN button . So i am stuck with how to take the records to the report.

 

If user selects MY Custom records list he has to select some of those records and then hit the button which should take to the report which those selected records , IS THIS POSSIBLE?)

 

Thanks

Akhil

  • November 14, 2012
  • Like
  • 0
I require some help customizing my application. When you click on an Attachement (in the Notes and Attachements related list on a record detail page),  an Attachment detail page opens up, where you have to click on the 'View File' to open the attachment. Is there a way, where I could open the attachment by clicking the attachment on the record detail page. (In short I want to eliminate the intermediate Attachment detail page).
 
Waiting for some reply.

Hello,

 

I need to add following fields from SF to Reports. These fields do not need to be added to the page layout.

 

1. Current Step Owner: Name of person (or people) that the approval process is currently pending with


2. Current Step Name: Name of Step that the approval process is currently pending with


3. Days in current step: Calculation of Time elapsed since an approval entered into the current approver’s bucket for ‘action’ and today’s date (date of generating the report)

 

All three of these fields require reporting off of the approval process

In short I want to know for each type of approval process for a custom object, which step of the approval it is in, who the approver is, and how long it has been in that step.

 

I see that, there is ProcessInstance and ProcessInstanceStep objects which stores this data, can someone provide SOQL queries sample on how to do this or any other way of reporting?

  • November 14, 2012
  • Like
  • 0

We were looking for a way that we can relate a email address (salesforce or similar) wherein our user can send an email to the address and the email details show up in the salesforce for that particular account or lead. Is there a way to do this in salesforce.

Vic Sawhney

Hello All,

 

Does anyone have any experience implementing delegated authentication SSO where the user logs into their company Intranet, which authenticates them to access their Salesforce.com org without any further login? Is this possible?

Hello Board,

 

Salesforce doc says,

 

When a rich text area field is used in a formula, the HTML tags are stripped out before the formula is run. For example, when a rich text area field is used in a validation rule's criteria, the HTML tags are removed before the evaluation.

 

I am creating a cross object formula field with return type TEXT to access Rich Text Area field. But RTA field was not available there.

 

What I am missing here?

 

Thanks,

Devendra