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

  • Chatter
    Feed
  • 0
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 10
    Replies
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 have a join table that connects two accounts.  One of it's fields is the distance between the accounts.  Using the location class, I can easily determine how far apart the billing addresses are for both accounts when created or editing the join record.

However, if one of the accounts moves to a new address, I can’t capture the event to update the distance since I can’t seem to identify when the re-geocoding is complete.

Currently, my trigger is as below..
if(trigger.isAfter && trigger.isUpdate){
  set<id> needsUpdate = new set<id>();
  for (account is : trigger.new){
   account was = trigger.oldMap.get(is.id);
   if( is.billinglatitude != was.billinglatitude || is.billinglongitude != was.billinglongitude)   needsUpdate.add(is.id);
  }
  // call to update the distance
}

This isn't catching the event so needsUpdate is always blank.

Also, the Data Integration rule is NOT set to bypass triggers (see below).

Has anyone figured a way around this problem?

Thanks a ton for your help...

Steve 

User-added image
No matter the command I enter in the force.com CLI on Win10, I always get an error saying "unexpected end of json input", even when just interrogating the version.

Has anyone else come across/resolved this problem?

User-added image
I have a button on the account page that calls a js window.open() when clicked.  

I also have a field on account called Status.  

The button can be pushed any time.  However it must be clicked when Status is set to 47.

Since the users are forgetful i want to automatically call the window.open() for them whenever status=47.

How do I do this - by any realistic means (apex, wfr, flow, pb....) 

Thanks,

Steve 
 
While MavensMate is riding off into the sunset, it's going to remain relevant for a bit.  That said, what's The Thing to use moving forward to connect VS Code, Atom, or Sublime to the Salesforce backend?

Thanks,

Steve 
When a user clicks on a quick action, say in the lightning console, the action expands to show its layout.

Other than doing a page refresh - is there a way to make it to collapse back to its original state, using less screen space; espically if the user chose not to complete the action?

Thanks,
I have a method that includes conversion of a lead.  The database.convertlead() call is wrapped in a try/catch.
try {
	Database.LeadConvertResult lcr = Database.convertLead(lc);
} catch (exception e) {
    lpTools.logError('Client_Hub_Attachment_Tools.convertPortalProspects', e);
}

How do I force an error in my test code so I can exercise the catch part?

Thanks,

Steve 

 
This is driving me nuts...

My trigger has 42% coverage in my sandbox but it won't deploy saying that the coverage is 0% (code below).  The test method both inserts and updates an opportunity. I'm lost as to why the trigger never fires.

Things I've tried so far...
  • I tried a creating new trigger and deactivating the old one. 
  • The trigger's system version was 18 - I updated it to 40.
  • I tried implementing the changes in a brand new sandbox.
  • I've given it a rest and waited 12 hours (read that trying again gets it working)
All to no avail

Please help save my sanity -- I don't understand why I'm getting 0% coverage of the trigger.

Thanks,

Here's my test code....
@isTest
private class paymentManager_test {

    @isTest static void test_addingPayments() {
        id acctRT = lpTools.getRecordTypeID('Account', 'Business');
        id oppRT = lpTools.getRecordTypeID('Opportunity', 'Donation');
        account a = new account(name = 'test', recordtypeid=acctRT);
        insert a;
        opportunity o = new opportunity(name='blah', accountid=a.id, closedate=date.today(), stagename='Pledged', amount=47, recordtypeid = oppRT);
        insert o;
        o.stagename = 'Posted';
        update o;
    }
}

Here's the trigger...
trigger opportunityTrigger on Opportunity (before insert, before update, before delete, after insert, after update, after delete, after undelete) {

    // Add payments to newly closed opps
    if (trigger.isAfter){
        list<Opportunity> inNeed = new list<Opportunity>();
        if (trigger.isInsert) {
            for (Opportunity is : trigger.new) { 
                if (is.stagename == 'Posted' && is.amount > 0) inNeed.add(is);
            }
        }
        else if (trigger.isUpdate){
            for (Opportunity is : trigger.new) {
                Opportunity was = trigger.oldmap.get(is.id);
                if (is.stagename == 'Posted' && is.amount > 0 && is.Num_Payments__c == 0 && (was.stagename != 'Posted' || was.amount == null || was.amount == 0)) inNeed.add(is);
            }
        }
        paymentManager.addPayments(inNeed);
    }
}


 
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 have lightning action button that calls a server-side process - JS controller code below.

My problem is that the callback only fires if the apex method performs no DML calls.  Otherwise, it never fires.
 
buttonClick : function(component, event, helper) {
    var action = component.get("c.apexCall");
    action.setParams({"contactID": component.get("v.recordId")});
    
    action.setCallback(this, function(response){
        console.log('in callback...');
    });
    $A.enqueueAction(action);
}

I'm new to Lightning - please help me understand how to get around issue?

Thanks,

Steve 
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.  
I'm generating a pdf letter in a vf page and am tripping on a very simple thing...

If the field giftAmount, which is passed in from apex as say $2,500.00 is over 1000, I want to sign the lettter Sonja, otherwise I'd like to sign it Karen.

How do I do this in VF?

Current Code - gives generic "Syntax Error" message
{!IF( Value({!giftAmount}) >= 1000, "Sonja", "Karen")}

Thanks for the help...

Steve 
<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 
Hello,

I'm looking to add some of the new apex:map functionality to one of the orgs I manage.  While it's pretty fantastic how they've made it so easy, there's also some basic things I've noticed lacking.  Specifically...

1. Controlling the color of the map markers.  This is key if you want to show more than one type of thing on the map.

2. Showing a window of data about whatever's at each marker.

3. Capturing marker-related events.  For example, I'd like to capture mouseup, so users can choose a location off the map.

Has anyone approached these challenges yet?  If so, how have you solved them?

Thanks a lot,

Steve
Oakland
I know this is an often re-tread thread but I'm going kinda bananas on something that should be a no-brainer...

I'm studying for the 401 exam by going through the slide-videos of Salesforce's "Building Applications with Force.com" parts 1 & 2. 

As I try to do the exercises, I'm finding there's a bunch of stuff - objects, profiles, etc., that aren't in my developer org and referred to but not described in the materials - as if they should already be present. I have this strong feeling there's a course setup that I'm missing. 

Have others found this? Have you found a setup that sets the context for the course?

While I could limp along or just skip the exercise, I'm afraid I'll miss valuable stuff...

Thanks for your help...

Steve
While MavensMate is riding off into the sunset, it's going to remain relevant for a bit.  That said, what's The Thing to use moving forward to connect VS Code, Atom, or Sublime to the Salesforce backend?

Thanks,

Steve 
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 
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 !!