• Steve Berley
  • NEWBIE
  • 65 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 17
    Replies
I have an Enterprise Edition org that's now allowing API access.  When I try to create an API connection I keep getting the error message:

"Invalid username, password, security token; or user locked out."

- I successfully logged in using the username/password moments ago.
- The security token was created today
- The login uses the "factory" system administrator profile
- The API works with dozens of other enterprise edition orgs, including many verified working properly today.

I'm at a loss as to why this org won't permit API access.  Do you all have any thoughts as to why it's failing?

Thanks,
 
Hi everyone,

I've got some code that's amazingly simple but is throwing the craziest error when I try to deploy. 
  • The code has 100% coverage in the sandbox with no errors
  • Even when deploying from a brand new sandbox I get the error.
  • There are no batch calls in the code
I'm at a loss becuase the error is so unrelated to the code.  

Thanks for your help...

Steve 

The error is:
System.UnexpectedException: No more than one executeBatch can be called from within a test method. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation.

The code follows...
trigger TaskTrigger on Task (before insert, before update, before delete, after insert, after update, after delete, after undelete) {
 
    if (trigger.isAfter && trigger.isInsert) {
        TaskHandler.evaluateTasks(trigger.new);
    }
}
 
public with sharing class TaskHandler {
    // public TaskHandler() {  }
 
    public static void evaluateTasks(list<task> newTasks){
        set<string> didNums = new set<string>();
        set<id> leadIDs = new set<id>();
        for (task t : newTasks){
            if ( string.isNotBlank(t.Dialpad__PhoneNumber__c) ) {
                didNums.add( LeadSourceHandler.scrubber(t.Dialpad__PhoneNumber__c) );
            }
            if ( string.isNotBlank(t.WhoID) ) leadIDs.add(t.WhoID);
        }
        map<string, string> LeadSources = getLeadSources(didNums);
        set<id> LeadsInNeed = getLeadIDs(leadIDs);
       
        list<lead> leadsToUpdate = new list<lead>();
        list<Lead_Source__c> newLeadSources = new list<Lead_Source__c>();
        for (task t : newTasks){
            string didNum = LeadSourceHandler.scrubber(t.Dialpad__PhoneNumber__c);
 
            if ( LeadsInNeed.contains(t.WhoID) ){
                if ( LeadSources.containsKey( didNum ) ) {
                    leadsToUpdate.add( new Lead(id=t.WhoID, LeadSource = LeadSources.get( didNum ) ) );
                } else {
                    newLeadSources.add( new Lead_Source__c(name = t.Dialpad__PhoneNumber__c ) );
                }
            }
        }
 
        if( leadsToUpdate != null && leadsToUpdate.size() > 0 ) update leadsToUpdate;
        if( newLeadSources != null && newLeadSources.size() > 0 ) insert newLeadSources; // save new ones
    }
 
    public static set<id> getLeadIDs(set<id> leadIDs){
        map<id, lead> leadsInNeed = new map<id, lead>([select id from lead where LeadSource = null and id in :leadIDs]);
        return leadsInNeed.keySet();
    }
 
   
    public static map<string, string> getLeadSources(set<string> didNums){
        map<string, string> m = new map<string, string>();
        for (Lead_Source__c ls : [select name, lead_source__c from Lead_Source__c where name in :didNums and Lead_Source__c != null]){
            m.put(ls.name, ls.Lead_Source__c);
        }
        return m;
    }
}
 
@isTest
private class TaskHandler_test {
    // private TaskHandler_test() {  }
 
    @isTest static void AssignLeadSourcesPrimary_test(){
        insert new Lead_Source__c(name='1234', lead_source__c='source 1');
 
        lead l1 = new lead(lastname='lead 1', Language__c='English', Location__c='Los Angeles');
        lead l2 = new lead(lastname='lead 2', Language__c='English', Location__c='Los Angeles');
        insert new list<lead>{l1, l2};
 
        task t1 = new task(subject='task 1', whoID=l1.id, activitydate=date.today(), Dialpad__PhoneNumber__c='1234');
        task t2 = new task(subject='task 2', whoID=l2.id, activitydate=date.today(), Dialpad__PhoneNumber__c='47');
        insert new list<task>{t1, t2};
    }
 
}


 
Hi,

I have a new package and I want to give a discount to an early adopter.  I see the coupon code field in the checkout process but I can't figure out where to manage coupon codes in the partners site.

What am I missing?

Thanks,

Steve 
I'm trying to do a query such as below.  Granted the SOQL itself is silly but it gets the point across
 
SELECT id, name FROM Account
WHERE name = 'whatever' OR id IN ( SELECT accountID FROM contact WHERE lastname = 'something' )
No surprise that it yields the error:  
MALFORMED_QUERY: Semi join sub-selects are not allowed with the 'OR' operator

The challenge is, how do you accomplish this type of goal in batch apex?
The only idea I've come up with is to split the query into two parts
Query A: 
SELECT id FROM Account
WHERE id IN ( SELECT accountID FROM contact WHERE lastname = 'something' )
Query B:
SELECT id, name FROM Account WHERE name = 'whatever'
  1. Make the batch class stateful and in the init store the results of Query B to a map.
  2. Make Query A the one returned by the batch start() method.  
  3. In the execute() method, process the scope (from query A) and as all records from the map of query B as they're processed.
  4. In the finish() method process records that remain in the map of query B after all query A results handled in the batches.
While I think this would work, I'm hoping there's a better/more elegant solution.

How have you all solved this problem?

Thanks,
Hey everybody,

I sent my business plan to Salesforce at the beginning of november and it's still pending for approval, and we need that to ask for the security review.

I read it takes 3 days usually, do you have some feedback ?

Thanks
I have a parent-child query where I need to use a generic approach to evaluating the results. This works great, except when trying to access the records from the child query.

In the example below:
  • 1 and 2 work and yield the same result, as you’d expect
  • 3 works perfectly
  • 4 errors with: "Invalid field Contacts for Account"
Any suggestions of how to access the child query generically?

Thanks,
list<account> aa = [SELECT name, ( SELECT name FROM Contacts ) FROM Account];
for (account a : aa) {
    system.debug('-- 1: '+a.name);
    system.debug('-- 2: '+a.get('name'));
    system.debug('-- 3: '+a.contacts);
    system.debug('-- 4: '+a.get('Contacts'));  // errors out
}
Hi,

I have a client who has a batch process that generates a lot of data, and because of this it takes a bit to run.

Since the process needs to be manually triggered, is it possible to prevent someone from starting it if another user already has it running?

Could I query active jobs and throw a message if it's in queue?

Thanks,

Steve 
I’m having a problem with setOrgWideEmailAddressId() when sending a single email — anyone else running into troubles?

Even though the OWE email address is verified and I’m using the id retrieved from querying the owe object — it ALWAYS gives an “Invalid Id” error.

What am I doing wrong?
Hi -

I have a VF page that generates what we call Route Sheets.  Each one takes 1-2 pages and the whole printout is about 55 pages long.  Each Route starts on a new page.  This is all fine.

The challenge is -- I'd like to include the route name on every page so was thinking of placing it in the page footer.  To accomplish this I'd need to change the footer with each iteration through the loop.

Can that be done?  If not, do you have other suggestions?

Thanks,

Steve

 
<apex:page controller="GenerateRouteSheets" deferLastCommandUntilReady="true" renderAs="PDF" applyBodyTag="false" action="{!loadData}">
	<!-- <apex:page controller="GenerateRouteSheets" deferLastCommandUntilReady="true" renderAs="PDF" applyBodyTag="false" > -->
	<head>
		<style>
			@page{
			size: landscape;
			@bottom-right {
			font-family: 'Arial Unicode MS';
			font-size: 13px;
			content:  "Page " counter(page) " of " counter(pages);
			}
			} 
		</style>
	</head>
	<script>
	    var dt = new Date();
	    document.getElementById("datetime").innerHTML = dt.toLocaleString();
	</script>
	<body>
		<apex:pageBlock >
			<apex:repeat value="{!routes}" var="r">
				<div style="page-break-after:always;  ">
                    Route {!r}
                    ~~ SNIP ~~
                </div>
			</apex:repeat>
		</apex:pageBlock>
	</body>
</apex:page>

 
I've been using VS Code for a while now doing work in a number of orgs but today I've started getting errors when trying to create new projects.
 
17:08:30.275 sfdx force:project:create --projectname Eden-tncDev --outputdir /Users/Steve/Dev/sfdx --template standard
ERROR running force:project:create:  Command failed with ENOENT: npm root -g --prefix /Users/Steve/Dev/sfdx/.yo-repository --loglevel error
spawnSync npm ENOENT
17:08:30.696 sfdx force:project:create --projectname Eden-tncDev --outputdir /Users/Steve/Dev/sfdx --template standard
 ended with exit code 1

I've already tried reinstalling the Salesforce extensions suite with no luck.  Any thoughts?

Thanks,

Steve 
I've got some code that's throwing errors that provide no information of value.  I wrapped it in a try/catch block to catch the exception at the source so I can isolate and correct it, but its now throwing CPU time outs.

So I've gotta ask - are try/catches super processor intensive? 

Also - tips for working around this would be greatly appreciated...

Thanks,
I'm creating a custom quick action for the lightning ui that requires no user input - just click the button and it starts.

Is it possible to prevent the Quick Action dialog from showing?  

While not as good a solution, I'd like to make it vanish immediately, but I can't make it happen.

Component:
<aura:component implements="force:lightningQuickActionWithoutHeader">
    <aura:handler name="init" value="{!this}" action="{!c.dismissIt}" />
</aura:component>

JS Controller:
dismissIt : function(component, event, helper) {
        var wasDismissed = $A.get("e.force:closeQuickAction").fire(); 
    }
As you can see they're as simple as possible but it's just not working.

Any suggestions?  

Thanks,

Steve 
 
I have a method that loops through one map and adds relevant information from a another map.  
for(id opp : opps.keySet()){
  id dg = opps.get(opp);
  if (templates.containsKey(dg) ) {
    list<npsp__Allocation__c> thisTemplate = templates.get(dg);
    for (npsp__Allocation__c t : thisTemplate) {
      t.npsp__Opportunity__c = opp;
      toInsert.add(t);
      system.debug('added: '+toInsert[toInsert.size()-1].npsp__Opportunity__c);  // << #1
    }
  }
}
 
system.debug('------------------ ');
for (npsp__Allocation__c a : toInsert ) system.debug(a.npsp__Opportunity__c);   // << #2

Looking at the output from the debug statements - the two ids are different, specificially one includes FF and the other includes FG.  However when interrogated again they're both FG.

User-added image

What's going on?  How do I fix this?  I have tried changing API version of the code - no luck.  
<rant>
Is it my imagination or has something changed so that developer docs stopped googling properly in the past month or so?

I often enter a google query such as:   sfdc apex map methods

For years one of the top results would be the page describing all methods you can do to a map.

Now, however, all you get is the developer documentation home page.  Which is useless in great part because the search within the developer documentation site is quite weak.

Ugh!
</rant>
Hi - 

I've got a circumstance where I need to pass the name of a class method to another method which would execute then passed method.

Example:
the class I'd want to call:
public class1 {
    public static void methodA() {
    };
}

The class I'd pass the method name to...
public class2 {
   public static void methodRunner(string methodName) {
      run( class1.methodName() );  // call that would execute the method (TBD)
   }
}

so the call would be - 
class2.methodRunner( class1.methodA );

In case you're wondering why go to all this work? 
I'd like to create a generic way to run class methods as batch processes from the console in prod to efficiently retrofit existing data - without littering the prod org with lots of one-time use code.

Looking forward to everyone's collective insights...

Thanks,

Steve 

Trapdoor is awesome but I do have some things that I wish I could control or fix.

 

1.) Duplicate URL.

I entered a URL into my list of servers as http://www.salesforce.com/login and then again as http://www.salesforce.com/login/

Trapdoor lists these as 2 distinct servers but if I delete one in order to correct it, Trapdoor deletes the other server in the list too.

I wish I could manually edit the list of servers and login details so that I could correct my typo.

 

2.) Sorting

I see that there is a "sort by alias" option but I don't see this working as expected.

If I had access to the list of servers ( see 1 above ) I would be happy to manually edit and order my servers.

 

Thanks !!

Hi guys,

 

today I received a strange error message after trying to change the controller in the visualforce editor

 

Error: java.sql.SQLException: ORA-00001: unique constraint (CORE.AKAPEX_CLASS) violated ORA-06512: at "HAPPY.CAPEX", line 505 ORA-06512: at line 1 : {call cApex.update_class(?,?,?,?,?,?,?,?,?,?,?,?)})} 

 

 

and remebered about a Blog article on Wes's Blog about strange error messages where I found this

 

  

Error: java.sql.SQLException: ORA-00001: unique constraint (CORE.AKAPEX_CLASS) violated ORA-06512: at “SNEEZY.CAPEX”, line 505 ORA-06512: at line 1 : {call cApex.update_class(?,?,?,?,?,?,?,?,?,?,?,?)})} 

.

 

 

Looks like some SF guys are huge fans 'Snow White and the Seven Dwarfs' .

 

 

So the big question is, where are the others and of course where's Snow White?