• Romeo Mirzac
  • NEWBIE
  • 30 Points
  • Member since 2014
  • Owner
  • Aplus Force Inc.

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 4
    Replies
I have written a try...catch statement, in an Apex Trigger.

OVERVIEW
This routine runs as part of a trigger which evaluates field names.  However, if an invalid field name is passed in, I want to deactive the template record..  This routine works fine IF I remove the objCase.adderror line (the template is marked Inactive).  BUT then I don't get an error on the page.  Any suggests on why this is occurring and how I can resolve it?

CODE SNIPPET:

try{
         String strCompare =string.valueOf(objCase.get(fieldName));
            return strCompare;
        } catch(Exception ex){

            aplusTemplate theTempl = new aplusTemplate(false);
            system.debug('TriggerHandler: ' + templateName);
            theTempl.disableTemplate(templateName);
            String strMsg ='Error with Aplus Template: ';
            strMsg +='An invalid field name on Template (' + templateName + ') ';
            strMsg +='caused a problem. ';
            strMsg += 'This template will be deactivated until the issue can be resolved. ';
            strMsg +='Please report this issue to you system administrator.  ';
            strMsg +='Please try to SAVE the record again. ';
            objCase.addError(strMsg);

        }


My goal is to disable the tea
I created a managed package and am working on deploying it.  When I deploy the package to my testing environment, I keep getting an error while trying to access a customsetting i created.  The error is:  System.LimitException: aplusf:DML currently not allowed.  

The problem is that my applicaiton is NOT generated the managed list, even though I put code in to add the managed list if its not found.  I'm including the code below that I put in the application.  If I MANUALLY create the customsetting managed list name then my app works fine.  Any thoughts as to why this isn't working in test?

try{
            objSettings = new aplusf__Settings__c();
            objSettings = aplusf__Settings__c.getValues(strSetting);
           
            If(objSettings ==null){
                //Need to create new settings
                upsert new aplusf__Settings__c(
                    Name=strSetting,
                    aplusf__EnableApplication__c=false,
                    aplusf__EnableDebugging__c=false,
                    aplusf__EnableRecordTypes__c=false,
                    aplusf__EnableHelpMessage__c=false
                    );
                objSettings = aplusf__Settings__c.getValues(strSetting);
            }
            EnableApplication=objSettings.aplusf__EnableApplication__c;
            EnableDebugging=objSettings.aplusf__EnableDebugging__c;
            EnableRecordTypes=objSettings.aplusf__EnableRecordTypes__c;
            EnableHelpMessage=objSettings.aplusf__EnableHelpMessage__c;
        } Catch(Exception ex){
            String strM = 'An error occurred trying to save settings: ' + ex.getMessage();
            objSettings.addError(strM);
        } finally {return;}
    }
I am working on a managed package. I have a list button on a form which opens a visualforce page using the following code:
/apex/criterianew?templateId={!aplusf__Aplus_Template__c.Id}

This code works great in my development org.  However, I've deployed this page and button (and associated apex controller) into a testing environment.  When I click on the button I get the following error:

Page elouh__criterianew does not exist

What confuses me is that elouh__ is the prefix from my testing environment!  Why is this happening?  How come my button isn't finding my managed package form?

Thanks in advance for your help!
I'm new to Apex and have a very general question:

* Should I put Try..Catch..Finally statements in ALL of my class methods?  Or,
* Should I only add the Try..Catch..Finally to the main method and not add any handling on the subroutines?

What's the best practice?
After adding error checking to my Apex classes (try..catch blocks), my apex unit tests are now less than 100%.  Apparently I'm not testing for the Catch part of my code.  I can't for the life of me figure out how to test for this.  Help!

Thanks.

My catch blocks are all like this:

Catch (Exception ex) {
     String strMsg = 'An error occurred: ' + ex;
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, strMsg);
        ApexPages.addMessage(myMsg);
}
Sorry for this simplistic question, but I have a custom button on 2 different pages which calls the same Visualforce page.  How can I redirect the user back to the correct page when they hit "back" on my custom page?

NOTE:  One of the pages with the button that calls the VF page is the standard list page...

Thanks
I'm trying to render a second pageblock table, when a user clicks on a row with an outputlink in the first page block... Any thoughts on how/if I can do this?  I wrote a custom controller, but I can't get anything to display in the second block and the debug log isn't showing any indication that I'm clicking on a row in the first block.  I'm new to VF and having a tough time getting past this.
After adding error checking to my Apex classes (try..catch blocks), my apex unit tests are now less than 100%.  Apparently I'm not testing for the Catch part of my code.  I can't for the life of me figure out how to test for this.  Help!

Thanks.

My catch blocks are all like this:

Catch (Exception ex) {
     String strMsg = 'An error occurred: ' + ex;
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, strMsg);
        ApexPages.addMessage(myMsg);
}
I'm trying to render a second pageblock table, when a user clicks on a row with an outputlink in the first page block... Any thoughts on how/if I can do this?  I wrote a custom controller, but I can't get anything to display in the second block and the debug log isn't showing any indication that I'm clicking on a row in the first block.  I'm new to VF and having a tough time getting past this.
I am working on a managed package. I have a list button on a form which opens a visualforce page using the following code:
/apex/criterianew?templateId={!aplusf__Aplus_Template__c.Id}

This code works great in my development org.  However, I've deployed this page and button (and associated apex controller) into a testing environment.  When I click on the button I get the following error:

Page elouh__criterianew does not exist

What confuses me is that elouh__ is the prefix from my testing environment!  Why is this happening?  How come my button isn't finding my managed package form?

Thanks in advance for your help!
I'm new to Apex and have a very general question:

* Should I put Try..Catch..Finally statements in ALL of my class methods?  Or,
* Should I only add the Try..Catch..Finally to the main method and not add any handling on the subroutines?

What's the best practice?
Sorry for this simplistic question, but I have a custom button on 2 different pages which calls the same Visualforce page.  How can I redirect the user back to the correct page when they hit "back" on my custom page?

NOTE:  One of the pages with the button that calls the VF page is the standard list page...

Thanks
I'm trying to render a second pageblock table, when a user clicks on a row with an outputlink in the first page block... Any thoughts on how/if I can do this?  I wrote a custom controller, but I can't get anything to display in the second block and the debug log isn't showing any indication that I'm clicking on a row in the first block.  I'm new to VF and having a tough time getting past this.