• aj2taylo2
  • NEWBIE
  • 50 Points
  • Member since 2011

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 22
    Replies

Hi All,

 

I have a Apex Class. THis is used in creating new cases. THe problem is if I create a validation rules it throw an error  when new cases is created. I am not sure why this is happening as I didn't write this code. Any help is appreciated.

 

Error: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please select Type and Category:

Error is in expression '{!insertAndRedirect}' in component <apex:page> in page cases_new

 

An unexpected error has occurred. Your development organization has been notified

 

Code:

public with sharing class cases_Extension {

    public case thisCase {get;set;}
    public List<Case> theseCases {get;set;}
    
    public cases_Extension(ApexPages.StandardController controller){
        this.thisCase = (Case) controller.getRecord();
        this.theseCases = new List<Case>();
    }
    
    public cases_Extension(ApexPages.StandardSetController controller){
        this.theseCases = (List<Case>) controller.getRecords();
    }


    public PageReference insertAndRedirect(){
        //If DID__c is populated, Query DIDs
        if ( thisCase.Did__c != null && (thisCase.AccountId == null || thisCase.ContactId == null )){
            List<DID__c> didQuery = [Select Id, Account__c, Contact__c from DID__c where Id = :thisCase.Did__c limit 1];
            if ( didQuery.size() > 0 ){
                DID__c thisDid = didQuery[0];
                if ( thisCase.AccountId == null && thisDID.Account__c != null ){
                    thisCase.AccountId = thisDID.Account__c;
                } 
                if ( thisCase.ContactId == null && thisDID.Contact__c != null ){
                    thisCase.ContactId = thisDID.Contact__c;
                } 
            } 
        }


        insert thisCase;
        String url = '/'+thisCase.id+'/e?retURL=' + EncodingUtil.urlEncode('/500/o','UTF-8');
        PageReference p = new PageReference(url);
        return p;
    }

    public PageReference getNextCase(){
        //Determine current user
        Id userId = userinfo.getUserId();
        Set<Id> listQueueIds = new Set<id>();
        Set<Id> myQueueIds = new Set<id>();
        List<Case> caseQuery = new List<Case>();
        
        if ( theseCases.size() > 0 ){
            for ( Case c : theseCases ){
                if ( string.valueOf(theseCases[0].OwnerId).subString(0,3) != '005' ){
                    myQueueIds.add( theseCases[0].OwnerId );
                }
            }
            if ( myQueueIds.size() > 0 ){
                caseQuery = [Select Id, CreatedDate, IsClosed from Case where OwnerId in :myqueueIds and IsClosed != TRUE order by CreatedDate asc limit 1];
            }
        }

        if ( caseQuery.size() == 0){
            for ( GroupMember gm : [Select UserOrGroupId, Group.Type, Group.RelatedId, Group.Name, GroupId From GroupMember where Group.Type = 'Queue' and UserOrGroupId = :userId]){
                listQueueIds.add(gm.GroupId);
            }
            caseQuery = [Select Id, CreatedDate, IsClosed from Case where OwnerId in :listQueueIds and IsClosed != TRUE order by CreatedDate asc limit 1];
        }

        if ( caseQuery.size() > 0 ){
            thisCase = caseQuery[0];
            thisCase.OwnerId = userId;
            update thisCase;
            PageReference p = new PageReference('/'+thisCase.id);
            return p;
        } else {
            PageReference p = new PageReference('/500/o');
            return p;
        }
    }

    public PageReference replyToCase(){
        if ( string.valueOf(thisCase.OwnerId).subString(0,3) != '005' ){
            thisCase.OwnerId = userInfo.getUserId();
            update thisCase;
        }
        String templateId = '00X60000000xlFf';  //Sandbox
//      String templateId = '00XR0000000MJWr';  //Production
        
        PageReference p = new PageReference('/_ui/core/email/author/EmailAuthor?p2_lkid='+ thisCase.ContactId + '&p3_lkid=' +  thisCase.Id + '&rtype=003&template_id=' + templateId + '&p26=' + thisCase.From__c + '&retURL=%2F' + thisCase.Id);
        p.setRedirect(true);
        return p;
    }

}

  • February 24, 2013
  • Like
  • 0

I have a schedulable class that I've been able to schedule previously.  I stopped the job today as I needed to update some parts of a related class.

 

All of my regression tests pass, and the class shows 100% code coverage.

 

However, I couldn't schedule it via the UI, it keeps returning an error stating Error: You must select an Apex class that implements the Schedulable interface.

 

I added some whiltespace and then deleted it from the scheduable class, then saved, and then I was able to schedule it again.

 

Any thoughts?

Can multiple profiles be used on a Customer Portal, or can it only run under one profile?

 

I have a a portal setup with "Profile A" setup as the Default New User Profile;  I then have "Profile A" and "Profile B" in the Assigned Profile Lists, but if I change User Z's profile from Profile A to Profile B, I get insufficient priviliges in the portal.

 

 

I have HTML5 page that pulling data for multiple accounts in concurrent batches. 

 

I'm getting the following error in my Javascript console:

 

Visualforce Remoting Exception: Unable to connect to the server (transaction aborted: timeout).

 

Would this be from Salesforce refusing the request due to too many requests?  Is there a limit to multiple concurrent Remoting requests?

 

 

I'm attempting to use Debug Logs, logged in as a different user, and not all the "System.debug" lines are appearing in the debug logs.  Any ideas?

 

 

I'm peridically getting errors in our sandbox (Winter '14) when running tests - Could not run tests on class [class Id].  If I attempt to re-run, it generally works, but one is consistently failing now.

 

There doesn't appear to be any errors with the class itself - any ideas?

 

As a side note, anyone know why the estimated code coverage is no longer visible when viewing the list of classes (Setup > Apex Classes)? 

 

Does a user need administrator privileges to install the force.com ide on a windows machine?  I need to visit a site and use one of their machines to access their SFDC org (security protocol), and they are asking what is required to install the IDE.

 

 

I have a VF page showing a custom object record.  I'd like to add a button to post the details to Facebook (or twitter), but unsure where to start.  Can someone point me to a tutorial or posting that would get me there?

I have an inputField which is a decimal, but if the existing value is an integer, I want to strip the decimals (e.g. show 5 instead of 5.00).

 

<apex:inputField value="{!myObject.Field__c}" />

 

Is there a way I can do this?

I'm developing an import tool through a VF page, and the uploaded CSV will contain a date field.

 

The date field may arrive in different formats (YYYY/MM/DD;  MON-DD, YY, etc).  Is there a common library for this, or will I have to write a regex utility to do the conversion from string to date based on the string format?

I have a VF Extension class with subclass, that has a void method.

 

public with sharing class myWizard {

    public myWizard(ApexPages.StandardController stdController) {
        ...
    }

        public List<listMap> getHierarchy() { 
            ... 
            return returnList;
        }


        // ------------------------------------------------------
        // Custom class for the Gantt Chart Projects
        // ------------------------------------------------------
            public class listMap {
                
                public listMap(...) {              
                   instantiateValues();
                }
                
                private void instantiateValues() {
                   ...
                }
                
                public void addChild() {
                    try {
                        ...
                    } catch (Exception e) {
                        if(e.getTypeName() != 'System.DmlException') {
                            this.myRecord.addError(e.getMessage());
                        }
                    }
                }
                
                
            }

            
}

 

When the void method (addChild) from my VF Page, I want to return an error for an Exception. Is there a way I can do this?

 

 

I have a custom class that is updating a list of records.

 

Is there a way for me to iterate through the list to determine if a particular field has been updated before/after update?

 

public PageReference mySave() { 
    update this.myRecords;

    for(Object__c o : this.myRecords) 
        if(o.myField__c <> [oldvalue].myField__c)
            {do something}
}

 

I know how to accomplish this in a trigger, but I only want to execute this change check within my controller, not globally for all record updates.

 

 

I changed my site template for my Site, but when I load the site, it still shows the old template.  Any idea how long it takes to refresh this, or if there's something I need to do to force the change through?

I'm working with Jeff Douglas' sample app (Databasedotcom-Gem-Demo), and getting errors (ArgumentError with no detail) when using Account.all and Account.find(params[:id])

The connection to Salesforce appears to be fine (I'm not seeing any errors at least).  Is there a way I can further debug this, or might I have a bad version of the gem installed?
Thank you

Is there a way I can force a refresh of my Site?  I have updated the template to a custom one, but the default standard SiteTemplate still appears.

 

I'm trying to checkout the databasedotcom gem when integrating with Heroku.


I've tried deploying a couple sample apps posted on github, but without even changing the code, the apps return 500 errors.

 

Can anyone recommend a place to get started with setting up a simple app that can return a list of users/accounts/some object?

 

I am working on an org where I can't determine how an auto-response for a Case is being generated.

 

- when the case is opened, an email is sent.  I don't recognize the email template.

 

- the "Auto Response" rules setup for the org don't include a rule for this Record Type, and the templates used do not match any of the above.  So the email is not sent from there.

 

- I can't see anywhere in the APEX code where this email is sent.  When I check the debug log, it doesn't appear that any Email Invocations are run.

 

- I can't see any workflow email triggers that send this

 

- If I modify one of the Auto Response rules to include the Record Type in question, the Auto Response rule runs as expected;  the original email is not sent.

 

- If I reset the Auto Response rules, then the original email is sent again.

 

Is there any way for me to diagnose this?

 

Thank you

 

AT 

Can anyone point me to a sample call to custom webservice (on Force.com) made from Rails?

 

I have found some samples to connect via Oauth and query data, but I'm looking more to integrate with a custom web service (i.e. pass in a couple strings to the webservice, and have it return a boolean/integer/whatever).

 

I've done this in PHP before (exporting the wsdl to the external server), but haven't found samples on how to do it in Rails.

 

I'm attempting to follow the article linked here for integrating with Salesforce: https://devcenter.heroku.com/articles/omniauth-and-force-com

 

When I reach the step to run "rails generate controller sessions create", I'm getting an error for multi_json.

 

"Bundler could not find compatible versions for gem "multi_json": 
In Gemfile: rails (=3.2.3) x86-mingw32 depends on multi_json (~> 1.0) x86-mingw32 
omniauth (=0.2.0) x86-mingw32 depends on multi_json (0.0.5)"

 

Has anyone else encountered this?

I have a trigger that's updating the UnitPrice of an existing OpportunityLineItem.

 

When this happens, I get the error "Cannot change both 'UnitPrice' and 'TotalPrice' in update call".  The TotalPrice is not being touched in this segment of code.  When I write the contents of the update call to the System log, the TotalPrice is not included.

 

However, when this update is called, a Before Update Trigger is fired, and when I write "System.trigger.new" to the error log, I can now see the TotalPrice (not sure if now the system believes I'm setting both values in my call?)

 

Any advice/thoughts on this?

 

 

I have HTML5 page that pulling data for multiple accounts in concurrent batches. 

 

I'm getting the following error in my Javascript console:

 

Visualforce Remoting Exception: Unable to connect to the server (transaction aborted: timeout).

 

Would this be from Salesforce refusing the request due to too many requests?  Is there a limit to multiple concurrent Remoting requests?

 

 

I'm attempting to use Debug Logs, logged in as a different user, and not all the "System.debug" lines are appearing in the debug logs.  Any ideas?

 

 

I'm peridically getting errors in our sandbox (Winter '14) when running tests - Could not run tests on class [class Id].  If I attempt to re-run, it generally works, but one is consistently failing now.

 

There doesn't appear to be any errors with the class itself - any ideas?

 

As a side note, anyone know why the estimated code coverage is no longer visible when viewing the list of classes (Setup > Apex Classes)? 

 

I have a VF page showing a custom object record.  I'd like to add a button to post the details to Facebook (or twitter), but unsure where to start.  Can someone point me to a tutorial or posting that would get me there?

Hi all........

I have a requirement like there is one custom object by name 'Position'..... I need its data to be filled from web form. How to implement it.

Note: I am already using lead object so cant use it for this purpose.........

I have the following in a helper class accessed by a Trigger that is run for every Opty given we are using custom Fiscal settings:

String fiscalYear = [SELECT PeriodId, Name from FiscalYearSettings where StartDate<=:curDateEval and EndDate>=:curDateEval].Name;

 

Which I would like to convert into something like:

List<Date> datesToInclude = new List<Date>();

List<...> fiscalYrs = [SELECT Name from FiscalYearSettings where StartDate<=: IN datesToInclude and EndDate>=: IN datesToInclude]

 

Adding the "IN" keyword for a in-between date comparison is not working...does someone know how to do this Query in one shot for all my Opty dates?

 

 

What is wrong with my code? After i execute it,  annualvalue dont change...

public class ChangeValue{
    public ChangeValue(){
        List<Contact> cts = [SELECT ID, AccountID from Contact Where Name = 'test'];
		//Get list of account IDs    
		Set<ID> accountids = new Set<ID>();
        for(Contact ct: cts) if(ct.AccountID!=null){
        	accountids.add(ct.AccountID);}
        if(accountids.size()>0)
        {
            List<Account> accounts = [Select ID, AnnualRevenue 
                                      from Account where ID in :accountids];
            for(Account accountfound: accounts)
                if(accountfound.AnnualRevenue != 0)
                accountfound.AnnualRevenue = 500;
            update accounts;
        }
    }    
}

 

I have a VisualForce page with multiple tabs.

 

Each tab has <apex:inputField> tags were required=true. The fields are not required at the object level, only on the VisualForce page.

 

When the page invokes any action, the action will not execute unless all required fields on all tabs, even the ones that are inactive and not visible, are completed.

 

This is OK. I want to user to complete all information.

 

My problem is that I do not have a way to let the user know that the missing information in on an inactive tab. 

 

Does anyone know how to determine which tabs have uncompleted required fields so that I can provide some indication to the user?

 

Ideally, I would like a way to change the tab indicator to show that data is complete on the tab or not.

 

I am guessing I need some sort of Javascript to cycle through the elements in each tab. 

 

Thanks.

 

 

I'm developing an import tool through a VF page, and the uploaded CSV will contain a date field.

 

The date field may arrive in different formats (YYYY/MM/DD;  MON-DD, YY, etc).  Is there a common library for this, or will I have to write a regex utility to do the conversion from string to date based on the string format?

I have a VF Extension class with subclass, that has a void method.

 

public with sharing class myWizard {

    public myWizard(ApexPages.StandardController stdController) {
        ...
    }

        public List<listMap> getHierarchy() { 
            ... 
            return returnList;
        }


        // ------------------------------------------------------
        // Custom class for the Gantt Chart Projects
        // ------------------------------------------------------
            public class listMap {
                
                public listMap(...) {              
                   instantiateValues();
                }
                
                private void instantiateValues() {
                   ...
                }
                
                public void addChild() {
                    try {
                        ...
                    } catch (Exception e) {
                        if(e.getTypeName() != 'System.DmlException') {
                            this.myRecord.addError(e.getMessage());
                        }
                    }
                }
                
                
            }

            
}

 

When the void method (addChild) from my VF Page, I want to return an error for an Exception. Is there a way I can do this?

 

 

Hi All,

 

I have a Apex Class. THis is used in creating new cases. THe problem is if I create a validation rules it throw an error  when new cases is created. I am not sure why this is happening as I didn't write this code. Any help is appreciated.

 

Error: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please select Type and Category:

Error is in expression '{!insertAndRedirect}' in component <apex:page> in page cases_new

 

An unexpected error has occurred. Your development organization has been notified

 

Code:

public with sharing class cases_Extension {

    public case thisCase {get;set;}
    public List<Case> theseCases {get;set;}
    
    public cases_Extension(ApexPages.StandardController controller){
        this.thisCase = (Case) controller.getRecord();
        this.theseCases = new List<Case>();
    }
    
    public cases_Extension(ApexPages.StandardSetController controller){
        this.theseCases = (List<Case>) controller.getRecords();
    }


    public PageReference insertAndRedirect(){
        //If DID__c is populated, Query DIDs
        if ( thisCase.Did__c != null && (thisCase.AccountId == null || thisCase.ContactId == null )){
            List<DID__c> didQuery = [Select Id, Account__c, Contact__c from DID__c where Id = :thisCase.Did__c limit 1];
            if ( didQuery.size() > 0 ){
                DID__c thisDid = didQuery[0];
                if ( thisCase.AccountId == null && thisDID.Account__c != null ){
                    thisCase.AccountId = thisDID.Account__c;
                } 
                if ( thisCase.ContactId == null && thisDID.Contact__c != null ){
                    thisCase.ContactId = thisDID.Contact__c;
                } 
            } 
        }


        insert thisCase;
        String url = '/'+thisCase.id+'/e?retURL=' + EncodingUtil.urlEncode('/500/o','UTF-8');
        PageReference p = new PageReference(url);
        return p;
    }

    public PageReference getNextCase(){
        //Determine current user
        Id userId = userinfo.getUserId();
        Set<Id> listQueueIds = new Set<id>();
        Set<Id> myQueueIds = new Set<id>();
        List<Case> caseQuery = new List<Case>();
        
        if ( theseCases.size() > 0 ){
            for ( Case c : theseCases ){
                if ( string.valueOf(theseCases[0].OwnerId).subString(0,3) != '005' ){
                    myQueueIds.add( theseCases[0].OwnerId );
                }
            }
            if ( myQueueIds.size() > 0 ){
                caseQuery = [Select Id, CreatedDate, IsClosed from Case where OwnerId in :myqueueIds and IsClosed != TRUE order by CreatedDate asc limit 1];
            }
        }

        if ( caseQuery.size() == 0){
            for ( GroupMember gm : [Select UserOrGroupId, Group.Type, Group.RelatedId, Group.Name, GroupId From GroupMember where Group.Type = 'Queue' and UserOrGroupId = :userId]){
                listQueueIds.add(gm.GroupId);
            }
            caseQuery = [Select Id, CreatedDate, IsClosed from Case where OwnerId in :listQueueIds and IsClosed != TRUE order by CreatedDate asc limit 1];
        }

        if ( caseQuery.size() > 0 ){
            thisCase = caseQuery[0];
            thisCase.OwnerId = userId;
            update thisCase;
            PageReference p = new PageReference('/'+thisCase.id);
            return p;
        } else {
            PageReference p = new PageReference('/500/o');
            return p;
        }
    }

    public PageReference replyToCase(){
        if ( string.valueOf(thisCase.OwnerId).subString(0,3) != '005' ){
            thisCase.OwnerId = userInfo.getUserId();
            update thisCase;
        }
        String templateId = '00X60000000xlFf';  //Sandbox
//      String templateId = '00XR0000000MJWr';  //Production
        
        PageReference p = new PageReference('/_ui/core/email/author/EmailAuthor?p2_lkid='+ thisCase.ContactId + '&p3_lkid=' +  thisCase.Id + '&rtype=003&template_id=' + templateId + '&p26=' + thisCase.From__c + '&retURL=%2F' + thisCase.Id);
        p.setRedirect(true);
        return p;
    }

}

  • February 24, 2013
  • Like
  • 0

I have a custom class that is updating a list of records.

 

Is there a way for me to iterate through the list to determine if a particular field has been updated before/after update?

 

public PageReference mySave() { 
    update this.myRecords;

    for(Object__c o : this.myRecords) 
        if(o.myField__c <> [oldvalue].myField__c)
            {do something}
}

 

I know how to accomplish this in a trigger, but I only want to execute this change check within my controller, not globally for all record updates.

 

 

So I am trying to call a simple string method to remove a specified set of characters from an existing string, and I keep getting an error message that says: 

 

Error: Compile Error: Method does not exist or incorrect signature: [String].remove(String) at line 10 column 30

 

So my code is fairly simple so far, all I have is this

trigger updateTextEmail on Contact (before insert, before update) {

    List<String> contactNames = new List<String>{};

    for(Contact c: Trigger.new){

        if (c.MobilePhone != '') {
            
           String phone = c.MobilePhone;
           String numPhone = phone.remove('()- ');
            
        }

    }

}

 

So why doesn't the remove method work? I have copied and pasted the method example straight from the documentation, and even that throws an error. Is there something I have to import/include? 

 

Thanks in advance

I'm working with Jeff Douglas' sample app (Databasedotcom-Gem-Demo), and getting errors (ArgumentError with no detail) when using Account.all and Account.find(params[:id])

The connection to Salesforce appears to be fine (I'm not seeing any errors at least).  Is there a way I can further debug this, or might I have a bad version of the gem installed?
Thank you

I am working on an org where I can't determine how an auto-response for a Case is being generated.

 

- when the case is opened, an email is sent.  I don't recognize the email template.

 

- the "Auto Response" rules setup for the org don't include a rule for this Record Type, and the templates used do not match any of the above.  So the email is not sent from there.

 

- I can't see anywhere in the APEX code where this email is sent.  When I check the debug log, it doesn't appear that any Email Invocations are run.

 

- I can't see any workflow email triggers that send this

 

- If I modify one of the Auto Response rules to include the Record Type in question, the Auto Response rule runs as expected;  the original email is not sent.

 

- If I reset the Auto Response rules, then the original email is sent again.

 

Is there any way for me to diagnose this?

 

Thank you

 

AT