• Mike Arthur
  • NEWBIE
  • 200 Points
  • Member since 2014

  • Chatter
    Feed
  • 5
    Best Answers
  • 4
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 47
    Replies
Hello,

I am working to build a trigger that updates an Opportunity when a Task is added to the opportunity. The trigger is successful in the Sandbox, however my Apex Class to test the trigger is presenting 0% code coverage. I am new to Apex and more of a "Desktop Admin" so any help would be appreciated.

The Trigger:
trigger OptyUpdateonTaskInsert on Task (after insert, after update)
{
    List<Opportunity> lstOpty = new List<Opportunity>();
    for(Task T : Trigger.New)
    {
        if(T.WhatId != null && string.valueof(T.WhatId).startsWith('006'))
        {
            Opportunity opt = new Opportunity(id=T.WhatId);
            lstOpty.add(opt);
        }
    }
    
    update lstOpty;
}

The Class:
 
@isTest(seealldata=true)
public class testTask{
    private static testmethod void testTaskActivity(){
        
        Opportunity o = new Opportunity(
        				AccountId 	= 	'0015500000AByHM',
            			Name 		=	'Test 2',
            			StageName	=	'Proposal Review',
            			CloseDate	=	(System.now()).date(),
            			Type		=	'New System');
        insert o;
                   
        Task t = new Task(
            			WhatId 		= 	o.Id, 
                        Subject 	= 	'Sample Email', 
                        Priority 	= 	'Normal', 
                        Status 		= 	'Completed',
            			OwnerId 	=	UserInfo.getUserId());
        insert t;

    }
}

 
Hello,

I was following the section in the trailhead as below:
Developer Beginner-->Data Modeling-->Creating Object Relationships-->Creating a Master-Detail Relationship

After creating the multilevel master-detail relationships as below:
1, one candidate can have one or more job applications
2, one job application can have one or more reviews

I tried to created another relevant master-detail relationship as below:
3, one position can have one or more job applications

But it's not feasible, and the field type-->Master-Detail Relationship has information as below:
You cannot create this type of field because a master-detail relationship already exists on this object, and this object is the master in another master-detail relationship.

Can anyone adivse is it possible to create the relationship 1,2 and 3 above?
If not possible, any equivalent substitution?

Thank you in advance.

Burt



 
Hello,
I need to get an information from an Inbound email and set it in a field.
The information always will look as: DUNS: 123456789
I want to do it with a Process Builder, with a immediate action "Update Record". I am trying to fill up the field with the 9 numbers, but I don´t know how to do get the strings.
I did a Formula like this: TRIM(TEXT(FIND("DUNS:", [EmailMessage].TextBody  )+10))
But it just gets the: 12
Does anyone know how to do it?


 
Hello,

In reports, we could give Read or Read/Write permission for set of users.

I see that, few reports still are possbile to edite even if the user has only read permission on it.

User is not an admin and also not the owner 
What can be possible reasons ?
Hi,

Still getting my feet wet with the developer thing, so I am not sure where to start on this one. 

I have a custom lookup field in my Contacts object called Relationship Manager, which is manually populated with a user name. I also have a custom picklist(multi select) field called Relationship Type, which includes Donor and Board Member as choices. 

I want a trigger that will make the Relationship Manager field mandatory to populate by the user when either the Donor and/or Board Member types are selected.

Thanks
I'm logged in to Trailhead as myself and working on this unit:
https://trailhead.salesforce.com/content/learn/modules/apex_patterns_sl/apex_patterns_sl_apply_uow_principles

Scroll to 'Preparation for the Challenges'
Click on 'Deploy to Salesforce' under 'Deploy the ApexMocks open source library'
That takes me to this page
https://githubsfdeploy.herokuapp.com/?owner=financialforcedev&repo=fflib-apex-mocks

Click on 'Login to Salesforce'
That gives me this page
https://brave-badger-257278-dev-ed.my.salesforce.com/setup/secur/RemoteAccessErrorPage.apexp?oauth_error_code=1800

"We can't authorize you because of an OAuth error. For more information, contact your Salesforce administrator.
1800 : There was a problem in setting up your remote access"

The first time I tried it I hadn't launched Trailhead Playground so the login url above had the domain of my Trailhead login.
I launched Trailhead Playground and the login url then had the domain of my Trailhead Playground.

I have seen other similar questions but no conclusive explanation. I have tried it on my regular computer and also on another that has never been used for Trailhead or Salesforce before.

Any suggestions?
I have a Visualforce page for creating Opportunity Line Item (OLI) records.  I have a custom OLI field 'Against__c'.  It is a lookup to a custom object 'Account_Course__c'.

Account_Course__c has a custom field Account__c which is a lookup to Account.

I want the OLI Against__c lookup to be filtered so that only Account_Course__c records with the same Account as the Opp of the OLI are returned.

Since I cannot span the relationship to Opportunity in the Against__c lookup filter I have another custom field Account__c on OLI, also a lookup to Account.  I populate this with the Opp Account when the page is rendered.

When I create an OLI record, the 'Account' field is pre-filled correctly but 'Against' lookup returns no rows (when there are valid values available).  If I then edit the newly created OLI record, Account is populated correctly and the Against lookup now shows the correct valid values.

In the online help for examples of filtered lookups it gives the example of a filter on Case lookup to Contact so that only Contacts with the same Account as the Case are returned.  My example has a similar data model structure, except I'm using a VF page.

The problem is the same as the one described here - https://help.salesforce.com/articleView?id=000239898&type=1 - but OLI to Account and Account Course to Account are both lookups.  No master detail.

What is also similar to the above is that if I type in the name of a valid 'Against' record when creating an OLI record, it saves correctly.

Any ideas?

Thanks,
Mike.
Hi,

I have a notification that self signed certificate is about to expire.  I have checked out other threads on here but they didn't give a complete answer.  I have followed the help article here https://help.salesforce.com/articleView?id=security_keys_creating.htm&type=0&language=en_US
but do I need to create a new one?  One of the threads mentioned renewing the expiring one.  Any action needed on whatever system is using the certificate?

Many Thanks,
Mike.
I'm sure I had 39,000+ points as I was looking forward to breaking through 40,000.  I just completed a new badge and now I only have 35,000 :-(

Where did they go?
My Visualforce Opportunity Product selection page has an apex:inputField tag to capture the Quantity.

The value is preset to 1 as a default.

The data type of the standard field Quantity is Number(10, 2).

When the page displays to enter a new Opportunity Product, the quantity is displayed as 1.00.

How can I make it display as 1 with no decimal?

Thanks,
Mike.
I have inherited an org where, for various reasons, the Account page has been completely written in VIsualforce, field by field.

Now there is a situation where, had standard pages been used, we would use different page layouts for different profiles.

How is this best achieved in Visualforce?  Do I need to add a 'rendered = ' attribute to every field that is displayed?

Would a 'rendered = ' attribute within the pageBlock Section component control whether the entire section is displayed or not?

Many Thanks,
Mike.
I came across this in the help text for Roll-Up Summary Fields (https://help.salesforce.com/HTViewHelpDoc?id=fields_about_roll_up_summary_fields.htm)

User-added image

What does it mean?

RUSs can only be created on master-detail relationships, not lookups.
I set up a lookup field with 'Don't allow deletion...' option on a detail object and created a RUS on the master but the the lookup on the detail wasn't available as a count.

It sounds like an important point but I can't get how it is applied.

Anyone know?

Thanks,
Mike.
I have a custom controller that I'm trying to write a unit test for.
In the unit test I'm trying to call the method in the controller that does the work - it runs a SOQL query to produce a list via a wrapper class on a vf page.
The compile error is 'Method does not exist or incorrect signature: SummariseQuotedWorks.getWISumOut()'.
The error is on the line 'ResultList = SummariseQuotedWorks.getWISumOut();'.
I think I just need a pointer on the syntax due to the added complexity of the method being tested returning a custom object.
Here's the controller class:
public class SummariseQuotedWorks {
    private final Quote qte;
    
    public SummariseQuotedWorks(ApexPages.StandardController controller) {
        this.qte = (Quote)controller.getRecord();
        }

/* Use a wrapper class to store the aggregate values in a way that is accessible to Visualforce */

public class WISum{
        public String Acct {get; set;}
        public String WorkItem {get; set;}
        public Decimal TotalCost {get; set;}
        public WISum(string a,string w,decimal c){
                this.Acct=a;
                this.WorkItem=w;
                this.TotalCost=c;
        }
}


public List<WISum> WISumList = new List<WISum>();

public List<WISum> getWISumOut(){
system.debug('IAmHere');

		String theAcct = '';

system.debug('1: qte: '+qte.id);

        AggregateResult[] AgR = [SELECT Account__r.Name AC, WorkItem__r.Name WI, sum(cost1__c) TC FROM Quoted_Work__c
where Quote__c=:qte.Id
group by rollup(Account__r.Name, WorkItem__r.Name)];

system.debug('QW AgR size: '+AgR.size());

        for (AggregateResult WIRecs : AgR) {


       
 /*      WISumList.add(new WISum((String) WIRecs.get('AC'), (String) WIRecs.get('WI'), (Decimal) WIRecs.get('TC'))); */
 	        WISumList.add(new WISum((String) ((WIRecs.get('AC') == theAcct) ? '' : WIRecs.get('AC')), (String) (WIRecs.get('WI') == null && WIRecs.get('AC') == null ? 'Grand Total' : (WIRecs.get('WI') == null ? 'Subtotal' : WIRecs.get('WI'))), (Decimal) WIRecs.get('TC')));
 
        	theAcct = (String)WIRecs.get('AC');
 
        }
        return WISumList;
}
    
}

Here's the test class:
 
@isTest
private class SummariseQuotedWorksTest {
	
	@isTest static void test_method_one() {

// Create Test Data:

		RecordType art = [select id,Name from RecordType where SobjectType='Account' and Name='Head Office' Limit 1];
        Account a = new Account(
            Name='Mike',
            RecordTypeId=art.Id,
            Region__c='National',
            Status__c='Active',
        	Type='Prospect',
        	CurrencyIsoCode='GBP',
        	Phone='1',
            Sage_Acc__c='1',
            Sage_Company__c='Water Sage',
        	Division__c='Water');
        insert a;

		RecordType crt = [select id,Name from RecordType where SobjectType='Contact' and Name like '%Contact%' Limit 1];
        Contact ctct = new Contact(
            AccountId=a.Id,
            LastName='Smith',
            RecordTypeId=crt.Id,
        	CurrencyIsoCode='GBP',
        	Phone='1');
        insert ctct;

		RecordType ort = [select id,Name from RecordType where SobjectType='Opportunity' and Name like '%Project%' Limit 1];
        Opportunity opp = new Opportunity(
            Name='Mike',
            AccountId=a.Id,
            RecordTypeId=ort.Id,
        	Type='New Business',
            LeadSource='Other',
            StageName='Present Quote',
            CloseDate=Date.valueOf('2015-12-31'),
        	CurrencyIsoCode='GBP',
        	Division__c='Water');
        insert opp;

        Quote q = new Quote(
        Name='Mike',
        OpportunityId=opp.Id,
        Type__c='Project',
        Account_Manager__c='Mark Viner',
        Contact=ctct,
        Sage_Company__c='Water Sage');
        insert q;

         Consumable__c consum = new Consumable__c (
            Name='A Consumable',
            Active__c=TRUE,
            Price__c=1,
            Product_Code__c='A Code',
            Product_Description__c='A Description');
        insert consum;

        Work_Item__c w = new Work_Item__c (
            Name='A Work Item',
            Sample_Consumable__c=consum.Id);
        insert w;

        Quoted_Work__c QW = new Quoted_Work__c (
            Account__c = a.Id,
            Quote__c= q.Id,
            WorkItem__c = w.Id,
            Assigned_Role__c = 'Technician',
            Duration_hrs__c = 1,
            Quantity__c = 1,
            Frequency__c = 'Annually');
        insert QW;

        Covered_Consumable_2__c CC2 = new Covered_Consumable_2__c (
            Site__c = a.Id,
            Quote__c= q.Id,
            Consumable__c = consum.Id,
            Quantity__c = 1);
        insert CC2;

// Set current page so that controller picks up Quote Id:

        PageReference pageRef = new PageReference('/apex/worksSummary?Id='+q.Id);

        Test.setCurrentPage(pageRef);

// Instantiate a new SummariseQuotedWorks object:

        Test.startTest();
	        SummariseQuotedWorks controller = new SummariseQuotedWorks(new ApexPages.StandardController(q));

            List<WISum> ResultList = new List<WISUm>();
            ResultList = SummariseQuotedWorks.getWISumOut();
	        system.assertEquals(controller.WISumList[0].TotalCost.abs(),45);
        Test.stopTest();

	}
public class WISum{
        public String Acct {get; set;}
        public String WorkItem {get; set;}
        public Decimal TotalCost {get; set;}
    }

}

Thanks,
Mike.

 
Hi

I was expecting to find this information easily but I've not found anything.

In my controller I run a SOQL statement with 'group by rollup' and I then display the records in a visualforce table.

Each time that a subtotal is displayed, I want to either indent or right justify the word 'Subtotal' and do the same for the grand total.  I can't find anything that explains how to apply this formatting in the controller.

Any help would be greatly appreciated.

Here's the controller:
 
public class SummariseQuotedWorks {
    private final Quote qte;
    
    public SummariseQuotedWorks(ApexPages.StandardController controller) {
        this.qte = (Quote)controller.getRecord();
        }
    
/* Use a wrapper class to store the aggregate values in a way that is accessible to Visualforce */

public class WISum{
        public String Acct {get; set;}
        public String WorkItem {get; set;}
        public Decimal TotalCost {get; set;}
        public WISum(string a,string w,decimal c){
                this.Acct=a;
                this.WorkItem=w;
                this.TotalCost=c;
        }
}

public List<WISum> WISumList = new List<WISum>();

public List<WISum> getWISumOut(){

		String theAcct = '';

        AggregateResult[] AgR = [SELECT Account__r.Name AC, WorkItem__r.Name WI, sum(cost1__c) TC FROM Quoted_Work__c
where Quote__c=:qte.Id
group by rollup(Account__r.Name, WorkItem__r.Name)]; 

        for (AggregateResult WIRecs : AgR) {


       
 /*      WISumList.add(new WISum((String) WIRecs.get('AC'), (String) WIRecs.get('WI'), (Decimal) WIRecs.get('TC'))); */
 	        WISumList.add(new WISum((String) ((WIRecs.get('AC') == theAcct) ? '' : WIRecs.get('AC')), (String) (WIRecs.get('WI') == null ? 'Subtotal' : WIRecs.get('WI')), (Decimal) WIRecs.get('TC')));
 
        	theAcct = (String)WIRecs.get('AC');
 
        }
        return WISumList;
}
    
}

Here's the VF:
 
<apex:page standardController="Quote" extensions="SummariseQuotedWorks">
	<apex:pageBlock title="Summary of Works for Quote: {!Quote.Name}">
		<apex:pageBlockSection >
			<apex:pageBlockTable value="{!WISumOut}" var="WISummary">
				<apex:column value="{!WISummary.Acct}">
					<apex:facet name="header">Site</apex:facet>
				</apex:column>
				<apex:column value="{!WISummary.WorkItem}">
					<apex:facet name="header">Work Item</apex:facet>
				</apex:column>
				<apex:column value="{!WISummary.TotalCost}">
					<apex:facet name="header">Total Cost</apex:facet>
				</apex:column>
			</apex:pageBlockTable>
		</apex:pageBlockSection>
	</apex:pageBlock>
</apex:page>

Here's the ouput:

User-added image

Wherever 'Subtotal' appears, I want it indented or right justified.

I've not modifed the controller yet to display 'Grand Total' in the last line but will do and will want that formatted too.

Many Thanks,
Mike.

 
Hi,

I have installed Force.com IDE (see versions of all components below).  If I try to do something simple like increase the length a custom text field, I get

'File only saved locally, not to server' and
'Save error: Conflict found while preparing to save 'Account.object' to server.  Remote instance has been updated since last save or sync.  Use the Synchronize Perspective to resolve the conflict.    Account.object    /MA Dev/src/objects    line 1    Force.com save problem'

I refreshed from server and then got this 8 times:
'Refresh error: Metadata API received improper input. Please ensure file name and capitalization is correct. Load of metadata from db failed for metadata of type:ConnectedApp and file name:Salesforce_Chatterbox.    package.xml    /MA Dev/Referenced Packages/Salesforce1 and Chatter Apps    line 1    Force.com retrieve problem'

Environment is
Spring '16 Dev Org with custom domain
Spring '16 Force.com IDE (36.0.0)
Eclipse Mars.2 (4.5.2)
Java 8 Update 74
Windows 7 64 bit

I have reviewed other threads, I needed to click 'work online' as default was offline, still having trouble.
I can sync the object with server and the changes are propogated but this has to be done every time.

Any ideas?

Many Thanks,
Mike.
The requirement is to show the UK parliamentary constituency based on the postcode of an account.  Using a custom object to store the constituency for each postcode would result in pretty close to 1 million rows.

1 - Can anyone share experience of working with an object on this scale?  What kind of performance impact may be expected?  Any data loading challenges?

2 - It feels like Apex would be needed to populate an Account 'Constituency' field based on the postcode.  Anyone have any alternative suggestions?

There are other considerations such as the impact on the data volume usage and what happens when boundaries are changed, but just looking to see if this is worth considering further.

Many Thanks,
Mike.
I don't recall receiving an email alert for the certification maintenance exams for Winter '16 on either Admin or Dev certs.  Googling for the training resources only revealed that others had noted the same.

To save others the time of hunting for the training material, it's here:
Winter ‘16 Developer Release Exam (http://certification.force.com/pkb/articles/Public_KB/Winter-16-Developer-Release-Exam/?q=winter+16&l=en_US&fs=RelatedArticle)
Winter ‘16 Administrator Release Exam (http://certification.force.com/pkb/articles/Public_KB/Winter-16-Administrator-Release-Exam/?q=winter+16&l=en_US&fs=RelatedArticle)

The modules are listed here:
Winter '16 Release Training for Certified Professionals (https://help.salesforce.com/HTTrainingModulesDetail?courseId=a1S300000032xGB)
(same for admin and dev)
I'm sure this must be a common requirement but I haven't been able to find what I need.

I have a Visualforce page with a standard controller.  The user updates one field on that page then clicks a button to update the record and then display a different visualforce page with a custom controller which uses the value that has just been updated.

How can I ensure that the first update has completed before the new page is displayed?

I originally had two buttons, one to 'Update' and one to display new page.  However, I fear impatient users will continue before the update has completed, so want to combine into one and bake in the control.  I have used a Javascript function to pass parameters and display the second page.

Thanks,
Mike.
Hello,

An application is to be developed to allow information to be submitted to Salesforce from a public website.  Public users will not have Salesforce credentials.  What's the best way to achieve authentication for Rest API access?

I can see in the Force.com Rest API Developer's Guide that there is a username/password OAuth authentication flow.Are there any security drawbacks with this?
Would you normally set up a user specifically for this purpose, which will never be used by a real person, rather than using a 'real person' user, whose password may/should change at some point?
Any other suggestions?

Many Thanks,
Mike.
Hi,

I have a new custom object with custom fields in my sandbox that I want to deploy to production.  I want the object permissions to come over too.

From what I read, if I include the relevant profiles in the change set then only the settings relating to the new custom objects will be included.

However, I need to be absolutely certain about this as the profiles in production have been customised and are not in sync with sandbox.  My concern is that including the profiles in the change set will deploy all profile settings and overwrite those in prod.

Any experience of this that anyone can share would be much appreciated.

Thanks,
Mike.
I would appreciate some best practice advice here -

I have an insert trigger to populate a field in the record being inserted into a custom object with the value of a field in the parent object.

From other posts I learned that trigger.new cannot see any related fields.

Taking the value from a formula field on my custom object would normally be a choice but maximum number of object references has been reached due to high number of formula fields so I can't create another.

So I need to look up the value with SOQL and store it in a map with the Id of the record being inserted.

Which means that my before insert trigger must now be an after insert in order to know the Id.

If I query into a map and then update the field on the record being inserted I then need to issue an update DML statement, so in order to populate my field I need an insert and an update.

Seems inefficient - is that the only way?

Thanks,
Mike.
Hi,

I'm writing a test class for a trigger and getting 'Non-void method might not return a value or might have statement after a return statement.'.

Should be a simple thing to fix but I can't see it I'm afraid.  Any advice?

The error is on the line
update taskToUpdate;

Here is the full class:
 
@isTest
                                
public class TestTaskBeyondContractEndDate {

    public static Task createTestTask() { 

        Account a = createAccount();

        Contract con = createContract(a);

        Vist_Detail__c conwk = createContractWork(a, con);

        Task t = createTask(conwk, '2015-07-31');  // Create task with date before Contract end date  

        Task taskToUpdate = [SELECT Id, ActivityDate FROM Task WHERE Id=:t.Id];
        taskToUpdate.ActivityDate = Date.valueOf('2015-12-08');
        update taskToUpdate;
        
   }            
    
// Helper methods

    private static Account createAccount() {
		RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='Office' Limit 1];
        Account a = new Account(
            Name='Mike',
            RecordTypeId=rt.Id,
            Region__c='National',
            Status__c='Active',
        	Type='Prospect',
        	CurrencyIsoCode='GBP',
        	Phone='1',
        	Division__c='Water');
        insert a;
        return a;
    }
    
   private static Contract createContract(Account a) {        
		RecordType rt = [select id,Name from RecordType where SobjectType='Contract' and Name='Maintenance Contract' Limit 1];
        Contract con = new Contract(                
            RecordTypeId=rt.Id,
        	AccountId=a.Id,
        	Status='Active',
        	Current_State__c='New',
        	CurrencyIsoCode='GBP',
        	G_Division__c='Water',
            endDate=Date.valueOf('2015-12-31'), // yyyy-mm-dd
        	Contract_Type__c='Maintenance Contract');      
        insert con;
        return con;
    } 

    private static Vist_Detail__c createContractWork(Account a, Contract con) {        
        Vist_Detail__c conwk = new Vist_Detail__c(                
            RecordTypeId='01220000000UVOh',
        	Account__c=a.Id,
            Contract__c=con.ID,
            Service_Owner__c='005w0000003Y7Nl',
        	CurrencyIsoCode='GBP',
        	Division__c='Water',
            Start_Date__c=Date.valueOf('2015-05-08'),
        	Service_Summary__c='Chemistry',
        	Technician_Comments__c='abcd');      
        insert conwk;
        return conwk;
    } 

        private static Task createTask(Vist_Detail__c conwk, string Tdate) {
        Task t = new Task(
            RecordTypeId='01220000000UUkC',
            WhatId=conwk.Id,
            Subject='abcd',
            ActivityDate=Date.valueOf('2015-05-08'),
        	CurrencyIsoCode='GBP',
            Status='Open',
            Activity_Type__c='Service Visit',
            Description='abcd',
            Priority='Normal',
        	Division__c='Water');
        insert t;
        return t;
    }
    
//    private static void updateTask(Task theTask, string theDate){
//        Task taskToUpdate = [SELECT Id, ActivityDate FROM Task WHERE Id=:theTask.Id];
//        taskToUpdate.ActivityDate = Date.valueOf(theDate);
//        update taskToUpdate;
//    }

}



Many Thanks,
Mike.
This has worked fine for me in the past but today I'm working through Data Security modules and when I click 'Login to Take Chalenges' I get a pop up 'Login with Salesforce Account' button.  When I click that I get 'URL No Longer Exists'.  Anyone else getting same?
Hi

In the dev console on Firefox I go to Test, New Run and select my Test Class to run.  I'm in UK and today is 9th April (9/4 in UK).  The test gets enqueued for 4th September - 9/4 US style!

If I do the same in Chrome it is enqueued for today.  But I'd rather use Firefox!

Any suggestions?

Thanks,
Mike.
I don't recall receiving an email alert for the certification maintenance exams for Winter '16 on either Admin or Dev certs.  Googling for the training resources only revealed that others had noted the same.

To save others the time of hunting for the training material, it's here:
Winter ‘16 Developer Release Exam (http://certification.force.com/pkb/articles/Public_KB/Winter-16-Developer-Release-Exam/?q=winter+16&l=en_US&fs=RelatedArticle)
Winter ‘16 Administrator Release Exam (http://certification.force.com/pkb/articles/Public_KB/Winter-16-Administrator-Release-Exam/?q=winter+16&l=en_US&fs=RelatedArticle)

The modules are listed here:
Winter '16 Release Training for Certified Professionals (https://help.salesforce.com/HTTrainingModulesDetail?courseId=a1S300000032xGB)
(same for admin and dev)
This has worked fine for me in the past but today I'm working through Data Security modules and when I click 'Login to Take Chalenges' I get a pop up 'Login with Salesforce Account' button.  When I click that I get 'URL No Longer Exists'.  Anyone else getting same?
Hi,

I have a notification that self signed certificate is about to expire.  I have checked out other threads on here but they didn't give a complete answer.  I have followed the help article here https://help.salesforce.com/articleView?id=security_keys_creating.htm&type=0&language=en_US
but do I need to create a new one?  One of the threads mentioned renewing the expiring one.  Any action needed on whatever system is using the certificate?

Many Thanks,
Mike.
My Visualforce Opportunity Product selection page has an apex:inputField tag to capture the Quantity.

The value is preset to 1 as a default.

The data type of the standard field Quantity is Number(10, 2).

When the page displays to enter a new Opportunity Product, the quantity is displayed as 1.00.

How can I make it display as 1 with no decimal?

Thanks,
Mike.
I came across this in the help text for Roll-Up Summary Fields (https://help.salesforce.com/HTViewHelpDoc?id=fields_about_roll_up_summary_fields.htm)

User-added image

What does it mean?

RUSs can only be created on master-detail relationships, not lookups.
I set up a lookup field with 'Don't allow deletion...' option on a detail object and created a RUS on the master but the the lookup on the detail wasn't available as a count.

It sounds like an important point but I can't get how it is applied.

Anyone know?

Thanks,
Mike.
I have a custom controller that I'm trying to write a unit test for.
In the unit test I'm trying to call the method in the controller that does the work - it runs a SOQL query to produce a list via a wrapper class on a vf page.
The compile error is 'Method does not exist or incorrect signature: SummariseQuotedWorks.getWISumOut()'.
The error is on the line 'ResultList = SummariseQuotedWorks.getWISumOut();'.
I think I just need a pointer on the syntax due to the added complexity of the method being tested returning a custom object.
Here's the controller class:
public class SummariseQuotedWorks {
    private final Quote qte;
    
    public SummariseQuotedWorks(ApexPages.StandardController controller) {
        this.qte = (Quote)controller.getRecord();
        }

/* Use a wrapper class to store the aggregate values in a way that is accessible to Visualforce */

public class WISum{
        public String Acct {get; set;}
        public String WorkItem {get; set;}
        public Decimal TotalCost {get; set;}
        public WISum(string a,string w,decimal c){
                this.Acct=a;
                this.WorkItem=w;
                this.TotalCost=c;
        }
}


public List<WISum> WISumList = new List<WISum>();

public List<WISum> getWISumOut(){
system.debug('IAmHere');

		String theAcct = '';

system.debug('1: qte: '+qte.id);

        AggregateResult[] AgR = [SELECT Account__r.Name AC, WorkItem__r.Name WI, sum(cost1__c) TC FROM Quoted_Work__c
where Quote__c=:qte.Id
group by rollup(Account__r.Name, WorkItem__r.Name)];

system.debug('QW AgR size: '+AgR.size());

        for (AggregateResult WIRecs : AgR) {


       
 /*      WISumList.add(new WISum((String) WIRecs.get('AC'), (String) WIRecs.get('WI'), (Decimal) WIRecs.get('TC'))); */
 	        WISumList.add(new WISum((String) ((WIRecs.get('AC') == theAcct) ? '' : WIRecs.get('AC')), (String) (WIRecs.get('WI') == null && WIRecs.get('AC') == null ? 'Grand Total' : (WIRecs.get('WI') == null ? 'Subtotal' : WIRecs.get('WI'))), (Decimal) WIRecs.get('TC')));
 
        	theAcct = (String)WIRecs.get('AC');
 
        }
        return WISumList;
}
    
}

Here's the test class:
 
@isTest
private class SummariseQuotedWorksTest {
	
	@isTest static void test_method_one() {

// Create Test Data:

		RecordType art = [select id,Name from RecordType where SobjectType='Account' and Name='Head Office' Limit 1];
        Account a = new Account(
            Name='Mike',
            RecordTypeId=art.Id,
            Region__c='National',
            Status__c='Active',
        	Type='Prospect',
        	CurrencyIsoCode='GBP',
        	Phone='1',
            Sage_Acc__c='1',
            Sage_Company__c='Water Sage',
        	Division__c='Water');
        insert a;

		RecordType crt = [select id,Name from RecordType where SobjectType='Contact' and Name like '%Contact%' Limit 1];
        Contact ctct = new Contact(
            AccountId=a.Id,
            LastName='Smith',
            RecordTypeId=crt.Id,
        	CurrencyIsoCode='GBP',
        	Phone='1');
        insert ctct;

		RecordType ort = [select id,Name from RecordType where SobjectType='Opportunity' and Name like '%Project%' Limit 1];
        Opportunity opp = new Opportunity(
            Name='Mike',
            AccountId=a.Id,
            RecordTypeId=ort.Id,
        	Type='New Business',
            LeadSource='Other',
            StageName='Present Quote',
            CloseDate=Date.valueOf('2015-12-31'),
        	CurrencyIsoCode='GBP',
        	Division__c='Water');
        insert opp;

        Quote q = new Quote(
        Name='Mike',
        OpportunityId=opp.Id,
        Type__c='Project',
        Account_Manager__c='Mark Viner',
        Contact=ctct,
        Sage_Company__c='Water Sage');
        insert q;

         Consumable__c consum = new Consumable__c (
            Name='A Consumable',
            Active__c=TRUE,
            Price__c=1,
            Product_Code__c='A Code',
            Product_Description__c='A Description');
        insert consum;

        Work_Item__c w = new Work_Item__c (
            Name='A Work Item',
            Sample_Consumable__c=consum.Id);
        insert w;

        Quoted_Work__c QW = new Quoted_Work__c (
            Account__c = a.Id,
            Quote__c= q.Id,
            WorkItem__c = w.Id,
            Assigned_Role__c = 'Technician',
            Duration_hrs__c = 1,
            Quantity__c = 1,
            Frequency__c = 'Annually');
        insert QW;

        Covered_Consumable_2__c CC2 = new Covered_Consumable_2__c (
            Site__c = a.Id,
            Quote__c= q.Id,
            Consumable__c = consum.Id,
            Quantity__c = 1);
        insert CC2;

// Set current page so that controller picks up Quote Id:

        PageReference pageRef = new PageReference('/apex/worksSummary?Id='+q.Id);

        Test.setCurrentPage(pageRef);

// Instantiate a new SummariseQuotedWorks object:

        Test.startTest();
	        SummariseQuotedWorks controller = new SummariseQuotedWorks(new ApexPages.StandardController(q));

            List<WISum> ResultList = new List<WISUm>();
            ResultList = SummariseQuotedWorks.getWISumOut();
	        system.assertEquals(controller.WISumList[0].TotalCost.abs(),45);
        Test.stopTest();

	}
public class WISum{
        public String Acct {get; set;}
        public String WorkItem {get; set;}
        public Decimal TotalCost {get; set;}
    }

}

Thanks,
Mike.

 
I have an odd event happening.  I am doing a simple SELECT in an event, but the whoId is not correct.  I have a method that determines the element type (lead, account, opportunity, etc) and I see the whoid in there for the lead.  I immediately do a select (below) but the select fails because the whoid shows an event instead of the lead I'm working with.  I can't see why this should be.
 
List<Lead> leadList = [select Id, Name, PostalCode, Street, State, City, Latitude, Longitude
from Lead where Id = :whoId];
I can run the EXACT same query and get a response.  I can see the whoid and it shows the correct ID for the lead.  In the code, it fails:
11:17:25.0 (111774981)|EXCEPTION_THROWN|[126]|System.QueryException:
Event WHERE id = '00U15-------'

Above this, the whoid shows it to be a lead (00Q150-----).

What could I be doing wrong??
 
Hi

I was expecting to find this information easily but I've not found anything.

In my controller I run a SOQL statement with 'group by rollup' and I then display the records in a visualforce table.

Each time that a subtotal is displayed, I want to either indent or right justify the word 'Subtotal' and do the same for the grand total.  I can't find anything that explains how to apply this formatting in the controller.

Any help would be greatly appreciated.

Here's the controller:
 
public class SummariseQuotedWorks {
    private final Quote qte;
    
    public SummariseQuotedWorks(ApexPages.StandardController controller) {
        this.qte = (Quote)controller.getRecord();
        }
    
/* Use a wrapper class to store the aggregate values in a way that is accessible to Visualforce */

public class WISum{
        public String Acct {get; set;}
        public String WorkItem {get; set;}
        public Decimal TotalCost {get; set;}
        public WISum(string a,string w,decimal c){
                this.Acct=a;
                this.WorkItem=w;
                this.TotalCost=c;
        }
}

public List<WISum> WISumList = new List<WISum>();

public List<WISum> getWISumOut(){

		String theAcct = '';

        AggregateResult[] AgR = [SELECT Account__r.Name AC, WorkItem__r.Name WI, sum(cost1__c) TC FROM Quoted_Work__c
where Quote__c=:qte.Id
group by rollup(Account__r.Name, WorkItem__r.Name)]; 

        for (AggregateResult WIRecs : AgR) {


       
 /*      WISumList.add(new WISum((String) WIRecs.get('AC'), (String) WIRecs.get('WI'), (Decimal) WIRecs.get('TC'))); */
 	        WISumList.add(new WISum((String) ((WIRecs.get('AC') == theAcct) ? '' : WIRecs.get('AC')), (String) (WIRecs.get('WI') == null ? 'Subtotal' : WIRecs.get('WI')), (Decimal) WIRecs.get('TC')));
 
        	theAcct = (String)WIRecs.get('AC');
 
        }
        return WISumList;
}
    
}

Here's the VF:
 
<apex:page standardController="Quote" extensions="SummariseQuotedWorks">
	<apex:pageBlock title="Summary of Works for Quote: {!Quote.Name}">
		<apex:pageBlockSection >
			<apex:pageBlockTable value="{!WISumOut}" var="WISummary">
				<apex:column value="{!WISummary.Acct}">
					<apex:facet name="header">Site</apex:facet>
				</apex:column>
				<apex:column value="{!WISummary.WorkItem}">
					<apex:facet name="header">Work Item</apex:facet>
				</apex:column>
				<apex:column value="{!WISummary.TotalCost}">
					<apex:facet name="header">Total Cost</apex:facet>
				</apex:column>
			</apex:pageBlockTable>
		</apex:pageBlockSection>
	</apex:pageBlock>
</apex:page>

Here's the ouput:

User-added image

Wherever 'Subtotal' appears, I want it indented or right justified.

I've not modifed the controller yet to display 'Grand Total' in the last line but will do and will want that formatted too.

Many Thanks,
Mike.

 
I don't recall receiving an email alert for the certification maintenance exams for Winter '16 on either Admin or Dev certs.  Googling for the training resources only revealed that others had noted the same.

To save others the time of hunting for the training material, it's here:
Winter ‘16 Developer Release Exam (http://certification.force.com/pkb/articles/Public_KB/Winter-16-Developer-Release-Exam/?q=winter+16&l=en_US&fs=RelatedArticle)
Winter ‘16 Administrator Release Exam (http://certification.force.com/pkb/articles/Public_KB/Winter-16-Administrator-Release-Exam/?q=winter+16&l=en_US&fs=RelatedArticle)

The modules are listed here:
Winter '16 Release Training for Certified Professionals (https://help.salesforce.com/HTTrainingModulesDetail?courseId=a1S300000032xGB)
(same for admin and dev)
Hi,

I have written the below classes as part of the trailhead challenge for Apex REST callouts.

The class -

public class AnimalLocator {
  
  public static String getAnimalNameById(Integer id) {
    
    Http http = new Http();
    HttpRequest request = new HttpRequest();
    request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+id);
    request.setMethod('GET');
    
    HttpResponse response = http.send(request);
    List<Object> animals; 
    String returnValue; 
    
    // parse the JSON response
    if (response.getStatusCode() == 200) {
      Map<String, Object> result = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
      animals = (List<Object>) result.get('animals');
      System.debug(animals);
    }
    
    if (animals.size() > 0 && animals != NULL && id < animals.size()) {
      returnValue = (String) animals.get(id);
    }
    
    return returnValue;
  } 
    
}

Mock Response Class - 

@isTest
global class AnimalLocatorMock implements HttpCalloutMock {
     // Implement this interface method
    global HTTPResponse respond(HTTPRequest request) {
        // Create a fake response
        HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
        response.setBody('{"animals": ["majestic badger", "fluffy bunny", "scary bear", "chicken", "mighty moose"]}');
        response.setStatusCode(200);
        return response; 
    }
}

Test Class - 

@isTest
private class AnimalLocatorTest{
    @isTest static void AnimalLocatorMock1() {
        Test.setMock(HttpCalloutMock.class, new AnimalLocatorMock());
        string result = AnimalLocator.getAnimalNameById(3);
        String expectedResult = 'chicken';
        System.assertEquals(result,expectedResult );
    }
}

I have got 100% code coverage for the main class. But when I check the challenge I get 

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.NullPointerException: Attempt to de-reference a null object

Please tell me if any changes to the code is required. It's really frustrating as I am stuck from past 3-4 days with this unit.

Thanks & Regards,

Abhiram Sheshadri
i have test class for vf controller where as soql which is not not covering in code coverage even after inserting one test opp record.Please suggest me that how to get cover this soql.Here oppId is currentpage parameter.
In debug logs opppDeatils list value is coming as 0 but test opp record is inserted in test class.

List<Opportunity> oppDetails =[Select Name
From Opportunity
Where Id =:ApexPages.currentPage().getParameters().get('oppID')];
Hi

I have an apex trigger on contact which will trigger an email when an email field has been changed and picklist values is either No or Null

The following is the Apex trigger code 

Trigger:
trigger Contact_OnBusinessEmailChange_Trigger on Contact (after update) {
      
        List<String> mailList = new List<String>();
  List<String> mailAddresses = new List<String>(); 
  Group g = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE name = 'TCSTestGroup'];
  for (GroupMember gm : g.groupMembers) 
  {
   mailList.add(gm.userOrGroupId);
  }
  User[] usr = [SELECT email FROM user WHERE id IN :mailList];
  for(User u : usr) 
  {
  mailAddresses.add(u.email);
  } 
        string messagebody;
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
        for (Contact c : trigger.new) { 
            Contact old = trigger.oldMap.get(c.Id); 
            if ((old.Email != c.Email) && ((c.Opt_in_to_Tracking__c== 'No') ||(c.Opt_in_to_Tracking__c== null))) {  
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                email.setToAddresses(mailAddresses);
                email.setReplyTo('noreply@salesforce.com');
                email.setSenderDisplayName('IT Salesforce Support');
                email.setSubject('Notification: Email Address Change');
                messagebody='<html><body>The Business Email for the contact "' +c.FirstName + ' ' + c.LastName + '" has been updated from ' + old.Email + ' to ' + c.Email +' by '+c.Updated_By__c + '.<br/><br/>The Contact\'s further details below:<br/><br/>Contact\'s First Name:'+c.FirstName+'<br/>Contact\'s Last Name:'+c.LastName+'<br/>Contact\'s ID:'+c.Id+'';
                email.setHtmlBody(messagebody);
                emails.add(email);
            }
        }
        Messaging.sendEmail(emails);
    }

And the below is the Apex Test Class

@isTest
private class ContactOnBusinessEmailChangeTestClass{
private static testMethod void mailchangecheckvalid(){
//for new contact valid test
   Account grpAccnt = new Account(name='UpdateAccSSTest_grp1_11Dec_2015',account_type__c='Group',Source_System_ID__c='test5923');
        insert grpAccnt;
        
        Account accnt1 = new Account(name='UpdateAccSSTest_accnt1_11Dec_2015',account_type__c='Account',Source_System_ID__c='test594',
                parentId=grpAccnt.Id);
        insert accnt1;
        Account acc1 = new Account(Name='UpdateAccSSTest_accLoc1_11Dec_2015',Account_Type__c ='Account Location',
                Active__c = true,Source_System_ID__c='test',parentId=accnt1.Id);
        insert acc1;
        Contact con1 = new Contact(FirstName='UpdateAccSSTest_con1_11Dec_2015',LastName='Test contact1',accountid=acc1.id,
                Business_Unit__c='GCF',Email='mytestmail@genre.com');
        insert con1;
  
con1.Email='mytestmail2@genre.com';
try{update con1; }catch(DmlException e){System.Debug('Failure happened');}


System.assertEquals('mytestmail2@genre.com',con1.Email);
}

private static testMethod void mailchangecheckinvalid(){
//for new contact invalid test
   Account grpAccnt = new Account(name='UpdateAccSSTest_grp2_11Dec_2015',account_type__c='Group',Source_System_ID__c='test5927');
        insert grpAccnt;
        
        Account accnt1 = new Account(name='UpdateAccSSTest_accnt2_11Dec_2015',account_type__c='Account',Source_System_ID__c='test5947',
                parentId=grpAccnt.Id);
        insert accnt1;
        Account acc1 = new Account(Name='UpdateAccSSTest_accLoc2_11Dec_2015',Account_Type__c ='Account Location',
                Active__c = true,Source_System_ID__c='test',parentId=accnt1.Id);
        insert acc1;
        Contact con1 = new Contact(FirstName='UpdateAccSSTest_con1_17Mar_2011',LastName='Test contact2',accountid=acc1.id,
                Business_Unit__c='GCF',Email='mytestmail3@genre.com');
        insert con1;

       
con1.Email='mytestmail4@genre.com';

try{update con1; }catch(DmlException e){System.Debug('Failure happened');}

System.assertnotEquals('mytestmail3@genre.com',con1.Email);
}

}

Could you please tell me how to increase the code coverage to deploy this trigger
Hello,

I am working to build a trigger that updates an Opportunity when a Task is added to the opportunity. The trigger is successful in the Sandbox, however my Apex Class to test the trigger is presenting 0% code coverage. I am new to Apex and more of a "Desktop Admin" so any help would be appreciated.

The Trigger:
trigger OptyUpdateonTaskInsert on Task (after insert, after update)
{
    List<Opportunity> lstOpty = new List<Opportunity>();
    for(Task T : Trigger.New)
    {
        if(T.WhatId != null && string.valueof(T.WhatId).startsWith('006'))
        {
            Opportunity opt = new Opportunity(id=T.WhatId);
            lstOpty.add(opt);
        }
    }
    
    update lstOpty;
}

The Class:
 
@isTest(seealldata=true)
public class testTask{
    private static testmethod void testTaskActivity(){
        
        Opportunity o = new Opportunity(
        				AccountId 	= 	'0015500000AByHM',
            			Name 		=	'Test 2',
            			StageName	=	'Proposal Review',
            			CloseDate	=	(System.now()).date(),
            			Type		=	'New System');
        insert o;
                   
        Task t = new Task(
            			WhatId 		= 	o.Id, 
                        Subject 	= 	'Sample Email', 
                        Priority 	= 	'Normal', 
                        Status 		= 	'Completed',
            			OwnerId 	=	UserInfo.getUserId());
        insert t;

    }
}

 
I and some other colleagues received this notification via email to all our System Administrators:

"You have one or more certificates in your Salesforce org California College Guidance Initiative [org ID here] that will expire soon. Please review the list below and visit Certificate and Key Management from Setup to make an update.
 
   - SelfSignedCert_20Nov2013_203932, Self-Signed, expires on 11/20/2015. Warning: This certificate will expire in 30 day(s)"

Does anyone have any tips as to how I can check if letting this expire impacts us or not? Has anyone else seen this?

Hi, since yesterday i i'm trying to save an apex class but nothing happens. 

It says "success" but the changes has not impact the test enviroment.

Right now when press save it is saving for a long time.

Tanks!

Hi ,

 

I have a requirement where we need to show a lookup field with a filter criteria to show Accounts in a vf page on lead Object.The field does not exist in lead object.Can anyone please suggest me how to create a filtered lookup field on VF Page.

 

 

Any help would be highly appreciated

 

Thanks in Advance

 

Hi,

 

I have my accounts related on a way that one parent Account is pointed by its daughters with the field ParentId.

 

I need to do a trigger that when the parent account is modified in the field Recovery_actions__C(is a checkfield), this change has to go to the daughters accounts.

 

This is my trigger:

 

trigger UpdateCierrePorRecobro on Account (beforeupdate) {

 

Set<Id> addAccountsActivate = newSet<Id>();

Set<Id> addAccountsDeactivate = newSet<Id>();

 

//Aislo los id's

 

for(integer i=0;i<Trigger.new.size();i++){

//If the value has changed add to the list

if ((Trigger.new[i].Recovery_Actions__c!=Trigger.old[i].Recovery_Actions__c)) { 

if (trigger.new[i].recovery_actions__c){//changed to true

addAccountsActivate.add(Trigger.new[i].id);

}

else{//changed to false

addAccountsDeactivate.add(Trigger.new[i].id);

}

}

}

if(addAccountsActivate.size()>0){

 

//create a list of ids with the daughter ids of the main account

//????????????????????????????????????????

List<id> listaToTrue=newList<id>();

listaParaActivar.add([select id fromAccountwhereParentId in:addAccountsActivate]);

//????????????????????????????????????????????

 

Accountacc;

 

//and update the value

for(integer j=0;j<listaToTrue.size();j++){

acc.id=listaParaActivar[j];

acc.Reacovery_Actions__c=1;

updateacc;

}

}

 

}

 

 

---------------------------------------

 

I have the problem in the part where I query in order to get the ids of the daughter accounts, I dont know how to get that list of ids.

 

Anyone could help here?

 

Thanks,

Antonio

Hi Guys,

A rather basic question, but here goes!....

My company are currently using Data Loader for a proof of concept project currently underway, with a small user base of approx 20 users.

Should the project move into 'phase 2', we'll be increasing the users to approx 50-200.

Am I right in thinking Data Loader has limitations in the amount of data it can process or that performance would be greatly reduced by the amount of users we plan on adding to the sfdcom app we use?

Many thanks

 

  • April 01, 2011
  • Like
  • 0