• Aiden Byrne
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 16
    Replies

Is there any programmatic way for an app to determine if it is deployed or not?

 

I can't find documentation that would suggest that this is possible, but I know from past experience that sometimes you can query system objects to determine capabilities,

 

thanks!

Aiden

Our app on App Exchange is fairly straightforward to install. When the install has finished, our documentation calls for admins to "deploy" the application. Many miss this step. 

 

We have triggers on some standard objects. If the admin doesn't do the deploy step, the following exception is often thrown from these triggers;

 

caused by: System.UnexpectedException: No such column 'WVWhichAccountAddress__c' on entity 'Wherevantage__WVAdministration__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.  In this instance, it is not visible to the user because the custom object has not yet been deployed

 

The error is fairly clear - the field is not visible as the custom object has not yet been deployed. Even if the app appears to be usable for folks granted access, we still want to make sure that the triggers above run OK, regardless of which user takes an action that results in trigger invocation.

 

I can't imagine that we are the first folks to hit this. Does anyone have recommendations around best practices for dealing with this case? At the moment, the exceptions above can lead to other processes failing. In this case, an admin will typically uninstall the app, not realizing that a "deploy" would have resolved the issues.

 

I could swallow the exceptions in the trigger, but this leads to another case that the app is never deployed and our triggers don't get an opportunity to do necessary cleanup in some cases. Any guidance is appreciated.

 

thanks!

Aiden

We use Visualforce binding to display results from different object queries based on user selection. An admin can dynamically define the query we run so Visualforce binding is perfect for this.

 

Our code has broke in Summer 11. We get errors whenever results for a different object are retrieved. The new field change does not appear to be respected by Visual Force.

 

I was able to write the following test code to illustrate. When you run you will see 10 accounts in your org. Now change the dropdown to contacts, and you see a binding error.  It looks like Visualforce isn’t refreshing the QueryViewDisplayFields as expected. As mentioned, this functionality worked before but is broken in the Summer release.  If you change the selected option to ‘Contacts’ in the constructor, you’ll see that the contacts display fine. Now if the user changes the options to accounts the binding breaks.

 

<apex:page controller="BindingTest">
<apex:form >

<apex:outputLabel dir="" value="Showing: " />
                &nbsp;&nbsp;&nbsp;
<apex:selectList multiselect="false" value="{!SelectedOption}" size="1">    
        <apex:selectOptions value="{!OptionsList}" id="recordOptions" />
        <apex:actionSupport event="onchange" status="counterStatus"
            oncomplete="ReadData();" rerender="none"  />                
</apex:selectList>

<apex:actionFunction name="ReadData"
    action="{!ReadData}" rerender="SearchResults" />

<apex:pageBlock id="SearchResults" >
     
        <apex:pageblocktable value="{!QueryViewRecords}" var="viewRow">

        <apex:repeat value="{!QueryViewDisplayFields}" var="myfield" id="innerset">
        <apex:column value="{!viewRow[myfield]}" />
        </apex:repeat>
                                        
        </apex:pageblocktable>                

</apex:pageBlock>

</apex:form>
</apex:page>

 

 

public with sharing class BindingTest
{
    public String SelectedOption {get; set;}

    public List<SelectOption> OptionsList {get; set;}
    public List<SObject> QueryViewRecords {get; set;}
    
    public List<String> QueryViewDisplayFields
    {
        get
        {
            List<String> returnResults = new List<String>();    
            
            if( SelectedOption == 'Accounts' )
            {            
                returnResults.add('name');
                returnResults.add('phone');
                returnResults.add('annualrevenue');
            }
            else
            {            
                returnResults.add('firstname');
                returnResults.add('lastname');
            }

            return returnResults;            
        }
    }
    
    public BindingTest()
    {
        OptionsList = new List<SelectOption>();
        OptionsList.add(new SelectOption('Accounts', 'Accounts'));
        OptionsList.add(new SelectOption('Contacts', 'Contacts'));
        
        SelectedOption = 'Contacts';
        ReadData();
    }

    public void ReadData()
    {
         if( SelectedOption == 'Accounts' )
         {
             QueryViewRecords = [select name, phone, annualrevenue from account limit 10];
         }
         else
         {
             QueryViewRecords = [select firstname, lastname from Contact limit 10];         
         }
    }
}

I'm used to getting a package not found error for five minutes or so after doing an upload. Today at 1:27pm, I'm still not seeing packages uploaded at 12:32pm. In a year developing on SF, this is the first time seeing such a long delay. Are other people experiencing? Any known issues with the uploader service?

 

 

Package Not Found
The requested package does not exist or has been deleted. Please contact the package publisher for assistance. If this is a recently uploaded package, please try again soon. 

 

thanks

Aiden

For selected fields I want to save the enum display type in custom settings. Its a long story but for performance reasons I don't want to requery the underyling schema for these fields every time.

 

A conservative approach to saving an enum would be to save it's string value. Unfortunately unlike Java, APEX doesn't appear to offer a enum.valueOf(s) type method letting me de-reference the string parameter.
I could save the ordinal. Happily, I can easily convert ordinal back to the enum via enum.values()[ordinalNumber]
The latter approach minimizes the custom settings field size and should be fast.
Here's the thing... is it safe? If Salesforce engineering inadvertantly changes the order of enum values I'm in trouble. That said, absent the ability to easily do this another way, I would hope that Saleforce engineering is careful to view the enum value order as part of the API contract - and not change the order from release to release. Is that a safe assumption? 

 

I'm passing back some field values via SOAP to a mobile client. 

 

I'd like to pass these back as formatted text to make life easier for the mobile developer. So, a currency field would be correctly formatted as currency, a number field with commas etc. 

 

In VisualForce, I can get great default formatting via the apex:outputfield. If I try to do the conversion to a string in APEX via string.valueOf, I get a pretty crude string (e.g. for numbers I get an exponential representation). 

 

Is there any way I can access the VisualForce like formatting used in Apex:OutputField from within APEX?

 

thanks!

Aiden

If I create custom settings with a text field, and add sample data, it looks like Salesforce calculates the record size based on the max potential size of the text field rather than the number of bytes used.

 

Is this correct? To give a SQL analogy, it looks like text fields are char rather than varchar. If you say you need X characters, you are allocated these whether or not you use them.

 

I'd like to understand this given that the custom sets have hard namespace and size limits.

 

thanks!

Aiden

When a user installs our app off App Exchange they need to religously follow a few steps. One is to grant themselves a license after the install. If they don't do this they don't see any tabs. 

 

We've had a few support calls where people have forgotten to do this, didn't see the step etc and think that the app didn't install correctly. Is there any way for us to say show a tab with final install steps that appears just after installation? Would an administrator be able to see such a tab if they haven't granted themselves a license yet?

 

thanks

Aiden

I know that a lead with the isConverted flag set to true cannot be updated, even by an administrator. 

 

Does anyone know if there are any other conditions where Leads, Accounts or Opportunities cannot be updated (apart from transient locks)?

 

 

I'm trying to write a test method where I can simulate record locking so I have validate my exception handling code.

 

Just to make sure that I can demonstrate record locking in a test, I wrote the following very simple test case that creates two users, has the first user lock a record, and has the second user try to update this while the record is still locked. I was expecting an exception, but the test actually succeeds. I would have thought that record locking is per user. Any suggestions?

 

 

   public static testMethod void TestRecordLocks() 
   { 
         Profile p = [SELECT Id FROM profile WHERE name='Standard User']; 
         User u1 = new User(alias = 'zaxxy1', email='zaxxy1@zaxxy1.com', 
            emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US', 
            localesidkey='en_US', profileid = p.Id, 
            timezonesidkey='America/Los_Angeles', username='zaxxy1@zaxxy1.com');
         User u2 = new User(alias = 'zaxxy2', email='zaxxy2@zaxxy2.com', 
            emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US', 
            localesidkey='en_US', profileid = p.Id, 
            timezonesidkey='America/Los_Angeles', username='zaxxy2@zaxxy2.com');
         //Lets create an account
         Account addAccount = new Account(name='ASFSDFDSAFXXX');
         insert addAccount;
    
         System.runAs(u2) 
         {
         }
         
         System.runAs(u1) 
         {
            Account user1Account = [select id, name from account where name='ASFSDFDSAFXXX' for update ];
        
            System.runAs(u2) 
            {
                Account user2Account = [select id, name from account where name='ASFSDFDSAFXXX' ];
                user2Account.Name = 'test';
//I'd expect that the following update to throw an exception due to the u1 lock, but it actually succeeds
                update user2Account;
           }
            
           user1Account.Name = 'anothertest';
           update user1Account;
        }
   }
  

 

We use Visualforce binding to display results from different object queries based on user selection. An admin can dynamically define the query we run so Visualforce binding is perfect for this.

 

Our code has broke in Summer 11. We get errors whenever results for a different object are retrieved. The new field change does not appear to be respected by Visual Force.

 

I was able to write the following test code to illustrate. When you run you will see 10 accounts in your org. Now change the dropdown to contacts, and you see a binding error.  It looks like Visualforce isn’t refreshing the QueryViewDisplayFields as expected. As mentioned, this functionality worked before but is broken in the Summer release.  If you change the selected option to ‘Contacts’ in the constructor, you’ll see that the contacts display fine. Now if the user changes the options to accounts the binding breaks.

 

<apex:page controller="BindingTest">
<apex:form >

<apex:outputLabel dir="" value="Showing: " />
                &nbsp;&nbsp;&nbsp;
<apex:selectList multiselect="false" value="{!SelectedOption}" size="1">    
        <apex:selectOptions value="{!OptionsList}" id="recordOptions" />
        <apex:actionSupport event="onchange" status="counterStatus"
            oncomplete="ReadData();" rerender="none"  />                
</apex:selectList>

<apex:actionFunction name="ReadData"
    action="{!ReadData}" rerender="SearchResults" />

<apex:pageBlock id="SearchResults" >
     
        <apex:pageblocktable value="{!QueryViewRecords}" var="viewRow">

        <apex:repeat value="{!QueryViewDisplayFields}" var="myfield" id="innerset">
        <apex:column value="{!viewRow[myfield]}" />
        </apex:repeat>
                                        
        </apex:pageblocktable>                

</apex:pageBlock>

</apex:form>
</apex:page>

 

 

public with sharing class BindingTest
{
    public String SelectedOption {get; set;}

    public List<SelectOption> OptionsList {get; set;}
    public List<SObject> QueryViewRecords {get; set;}
    
    public List<String> QueryViewDisplayFields
    {
        get
        {
            List<String> returnResults = new List<String>();    
            
            if( SelectedOption == 'Accounts' )
            {            
                returnResults.add('name');
                returnResults.add('phone');
                returnResults.add('annualrevenue');
            }
            else
            {            
                returnResults.add('firstname');
                returnResults.add('lastname');
            }

            return returnResults;            
        }
    }
    
    public BindingTest()
    {
        OptionsList = new List<SelectOption>();
        OptionsList.add(new SelectOption('Accounts', 'Accounts'));
        OptionsList.add(new SelectOption('Contacts', 'Contacts'));
        
        SelectedOption = 'Contacts';
        ReadData();
    }

    public void ReadData()
    {
         if( SelectedOption == 'Accounts' )
         {
             QueryViewRecords = [select name, phone, annualrevenue from account limit 10];
         }
         else
         {
             QueryViewRecords = [select firstname, lastname from Contact limit 10];         
         }
    }
}

I'm used to getting a package not found error for five minutes or so after doing an upload. Today at 1:27pm, I'm still not seeing packages uploaded at 12:32pm. In a year developing on SF, this is the first time seeing such a long delay. Are other people experiencing? Any known issues with the uploader service?

 

 

Package Not Found
The requested package does not exist or has been deleted. Please contact the package publisher for assistance. If this is a recently uploaded package, please try again soon. 

 

thanks

Aiden

I'm passing back some field values via SOAP to a mobile client. 

 

I'd like to pass these back as formatted text to make life easier for the mobile developer. So, a currency field would be correctly formatted as currency, a number field with commas etc. 

 

In VisualForce, I can get great default formatting via the apex:outputfield. If I try to do the conversion to a string in APEX via string.valueOf, I get a pretty crude string (e.g. for numbers I get an exponential representation). 

 

Is there any way I can access the VisualForce like formatting used in Apex:OutputField from within APEX?

 

thanks!

Aiden

Hi

 

I have a custom object which has two child custom objects.  The relationship is Lookup, not Master-Detail.  These three objects are connected and can be viewed as a single part of a process.

 

I have an approval process on the parent object.  This locks the record.  However, the child records remain accessible.

 

Are there any methods that allow the automated locking of the child records off the back of the approval process on the parent?

 

Thanks

Chris

I am getting a series of errors while installing my managed beta package in a test developer org.  They appear related to unit test routines that work perfectly prior to packaging and in the packaging process, but fail during the installation.  

 

If I check "Ignore Apex Errors" during the installation process, the installation proceeds normally.

 

Here is the type of error I'm getting:

Apex Classes(01pA00000023cDB) testemploymenttriggers.testEmploymentUpsert()
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AQB.AccountBeforeInsert: execution of BeforeInsert

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

 

It looks like I'm getting an error similar to this while loading the package on every test class that I developed.

 

Any ideas of what's going on?

 

Thanks,

Jeff

 

I know that a lead with the isConverted flag set to true cannot be updated, even by an administrator. 

 

Does anyone know if there are any other conditions where Leads, Accounts or Opportunities cannot be updated (apart from transient locks)?

 

 

In several projects, in several orgs, I've scheduled some Batch Apex jobs to run nightly to process large numbers of records. I've run into a couple of problems that are leaving me very uncertain about whether Batch Apex really can handle large jobs.

Every now and then, a job will fail with this error: Unable to write to any of the ACS stores in the alloted time. I first encountered this in September 2010. I filed a Case and created a discussion group posting (http://boards.developerforce.com/t5/Apex-Code-Development/Unable-to-write-to-any-of-the-ACS-stores-in-the-alloted-time/m-p/205908#M36022). After a few weeks, I was finally told that it was an internal issue that had been resolved. After months of running nightly Batch Apex jobs without this problem, it just recurred.

A second issue is that, every now and then, a Batch Apex job gets stuck in the queue in the "Queued" state. When you launch a Batch Apex job, it gets added to the queue in the "Queued" state, and when the system gets around to executing it, the job gets moved to a "Processing" state. Well, I have batch jobs that have been stuck in the "Queued" state since early January. I've had cases open on this problem for over a month, and while the Case finally found its way to Tier 3 Support, there's still no sign of a resolution.

In both cases, the issue is NOT an Apex coding problem. It's an issue with how the platform is queueing and processing Batch Apex jobs.

I'm wondeirng whether anybody else has run into these problems, or other problems executing Batch Apex jobs. What problems have you run into? How have you resolved or worked around them?

Thanks for your insights.

 
  • February 04, 2011
  • Like
  • 0

I have a batch job that runs in several production orgs. It has run fine, twice a day, for several weeks now. However, in a few of the orgs in which it runs, I've started getting the error "Unable to write to any of the ACS stores in the alloted time." What does this error mean, why am I getting it, and what can I do about it?

 

Thanks--

  • September 14, 2010
  • Like
  • 0

If I install my managed beta package into a new developer org the installation works fine.

 

If I install, then uninstall and re-install the installation still works fine.

 

But if I install, use "Manage" to create an org instance of a custom setting object, then uninstall and re-install the re-install fails with errors like these:

 

Apex Classes(01pA0000000i0ux) benefitclaimedactionstest.test()
System.DmlException: Insert failed. First exception on row 0;
first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY,
cvc.BenefitTrigger: execution of BeforeInsert

caused by: System.DmlException: Upsert failed. First exception on row 0;
first error: DUPLICATE_VALUE, duplicate value found:
SetupOwnerId duplicates value on record with id: 00DA0000000Y0TO: []

 

It appears the unit tests run as part of the install process are failing because of this underlying code (in this one case only):

 

 

public class CustomSettings {
    public static DateConversionFactors__c getDateConversionFactors() {
        if (DateConversionFactors__c.getOrgDefaults() == null) {
            insert new DateConversionFactors__c(SetupOwnerId = UserInfo.getOrganizationId());
        }
        return DateConversionFactors__c.getOrgDefaults();
    }
}

 

My best guess is that the uninstall is not cleaning up the data created when "Manage" was used completely and so the SetupOwnerId inserted here is being seen as a duplicate.

 

Does anyone have any experience of this problem or insight into how to avoid it?

 

Thanks,

Keith