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

  • Chatter
    Feed
  • 5
    Best Answers
  • 4
    Likes Received
  • 2
    Likes Given
  • 19
    Questions
  • 66
    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 ?
  • December 10, 2015
  • Like
  • 0
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?
When I try to run sfdx the same way I have for about 4 years, I get this error message:

'"C:\Users\Desja\AppData\Local\sfdx\client\bin\..\7.209.6-8ba3197\bin\sfdx.cmd"' is not recognized as an internal or external command, operable program or batch file.

>>> Why is it trying to run sfdx from that folder? It's not in that folder!

In this folder: C:\Users\Desja\AppData\Local\sfdx\client I have two sub-folders, "bin" and "7.209.6-8ba3197", the 2nd of which appears to have been created on 9/5/23 (just 2 days ago). The "bin" folder contains 2 files: sf.cmd and sfdx.cmd, while the "7.209.6-8ba3197" folder contains a "bin" folder, which contains a single file named "node.exe"

CLI has become a very valuable tool for me as I support 19 nearly identical orgs for the chapters of a national non-profit that works for the homeless. I have no idea why it has stopped working so mysteriously.

I have been through several existing messages on here that all seem to point to the PATH environment variable. The correct folder is present in my path, but the error message indicates it's trying to run sfdx from that other folder named 7.209.6-8ba3197\bin -- why?

Thank you for any clues to help resolve this.
I am trying to solve the Trailhead Platform Developer 1 (PD1) maintenance module I am facing the following error please help me to solve it. "The correct Safe Navigation logic was not found. Your Apex code should use the Safe Navigation operator to check for null values for Account Name. Please review line 18 of the original code and recheck your code for the Safe Navigation operator."..?
@RestResource(urlMapping='/apexSecurityRest')
global with sharing class ApexSecurityRest {
    @HttpGet
    global static Contact doGet() {
        Id recordId = RestContext.request.params.get('id');
        Contact result;
        if (recordId == null) {
           throw new FunctionalException('Id parameter is required');
        }
        if (Schema.SObjectType.Contact.isAccessible()
          && Schema.SObjectType.Contact.fields.Name.isAccessible()
          && Schema.SObjectType.Contact.fields.Top_Secret__c.isAccessible()
        ) {
          List<Contact> results = [SELECT id, Name, Title, Top_Secret__c, Account.Name FROM Contact WHERE Id = :recordId];
          if (!results.isEmpty()) {
             result = results[0];
             if (Schema.sObjectType.Contact.fields.Description.isUpdateable()){
                 result.Description = result.Account.Name;
                 }
             }
           } else {
             throw new SecurityException('You don\'t have access to all contact fields required to use this API');
           }
           return result;
      }
      public class FunctionalException extends Exception{}
      public class SecurityException extends Exception{}
}

 
I'm currently working on the Trailhead unit Set Up Jest Test Framework (https://trailhead.salesforce.com/content/learn/modules/test-lightning-web-components/set-up-jest-testing-framework?trail_id=build-lightning-web-components)

I am in the directory with my project and I'd like to install Jest into the project.

However, Sfdx seems unable to find npm even though it is clearly installed:
 
D:\tutorials\SFDC2020\Summer20>npm --version
6.14.5

D:\tutorials\SFDC2020\Summer20>sfdx force:lightning:lwc:test:setup
ERROR running force:lightning:lwc:test:setup:  npm command not found. Verify npm is properly installed and try again.

What is wrong and how can I fix it?


 

I'm trying to insert an account record if it's not a duplicate. I'm referencing the findDuplicates method documentation found here: link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Datacloud_FindDuplicates.htm#apex_Datacloud_FindDuplicates_methods

Account acct = new Account();
acct.Name = 'Acme';
acct.BillingStreet = '123 Fake St';
acct.BillingCity = 'Springfield';
acct.BillingState = 'VT';
acct.BillingCountry = 'US';
        
List<Account> acctList = new List<Account>();
acctList.add(acct); 

if (Datacloud.FindDuplicates.findDuplicates(acctList).size() ​== 0) {
// If the new account doesn't have duplicates, insert it.
    insert(acct);
}
Here is my code:
trigger clientImportTrigger on Client_Import__c (before insert) {
    List<Account> accountsToInsert = new List<Account>();
    Id personAccRecTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('PersonAccount').getRecordTypeId();
    
    for (Client_Import__c A : trigger.new){
//create personAccount
        List<Account> dupeTestPersonAcc = new List<Account>();
        string pAddress = (A.addressLine1__c + ', '+ A.addressLine2__c);
                
        Account newPersonAcc = new Account();
        	newPersonAcc.FirstName = A.firstName__c;
            newPersonAcc.LastName = A.lastName__c;
            newPersonAcc.PersonEmail= A.email__c;
            newPersonAcc.Phone = A.phone__c;
            newPersonAcc.Phone_Type__c = A.phoneType__c;
            newPersonAcc.PersonMailingStreet = pAddress;        	
            newPersonAcc.PersonMailingcity = A.City__c;
            newPersonAcc.PersonMailingState = A.State__c;
            newPersonAcc.PersonMailingPostalCode = A.Zip__c;
            newPersonAcc.PersonMailingCountry = A.Country__c;
            newPersonAcc.Language_Preference__c = A.Language__c;
        	newPersonAcc.RecordTypeId = personAccRecTypeId;
        	dupeTestPersonAcc.add(newPersonAcc); 
        	//accountsToInsert.add(newPersonAcc);
        
        //if the new person account doesn't have duplicates, put it in the list to be inserted later with the rest
        System.debug(Datacloud.FindDuplicates.findDuplicates(dupeTestPersonAcc).size());
        if (Datacloud.FindDuplicates.findDuplicates(dupeTestPersonAcc).size() == 0){
        	accountsToInsert.add(newPersonAcc);
        	
        }
    }
    insert(accountsToInsert);
}

​​​​​​The problem I'm having is the findDuplicates(sObject).size() is always equal to 1, instead of 0 when I run the test class that just inserts a single record. Bascially, I can't figure out how to create the "if statement" so that a record is inserted if no duplicate is found. Any help is appreciated.
Hi,

I've been learning Lightning Components on Trailhead. I'm currently doing the project for the Lightning Superbadge and have been running into the following error when I try to reload the page for the standalone app:
 
Unable to find action 'getBoatTypes' on the controller of c:BoatSearchForm
Failing descriptor: {c:BoatSearchForm}

I've googled around and have found a lot of examples of this error where people hadn't added the @AuraEnabled annotation to their server-side controller, so the client-side controller couldn't find the method.

But, I have added that annotation and am still getting the message. It's driving me up the wall. I haven't had this issue on any other controllers I've created, and I even have another method in the same server-side controller that is being referenced by the client with no issues.

Here's my client-side controller:
({
    handleInit: function(component, event, helper) {
        // Check environment can create record
        var canCreateRecord = $A.get('e.force:createRecord');
        component.set('v.canCreateRecord', !!canCreateRecord);
        
        // Get boat types to populate boat type dropdown
        var getBoatTypesAction = component.get('c.getBoatTypes');
        getBoatTypesAction.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS') {
                component.set('v.boatTypes', response.getReturnValue());
            } else {
                console.log('Failed with state:', state);
            }
        });
        $A.enqueueAction(getBoatTypesAction);
    },
    
	createNewBoat : function(component, boatType) {
        var boatType = component.get('v.boatType');
        
		var createAction = component.get('c.createBoat');
        createAction.setParams({
            "type": boatType
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === "SUCCESS") {
                console.log('SUCCESS');
            } else {
                console.log(state);
            }
        });
        $A.enqueueAction(createAction);
	}
})

and my server-side controller:
public class BoatSearchApexController {
    
    @AuraEnabled
    public static void createBoat(String type) {
        Boat__c boat = new Boat__c();
        if(type != null) {
            BoatType__c boatType = new BoatType__c(Name=type);
            insert boatType;
            boat.BoatType__c = boatType.Id;
        }
        insert boat;
    }
    
    @AuraEnabled
    public static List<BoatType__c> getBoatTypes() {
        return [Select Id, Name From BoatType__c];
    }
}

​​​​​​​

Hi all, I am so close to finishing this process automation badge but am stuck in one area in Step 7.

I've built out my process builder as follows

User-added image
User-added image
User-added image

And my date formula as follows
 

Case(MOD(Date__c-DATE(1900,1,7),7),0,"Sunday",1,"Monday",2,"Tuesday",3,"Wednesday",4,"Thursday",5, "Friday",6,"Saturday", "")
 



Challenge Not yet complete... here's what's wrong:  The Robot Setup Day of the Week formula does not seem to be working properly. The Day of the Week should not fall on Saturday or Sunday. 

It works nicely but doesn't seem to pass, what could be up.
 

Hi All,

While setting up the CLIQ, its giving me the error below, I don't know which path to set to make it working

User-added image

thanks in advance
Abhi

Hi,

I'm having a problem with .setParams, I've tried to put it in an app that is similar to the Account List explained in the trailhead(https://developer.salesforce.com/trailhead/en/project/slds-lightning-components-workshop/slds-lc-6). The objective is to pass, from an input field, two dates to the apex controller for filter the select of the objects and show them when the buttom "Cerca" is pressed. So I tried with the aura:attribute and the action.setParams to pass the values in the controller but I've always get the same error. I think that the problem is .setParams because when I remove it the app works fine.
The error is this:

Something has gone wrong. Error during init [TypeError: Cannot read property 'apply' of undefined] . Please try again.

This is the code:

App:
 

<aura:application >
    <ltng:require styles="/resource/SLDS/assets/styles/salesforce-lightning-design-system.css"  />
    <div class="slds" style="margin-top:10px;margin-left:10px;">
       <c:AccountList DataDa="2016-01-01"  DataA="2016-01-31"/>
    </div>
</aura:application>
 


Component:
 

aura:component controller="LightningConsoleTitoliController">
   <aura:attribute name="titoli" type="List" />
       <aura:attribute type="Date" name="DataA" access="global"/>
    <aura:attribute type="Date" name="DataDa" access="global"/>
   <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<table class="slds-table slds-table--bordered slds-table--striped">
      <thead>
        <tr>
           <--Other Code -->
<ui:inputDate aura:id='DataDa' label='Data Da' value='{!v.DataDa}' displayDatePicker="true" updateOn='click'/>
           <ui:inputDate aura:id='DataA' label='Data A' value='{!v.DataA}' displayDatePicker="true" updateOn='click'/> 
           <ui:inputText aura:id='Agente' label='Agente' value='{!v.Agente}'/>
            <ui:button press='{!c.doInit}' aura:id='bottone' label='Cerca' />
        </tr>
      </thead>

<-- Other code -->

Controller:
({
   doInit: function(component, event, helper) {      
      //Fetch the expense list from the Apex controller   
      helper.getAccountList(component);
   }
})

Helper:
({
   //Fetch the accounts from the Apex controller
  getAccountList: function(component) {
      var action = component.get("c.getTitoli");
      action.setParams({
          DataA : component.get("v.DataA")
          DataDa : component.get("v.DataDa")
})
<-- Callback code -->

Apex Controller:
public class LightningConsoleTitoliController {
    
    @AuraEnabled
    public static list<Titolo__c> getTitoli(Date DataDa, Date DataA){
        return [Select id, Data_Scadenza__c, CreatedDate, Importo_Provvigionale__c,DataA__c,DataDa__c,
                Data_Scadenza_Inizio__c, Data_Scadenza_Fine__c from Titolo__c where Data_SCadenza__c >= :DataDa and Data_Scadenza__c <= :DataA];
    }

}

 

I've been working with developing a stand-alone app in lightning. In trying to adhere to the look and feel I'm following the html layed out in https://www.lightningdesignsystem.com/components/tabs. Sorry if this is a newb question how do I manipulate the class of the <a> being clicked to .slds-active and it's corresponding <div> to .slds-show , and then remove any other existing <a> with the .slds-active and change the <div> to .sld.slds-hide?  I've seen something similiar with javascript on a visualforce page but I wanted to follow the component design structure. Surely someone has done this as it seems pretty standard navigation. Currently my component has

<div class="slds-tabs--default">
 <ul class="slds-tabs--default__nav" role="tablist">
   <li class="slds-tabs--default__item slds-text-heading--label slds-active" title="Item One" role="presentation">
   <a class="slds-tabs--default__link" href="#void" role="tab" tabindex="0" aria-selected="true" aria-controls="tab-default-1" data-data="tab-default-1__item"  onclick="{!c.selectTab}" id="tab-default-1__item">New Checklists</a>
        </li>
  <li class="slds-tabs--default__item slds-text-heading--label" title="Item Two" role="presentation">
            <a class="slds-tabs--default__link" href="#void" role="tab" tabindex="-1" aria-selected="false" aria-controls="tab-default-2" data-data="tab-default-2__item" onclick="{!c.selectTab}" id="tab-default-2__item">Existing Checklist</a>
        </li>
      </ul>
      <div id="tab-default-1" class="slds-tabs--default__content slds-show" role="tabpanel" aria-labelledby="tab-default-1__item">
        <h2>Item One Content</h2>
      </div>
      <div id="tab-default-2" class="slds-tabs--default__content slds-hide" role="tabpanel" aria-labelledby="tab-default-2__item">
        <h2>Item Two Content</h2>
      </div>

    </div>
I have the onClick="{!c.selectTab}" which goes to my js controller. Below
selectTab : function(component, event, helper){
    	var activeTab;
        activeTab = event.target.getAttribute("id");
        //var result = component.find("tab-default-1__item");
        //alert(result);
  
    },

I see the event.target.getAttribute gives me the value of the onclick id. I can get the value and can then tell which tab was clicked, but then how do I 

1. Change the class value of that Id?
2. Change the class value of other id's?

I've been trying to use various javascript  functions like find but nothing seems to be working. Can someone point me to which functions I should be using to find id(DOMS) on a component and which functions can be used to set vairous attributes?  I didn't find anything in the lightning dev guide but will keep looking. Any help is appreciated.
 

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 Team, 

 

How can we get the lat and long of a current address automatically by using apex code.

 

Do we have any standard methods to retrieve those valuse.

 

Thanks,

Anil

I have Account object, Policy custom object and Receipt custom object. The relationships between these are:

 

Account 1:N Policy

Policy 1:N Receipt

 

I have a formula field called 'Account' on Receipt which displays the Name field of the Account related to the Policy in question. Somehow the following formula field:

MyApp__Policy__r.MyApp__.Name

is only working for regular Accounts not Personal Accounts.

I could edit the formula to something like:

 

IF(MyApp__Policy__r.MyApp__Account__r.IsPersonAccount, 
 MyApp__Policy__r.MyApp__Account__r.LastName & ' ' &  MyApp__Policy__r.MyApp__Account__r.FirstName, 
MyApp__Policy__r.MyApp__Account__r.Name)

But it seems to be a lame solution. Anybody knows the reason why this formula doesn't work for Personal Accounts?

Hi

 

I wrote a visualforce page and what I thought was a cool chunk of javascript which, when executed, copies values in the page from some inputfields to others (without updating the record—user can still save or cancel). It works fine except in the case of two fields which are a controller/dependent picklist pair. Boiled right down, the problem code is here:

 

document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
document.getElementById(DestDepdPListID).value = document.getElementById(SourceDepdPListID).value;

 

The first line populates the controller picklist correctly but despite the second line the dependent picklist does not gain a value (most of the time). The reason seems to be that after I set the Controller picklist value (eg Tea) the dependent picklist does not show the possible values (eg English Breakfast, Earl Grey, Oolong, etc) and even when the code attempts to set it to one of these allowed values the field remains blank.

 

Note, I have tried manually setting the Controller Picklist to the desired value first (ie Tea) and then the dependent displays the possible values. If I run the script afterwards, it works fine. I assume I need something like this:

 

document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
document.getElementById(SourceContPListID).systemMethodWhichKicksTheStandardControllerIntoActionToUpdateElementsOnPage;
...

 Or may be not. 

 

BTW, I am using "pure" javascript. Haven't venture into using the AJAX Toolkit yet but willing to try if it is the solution here.

 

Thanks for any help.

 

Regards

MellowRen

 

Hi,

I am accessing custom setting values in my apex code and its working fine. When I am calling it through test class then No values gets in from Custom Setting. It always blank in test class. Can somebody help me to understand why custom settings values are not accessible in test class.

 

Thanks,

Vinod Kumar

I'm trying to use ISPICKVAL to conditionally render part of my visualforce page. I want to show a pageBlockSectionItem if the value of Asset_Type__c is "Publications". Here is my code:

 

<apex:inputField required="true" value="{!Digital_Asset__c.Asset_Type__c}" />
<apex:pageBlockSectionItem rendered="{!ISPICKVAL(Asset_Type__c, 'Publications')}"><apex:inputField required="true" value="{!Digital_Asset__c.Publication_Title__c}" /></apex:pageBlockSectionItem>

 

 

The error I'm getting is:

Error: Unknown property 'Digital_Asset__cStandardController.Asset_Type__c' 

 

I've also tried using {!ISPICKVAL(Digital_Asset__c.Asset_Type__c, 'Publications')} in the rendered block, but then I get: Error: Incorrect parameter for function 'ISPICKVAL()'. Expected Picklist, received Text.

 

What am I missing here?

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,

 

   I am working on one workflow which sends out some notfication email to user depending on some data from opportunity.

 

   One of the triggering rule is ...the Opportunity Amount > 15000 USD.

   Since the currency in the opportunity varies, it could be USD or maybe not.

   How can i conver the Opportunity Amount in other currency into USD by using formula?...

 

 

Hi - I have created a flow which is meant to loop through all child records and update a couple of fields. The flow is getting the records correctly, assigning the new field values but on the last record that is updated it isnt adding it to the collection to be updated. Super weird and Ive pasted some of the code below as well as relevant screenshots.
From what I can see in this example:
1. All 5 child records are obtained without a problem
2. The loop goes through each of the records
3. The final record gets new values assigned but it doesnt get included on the update records which happens after the last record (in this case this is the record ending with XUAQ)

any help greatly appreciated

Final part of the flow and the record in question
User-added image
User-added image

2nd image shows only 4 records getting updated
User-added image
 
I'm currently working on the Trailhead unit Set Up Jest Test Framework (https://trailhead.salesforce.com/content/learn/modules/test-lightning-web-components/set-up-jest-testing-framework?trail_id=build-lightning-web-components)

I am in the directory with my project and I'd like to install Jest into the project.

However, Sfdx seems unable to find npm even though it is clearly installed:
 
D:\tutorials\SFDC2020\Summer20>npm --version
6.14.5

D:\tutorials\SFDC2020\Summer20>sfdx force:lightning:lwc:test:setup
ERROR running force:lightning:lwc:test:setup:  npm command not found. Verify npm is properly installed and try again.

What is wrong and how can I fix it?