• Tad Aalgaard 3
  • NEWBIE
  • 130 Points
  • Member since 2014

  • Chatter
    Feed
  • 4
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 26
    Replies
Hello everyone,

I am working on my first trigger and I was able to get the trigger to create a Case from a change in the account object but the only problem is, it is only supposed to create a Case if there isn't already a Case in the status of 'New' or 'On Service' in the Account

When i go to a test account, the trigger fires even when there is a Case that is New. I was wondering if anyone could look at my code and help me find out why this is happening
 
trigger caseCheck on Account (After update) {
        //Get all account and cases.
  

  List<Account> allAccounts = new List<Account>([Select id,Fuzion_Status__c,(select id from cases where status in('New','On Service')) from account where id in :Trigger.new]);
   List<Case> newCases = new List<Case>();
    
    for(Account myAccount :allAccounts){
    Account oldAccount = trigger.oldMap.get(myAccount.id);
    if(oldAccount.Fuzion_Status__c == 'Initial Phone call' && myAccount.Fuzion_Status__c != 'Initial Phone call'){
        if(myAccount.cases !=null){
            Case c = new Case();
            c.Accountid = myAccount.Id;
            c.Type = 'ICM';
            c.Origin = 'SHIP';
            c.Division__c = 'Case Management';
            c.Status = 'New';
            c.RecordTypeId = '01236000000OJLq';
            newCases.add(c); 
        }
     }
        
    }
    if(!NewCases.isEmpty()){
        insert newCases;
    }
 
}

 
Hello,
I am writing a test for an @InvocableMethod and for some reason I keep getting an error that says Invalid Type: SendPdf. Code below, any help is appreciated!!
Controller
public with sharing class EchoSign {
    private ApexPages.StandardController standardController;
    public EchoSign(ApexPages.StandardController standardController){
        this.standardController = standardController;}

@InvocableMethod
    public static void SendPdf(List<ID> conid){
        
    List<Contact> con = [SELECT Id, AccountId, Name FROM Contact WHERE Id =: conid LIMIT 1];  
        
        pageReference pdfPage = Page.ContactPDF;
        pdfPage.getParameters().put('Id',con[0].Id);
        blob pdfBody;
        pdfBody = pdfPage.getContentAsPDF();

//creation of Adobe Sign Agreement and Attachment here
}
}
Test
@isTest
public class Test_EchoSign2 {
    static testMethod void testechosign(){
    	Account ac = new Account(RecordTypeId = [SELECT Id, SobjectType, Name FROM Recordtype WHERE Name = 'Prospect/Client' AND SobjectType = 'Account' LIMIT 1].Id);
    	ac.Name = 'TestAcnt';
    	ac.Type = 'Prospect';
    	insert ac;
    
		Contact con = new Contact(RecordTypeId = [SELECT Id,SObjectType,Name FROM RecordType WHERE Name = 'Prospect/Client' AND SobjectType = 'Contact' LIMIT 1].Id);
		con.LastName = 'testLastName';
    	con.AccountId = ac.Id;
	    con.LeadSource = 'Unknown';
        insert con;
        
        Test.startTest();
        
        PageReference ContactPDF = Page.ContactPDF;
        ContactPDF.getParameters().put('Id',con.Id);
        Test.setCurrentPage(ContactPDF);
        
        SendPdf pdf = new SendPdf();
    }
}


 
I need to reference a put a Select Query into a String, but it won't process system data like getUserId() (or system.now, although I'm not sure because the error message centers on getUserId()).

Here's what I have:
 
String UserID = UserInfo.getUserId();

String myRequest = 'SELECT id, Owner.Id, type, subject,'+
                ' FROM Event' + 
                ' WHERE Owner.Id = '+UserId+' AND RecordTypeId = \'0126A0000004Qle\' And (ActivityDateTime = LAST_N_DAYS:30 OR (ActivityDate = TODAY And ActivityDateTime < ' + system.now() + ' ))';
Error message is "System.QueryExecption: unexpected token:" and then my UserId.
 
I'm creating a VF page for employees to create a record for a custom object. I'm having issues writing the redirect Apex code so that after they hit "Submit", the employees will be redirected to another VF page (that I've created called "SuccessPage") that says "Your profile has been submitted successfully". After five seconds the SuccessPage it automatically redirect to the company's website. But if the employee hits Cancel, it will close the VF page.

Record Code
<apex:page standardController="Object__c"> 
<apex:form >

<div class="header">
    <center><img src="{!$Resource.companylogo}" width="10%"/></center>
  </div> 
 
        <style>
            body .bPageBlock .pbBody .blue .pbSubheader{
                background-color:#154f82;
            
            }
            body .bPageBlock .pbBody .white .pbSubheader h3{
                color:#ffffff;
            }
        </style>
        

<apex:outputPanel styleClass="blue" layout="block">
      <apex:pageBlockSection title="Skills" id="section7">
       <apex:inputField value="{!Employee_Profile__c.Skills__c}"/>        
</apex:pageBlockSection>
</apex:outputPanel>

</apex:pageBlock>

<center><apex:commandButton value="Submit" action="{!save}"/><apex:commandButton value="Cancel" action="{!cancel}"/></center> 


  </apex:form>
</apex:page>
Success VF page
<apex:page >
    <h1>Success</h1>

  
  <script type="text/javascript">
    window.setTimeout("redirectpage();", 5000);    
    function redirectpage(){
    window.top.location.href = 'http://www.website.com';
    }
</script>
</apex:page>




 
If Email Deliverability is not set to All Email in my sandbox my code will error out when trying to send an email.  How can I check if Email Deliverabitlity is set to All Email in Apex so that I don't receive the NO_MASS_MAIL_PERMISSION errors?
I use Subversion, Sublime and Tortoise SVN and Windows.  I have no plan on chaning to Git (just to get that out there).  

That being said, I am in the process of creating a version control structure for our environment.  Being fairly new to branching and merging I am looking for some feedback.

Here is the directory structure that I have planned.  

Salesforce
    trunk
    branches
            
From what I can tell I need to commit my production code to trunk (stored in src)

Salesforce
    trunk
        config
        src
    branches
        
Then, when I wish to work on a project, I need to create a branch into the branch directory (which makes a copy of everything from the trunk)

Salesforce
    trunk
        config
        src
    branches
        project1
            config
            src
            
I then work in the project1 directory on my local computer.
When I have a change that is completed I then commit it to the project1 branch.
When my code is ready for production I then have to perform a merge to the trunk.  This is where I am having issues.  From what I have seen I have to go to the local copy of the trunk and do a merge and specify the source as the location in the branch of my changed file.  I cannot get it to merge this brand new file into the trunk.  Any ideas of what I am doing wrong?
I have a need to get the User object for the user who logged into SFDC so that I can use it in my community. After using "log in to community as user" how can I use Apex to get the original Salesforce user?

On the Content object page I can see it dispalyed in Kb or other sizes, but when I display the contentsize field on a Visualforce page it shows the size in bytes.  I would like it to appear as Kb, Mb, or Gb.  A contractor had used some JavaScript to calcuate the size on another page, but I'd rather not use JavaScript as I'd like to try and stay server side instead of client side.  What are my options?  Do I use forumula on a second hidden field, is there some Visualforce tag I can use? 

I am getting an error when trying a file into Chatter via RestAPI.

[{"errorCode":"POST_BODY_PARSE_ERROR","message":"Binary data included but file attachment information is missing. If providing rich JSON/XML input in multipart REST, make sure to include Content-Type header in the part."}]

Here is a snippet of my code, what am I missing?
 
DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost;
        MultipartEntity reqEntity;
        httppost = new HttpPost(RES_URL);
        reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        File imageFile = new File(
                "/salesforce/wsdl/test.txt");
        FileBody bin = new FileBody(imageFile);
        reqEntity.addPart("feedItemFileUpload", bin);
        String fileName = "test.txt";
        // file name can be text plain only, though using text/html doesn't breaks
        reqEntity.addPart("fileName", new StringBody(fileName, "text/plain",
                Charset.defaultCharset()));

        httppost.setEntity(reqEntity);

        httppost.setHeader("Authorization",         "OAuth " + logon());

        String response = EntityUtils.toString(httpclient.execute(httppost)
                .getEntity(), "UTF-8");

        System.out.println(response);

 
I have an issue where when you click on "Click here to view HTML version" on an Inbound Email Message in a Case some of the text will not display correctly and gets cut off because Salesforce treats certain special characters as HTML.

Example
files (where 0 <= i <= 6) 
turns to 
files (where 0
 
I have a need to get the User object for the user who logged into SFDC so that I can use it in my community. After using "log in to community as user" how can I use Apex to get the original Salesforce user?
Hi All,
I am getting following when I am performing DML Operation
 
​System.ExternalObjectException: Salesforce System Error: 627698564-15996 (1450171494) (1450171494) : (System Code)
Error is in expression '{!Search}' in component <apex:commandButton> in page cpm_lookup1: Class.CustomAccountLookupController.performSearch: line 34, column 1
Class.CustomAccountLookupController.runSearch: line 23, column 1
Class.CustomAccountLookupController.search: line 16, column 1

This is my code
public with sharing class CustomAccountLookupController {

  public Account account {get;set;} // new account to create
  public List<externalobj1__x> results{get;set;} // search results
  public string searchString{get;set;} // search keyword

  public CustomAccountLookupController() {
    account = new Account();
    // get the current search string
    searchString = System.currentPageReference().getParameters().get('lksrch');
    runSearch();  
  }

  // performs the keyword search
  public PageReference search() {
    runSearch();
    return null;
  }

  // prepare the query and issue the search command
  private void runSearch() {
    // TODO prepare query string for complex serarches & prevent injections
    results = performSearch(searchString);               
  } 

  // run the search and return the records found. 
  private List<externalobj1__x> performSearch(string searchString) {

    String soql = 'select id,externalid from externalobj1__x';
    if(searchString != '' && searchString != null)
      soql = soql +  ' where externalid LIKE \'%' + searchString +'%\'';
    soql = soql + ' limit 25';
    System.debug(soql);
    return database.query(soql); 

  }

  // save the new account record
  public PageReference saveAccount() {
    insert account;
    // reset the account
    account = new Account();
    return null;
  }

  // used by the visualforce page to send the link to the right dom element
  public string getFormTag() {
    return System.currentPageReference().getParameters().get('frm');
  }

  // used by the visualforce page to send the link to the right dom element for the text box
  public string getTextBox() {
    return System.currentPageReference().getParameters().get('txt');
  }

}
 
<apex:page controller="CustomAccountLookupController"  
  title="Search" 
  showHeader="false" 
  sideBar="false" 
  tabStyle="Account" 
  id="pg">

  <apex:form >
  <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
    <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">

      <!-- SEARCH TAB -->
      <apex:tab label="Search" name="tab1" id="tabOne">

        <apex:actionRegion >  
          <apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
            <apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
            <apex:inputText id="txtSearch" value="{!searchString}" />
              <span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
          </apex:outputPanel>

          <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
            <apex:pageBlock id="searchResults"> 
              <apex:pageBlockTable value="{!results}" var="a" id="tblResults">
                <apex:column >
                  <apex:facet name="header">
                    <apex:outputPanel >Name</apex:outputPanel>
                  </apex:facet>
                   <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.externalId}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.externalid}</apex:outputLink>     
                </apex:column>
              </apex:pageBlockTable>
            </apex:pageBlock>
          </apex:outputPanel>
        </apex:actionRegion>

      </apex:tab>

      <!-- NEW ACCOUNT TAB -->
      <apex:tab label="New Account" name="tab2" id="tabTwo">

        <apex:pageBlock id="newAccount" title="New Account" >

          <apex:pageBlockButtons >
            <apex:commandButton value="Save"/>
          </apex:pageBlockButtons>
          <apex:pageMessages />

          <apex:pageBlockSection columns="2">
            
          </apex:pageBlockSection> 
        </apex:pageBlock>

      </apex:tab>
    </apex:tabPanel>
  </apex:outputPanel>
  </apex:form>
</apex:page>

Please help me in resolving this error

Thanks in Advance
Hello everyone,

I am working on my first trigger and I was able to get the trigger to create a Case from a change in the account object but the only problem is, it is only supposed to create a Case if there isn't already a Case in the status of 'New' or 'On Service' in the Account

When i go to a test account, the trigger fires even when there is a Case that is New. I was wondering if anyone could look at my code and help me find out why this is happening
 
trigger caseCheck on Account (After update) {
        //Get all account and cases.
  

  List<Account> allAccounts = new List<Account>([Select id,Fuzion_Status__c,(select id from cases where status in('New','On Service')) from account where id in :Trigger.new]);
   List<Case> newCases = new List<Case>();
    
    for(Account myAccount :allAccounts){
    Account oldAccount = trigger.oldMap.get(myAccount.id);
    if(oldAccount.Fuzion_Status__c == 'Initial Phone call' && myAccount.Fuzion_Status__c != 'Initial Phone call'){
        if(myAccount.cases !=null){
            Case c = new Case();
            c.Accountid = myAccount.Id;
            c.Type = 'ICM';
            c.Origin = 'SHIP';
            c.Division__c = 'Case Management';
            c.Status = 'New';
            c.RecordTypeId = '01236000000OJLq';
            newCases.add(c); 
        }
     }
        
    }
    if(!NewCases.isEmpty()){
        insert newCases;
    }
 
}

 
Hello,
I am writing a test for an @InvocableMethod and for some reason I keep getting an error that says Invalid Type: SendPdf. Code below, any help is appreciated!!
Controller
public with sharing class EchoSign {
    private ApexPages.StandardController standardController;
    public EchoSign(ApexPages.StandardController standardController){
        this.standardController = standardController;}

@InvocableMethod
    public static void SendPdf(List<ID> conid){
        
    List<Contact> con = [SELECT Id, AccountId, Name FROM Contact WHERE Id =: conid LIMIT 1];  
        
        pageReference pdfPage = Page.ContactPDF;
        pdfPage.getParameters().put('Id',con[0].Id);
        blob pdfBody;
        pdfBody = pdfPage.getContentAsPDF();

//creation of Adobe Sign Agreement and Attachment here
}
}
Test
@isTest
public class Test_EchoSign2 {
    static testMethod void testechosign(){
    	Account ac = new Account(RecordTypeId = [SELECT Id, SobjectType, Name FROM Recordtype WHERE Name = 'Prospect/Client' AND SobjectType = 'Account' LIMIT 1].Id);
    	ac.Name = 'TestAcnt';
    	ac.Type = 'Prospect';
    	insert ac;
    
		Contact con = new Contact(RecordTypeId = [SELECT Id,SObjectType,Name FROM RecordType WHERE Name = 'Prospect/Client' AND SobjectType = 'Contact' LIMIT 1].Id);
		con.LastName = 'testLastName';
    	con.AccountId = ac.Id;
	    con.LeadSource = 'Unknown';
        insert con;
        
        Test.startTest();
        
        PageReference ContactPDF = Page.ContactPDF;
        ContactPDF.getParameters().put('Id',con.Id);
        Test.setCurrentPage(ContactPDF);
        
        SendPdf pdf = new SendPdf();
    }
}


 
Since Winter 18 update I'm getting the Internal Salesforce Error (-131831505) while executing Unit tests. Seems error persists during tests only. It works okay in real-time. I was able to find out that code fails on Inserting the task with custom Record Type Id which is part of the package:

Task task = new Task(Subject = "Subject",
                                 Description = "Description",
                                 ActivityDate = Date.today(),
                                 RecordTypeId = recordTypeId,
                                 Status = 'Completed'
                                 );
Hi All,
I am a beginner SF developer.  I was trying to download MavensMate to use for an IDE but it appears that it's no longer being supported.  From what I have read, MavensMate was highly regarded.  What IDE should I use instead?  Eclipse or Visual studio via the extension?
I need to reference a put a Select Query into a String, but it won't process system data like getUserId() (or system.now, although I'm not sure because the error message centers on getUserId()).

Here's what I have:
 
String UserID = UserInfo.getUserId();

String myRequest = 'SELECT id, Owner.Id, type, subject,'+
                ' FROM Event' + 
                ' WHERE Owner.Id = '+UserId+' AND RecordTypeId = \'0126A0000004Qle\' And (ActivityDateTime = LAST_N_DAYS:30 OR (ActivityDate = TODAY And ActivityDateTime < ' + system.now() + ' ))';
Error message is "System.QueryExecption: unexpected token:" and then my UserId.
 
I'm creating a VF page for employees to create a record for a custom object. I'm having issues writing the redirect Apex code so that after they hit "Submit", the employees will be redirected to another VF page (that I've created called "SuccessPage") that says "Your profile has been submitted successfully". After five seconds the SuccessPage it automatically redirect to the company's website. But if the employee hits Cancel, it will close the VF page.

Record Code
<apex:page standardController="Object__c"> 
<apex:form >

<div class="header">
    <center><img src="{!$Resource.companylogo}" width="10%"/></center>
  </div> 
 
        <style>
            body .bPageBlock .pbBody .blue .pbSubheader{
                background-color:#154f82;
            
            }
            body .bPageBlock .pbBody .white .pbSubheader h3{
                color:#ffffff;
            }
        </style>
        

<apex:outputPanel styleClass="blue" layout="block">
      <apex:pageBlockSection title="Skills" id="section7">
       <apex:inputField value="{!Employee_Profile__c.Skills__c}"/>        
</apex:pageBlockSection>
</apex:outputPanel>

</apex:pageBlock>

<center><apex:commandButton value="Submit" action="{!save}"/><apex:commandButton value="Cancel" action="{!cancel}"/></center> 


  </apex:form>
</apex:page>
Success VF page
<apex:page >
    <h1>Success</h1>

  
  <script type="text/javascript">
    window.setTimeout("redirectpage();", 5000);    
    function redirectpage(){
    window.top.location.href = 'http://www.website.com';
    }
</script>
</apex:page>




 
When ever user is trying to create duplicate contact ,I would like to send an email to Admin , . I am able to prevent the duplicate contacts using trigger , but not able to send email to Admin.

I need below two operation together.
1)User should receive the duplicate contact error.
2)Admin should receive an notofication email.
I am able to perform only one action not both , Any one has any solution for this scenario?
 
Hi,

I have deployed this Apex Testing class in production that messed up my whole production org; it got to a point where I'm not able to deploy anything on production nor able to delete it (the Apex class that's causing the issue). 

Here what I did to delete test class:

1. I download Eclipse and insalled the Foce.com IDE.
2. Then I created Foce.com two projects; one includes all my master production org components and one includes all of my sandbox components.
3. After that I went to sandbox project and altered my class file.xml to "Deleted" and changed four of my triggers (tied to the class, not needed anymore) to "Inactive"
4. I attempted to deploy the five components (referenced above) to production in order to delete trigger and deactive class but I failed. Got this error message and coverage results:
 
*** Deployment Log ***
Result: FAILED
Date: October 17, 2017 5:35:32 PM PDT

# Deployed From:
   Project name: Inbody_replacing
   Username: mahmoud@enarahealth.com.sandbox
   Endpoint: test.salesforce.com

# Deployed To:
   Username: mahmoud@enarahealth.com
   Endpoint: login.salesforce.com

# Deploy Results:
   File Name:    classes/InsertInbodyData_TestClass.cls
   Full Name:  InsertInbodyData_TestClass
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    package.xml
   Full Name:  package.xml
   Action:  UPDATED
   Result:  SUCCESS
   Problem: n/a

   File Name:    triggers/GetInitialPBFValue.trigger
   Full Name:  GetInitialPBFValue
   Action:  NO ACTION
   Result:  SUCCESS
   Problem: n/a

   File Name:    triggers/GetInitialSMMValue.trigger
   Full Name:  GetInitialSMMValue
   Action:  NO ACTION
   Result:  SUCCESS
   Problem: n/a

   File Name:    triggers/GetLatestPBFValue.trigger
   Full Name:  GetLatestPBFValue
   Action:  NO ACTION
   Result:  SUCCESS
   Problem: n/a

   File Name:    triggers/GetLatestSMMValue.trigger
   Full Name:  GetLatestSMMValue
   Action:  NO ACTION
   Result:  SUCCESS
   Problem: n/a

# Test Results:

Run Failures:
  InsertInbodyData_TestClass.UpdateBIA System.DmlException: Update failed. First exception on row 0 with id a076100000HLRd3AAH; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
User-added image

Here is the code for Apex class (InsertInbodyData_TestClass) and one of the triggers (GetInitialPBFValue) (The triggers logic is identical across all four triggers).
 
Trigger GetInitialPBFValue on Inbody__c(after insert, after update) {
    Set<Id> accountIds = new Set<Id>();

    for (Inbody__c inbdy : trigger.new) {
        accountIds.add(inbdy.Patient__c);
    }

    //Elimnate the the accounts that don't have IDs for
    accountIds.remove(null);

    //SOQL query that returns that latest weight value 
    if (!accountIds.isEmpty()) {
        List<Account> accountsToUpdate = new List<Account>();
        for (Account account : [
            Select Id,
                (
                    SELECT Test_Date_Time__c, Percent_Body_Fat__c
                    FROM Inbody__r
                    WHERE Percent_Body_Fat__c != NULL
                    ORDER by Test_Date_Time__c asc
                    Limit 1
                )
            From Account
            Where Id in :accountIds
        ]) {
           
            //Declare a decimal variable to store latest weight value 
            Decimal IPBF = NULL;
            
            // Get(0) to return the first element in the list value
            if (!account.Inbody__r.isEmpty()) {
                IPBF = account.Inbody__r.get(0).Percent_Body_Fat__c;
            }

            accountsToUpdate.add(new Account(
                Id = account.Id,
                initial_PBF_Value__c = IPBF
               
            ));
                         
        }   
        
        Update accountsToUpdate;
        
        }
      }
GetInitialPBFValue Trigger:
@isTest(SeeAllData=true)
Private class InsertInbodyData_TestClass {

    @isTest static void InsertInbody() {
        Account accnts = new Account();
        Inbody__c BIA = new Inbody__c();
        
        RecordType rt = [SELECT ID,Name FROM RecordType WHERE SobjectType='Account' and Name='Patients' Limit 1];
        
        accnts.name = 'afagas';
        accnts.RecordTypeID = rt.id;
        
        insert accnts;
        
        BIA.Skeletal_Muscle_Mass__c = 200;
        BIA.Percent_Body_Fat__c = 160;
        BIA.Test_Date_Time__c = Date.today();
        BIA.patient__c = accnts.id;
        
        insert BIA;
               
        }
        
    @isTest static void UpdateBIA() {
        Inbody__c BIA = new Inbody__c();
        BIA.id = 'a076100000HLRd3';
        BIA.weight__c = 100;
        BIA.Test_Date_Time__c = date.today();
        BIA.patient__c = '0016100000V5qTw';
        
        update BIA;   
        
        }
     
}
This issue had became a HUGE bottleneck in my development process, any input would be greatly appreciated!





 
Hi Community,
I want to set the IsConverted (=true) variable of a Lead, but it is a readonly field...

We are creating leads, opportunities, contacts and accounts via api and we want to set the lead as converted. Is there a way to do this via api? I found the LeadConvert class, but this class will merge informations and I can not disable the option to create a new opportunity.
I hope someone could help me. Thanks.
  • October 18, 2017
  • Like
  • 0
Someone could help me with the Assignment Rules triggered by Apex Code?
I am able to use the Assignment Rule using the new Case button checking the dedicated field in the Page Layout.

Here the Rule Configured

Rule Configured

I am also able to trigger the rule using the trigger on the Case on After Insert using the following Code:

public void OnAfterInsert(Case[] newCase, Map<Id, Case> newCaseMap) {
        List<Id> caseIdSet = new List<Id>();
        for(Case c : newCase) {
            caseIdSet.add(c.Id);
        }
        
        //updateOwnership(caseIdSet);
        
           List<Case> caseList = new List<Case>();
        Database.DMLOptions dmo = new Database.DMLOptions();
        dmo.AssignmentRuleHeader.useDefaultRule = true;
        
        
        for(Case c : [SELECT Id FROM Case WHERE Id IN: caseIdSet]) {
            c.setOptions(dmo);
            caseList.add(c);
        }
        update caseList;
    }

Unfortunatelly the Email Notification isn't sent when I use the trigger. Could you help me please?
If I use the following code I don't receive any email :-(

dmo.EmailHeader.triggerAutoResponseEmail = true;

Do you have any Idea?
after the winter'18 prduction upgrade no @future method are running in our org. I checked my class and testclass. I don't see the future handler in the logs. Is there anything else that I can check? 
Hey Everyone,

I created a field that displays the time zone based on the phone area code, but the issue I'm having is that area codes are displayed in the wrong time zones. For example when I enter a New York Time zone it displays "Pacific Time" although the area code is listed under eastern. Here's my code:

if( ISBLANK(Phone),"--", 



if( CONTAINS 

("206:209:213:236:250:253:310:323:341:360:369:408:415:424:425:442:458:503:509:510:520:530:541:559:563:564:604:619:626:627:628:650:657:661:669:702:707:714:747:752:760:764:775:778:805:818:831:858:867:909:916:925:935:949:951:971:", left(SUBSTITUTE( Phone , "(", ""),3)),"Pacific", 


if( 

CONTAINS("208:303:306:307:308:385:403:406:432:435:480:505:575:587:602:604:623:639:701:719:720:780:801:915:928:957:970:", left(SUBSTITUTE( Phone , "(", ""),3)),"Mountain", 


if( 

CONTAINS 

("204:205:210:214:217:218:224:225:228:251:254:256:262:270:274:281:306:308:309:312:314:316:317:318:319:320:325:327:331:334:337:361:364:402:405:409:414:417:430:431:432:447:464:469:479:501:504:507:512:515:534:557:563:573:580:601:605:606:608:612:615:618:620:630:636:639:641:651:659:660:662:682:701:708:712:713:715:730:731:737:763:779:785:806:807:812:815:816:817:830:832:847:850:870:872:901:903:913:915:918:920:931:936:938:940:952:956:972:975:979:985", left(SUBSTITUTE( Phone , "(", ""),3)),"Central", 


if( 

CONTAINS 

("201:202:207:212:215:216:219:226:227:229:231:234:239:240:242:248:249:252:260:267:269:272:276:278:280:283:289:301:302:304:305:313:315:321:330:331:336:339:343:345:347:351:352:365:380:386:401:404:407:410:412:413:416:418:419:423:434:437:438:440:443:445:475:478:484:502:508:513:514::516:517:518:519:540:551:561:567:570:571:574:579:581:582:585:586:603:606:607:609:610:613:614:616:617:631:646:647:649:667:678:679:681:689:703:704:705:706:716:717:718:724:727:732:734:740:754:757:762:765:770:772:774:781:786:802:803:804:807:810:813:814:819:828:835:843:845:848:850:856:857:859:860:862:863:864:865:873:876:878:904:905:906:908:910:912:914:917:919:927:937:941:947:954:959:973:978:980:984:989:", left(SUBSTITUTE( Phone , "(", ""),3)),"Eastern", 


if( 

CONTAINS("246:268:284:340:441:473:664:721:758:767:784:787:809:849:868:869:939",LEFT(SUBSTITUTE(Phone,"(",""),3)),"Atlantic", 

if( 

CONTAINS("684",LEFT(SUBSTITUTE(Phone,"(",""),3)),"American Samoa", 

if( 

CONTAINS("808",LEFT(SUBSTITUTE(Phone,"(",""),3)),"Hawaii", 

if( 

CONTAINS("670:671",LEFT(SUBSTITUTE(Phone,"(",""),3)),"Guam", 

if( 

CONTAINS("800:877",LEFT(SUBSTITUTE(Phone,"(",""),3)),"Toll Free","Other" 


))))))))))
Anyone every get horrendously slow performance when saving classes and pages from the Eclipse IDE back to the org? 

I'm experiencing times when it takes several minutes just to save one file.  Trying to work in a rapid development cycle is almost impossible and it's also hard not to completely lose your train of thought when debugging.

I guess I'm sort of venting here.  We did enter a support case once.  But a support case will sit for a day or two before anything happens.  And by then, the SB is back to saving in 5 or 10 seconds.  Then a week or two later, for the better part of the day, save time is back to several minutes.

I'm wondering if anyone else ever has the same issue.

I did check my network speed and have a 40ms ping, 20mbs download, and 5mbs upload.  My network is fast enought to do voice-over-IP meetings with screen sharing so you think I could upload a couple K text file in maybe a second.
Hey there

Because I want my test class to work without assuming that certain data is present in the deploy-org, I need to create some partner community users in my test class. As I haven't found any guides on how to do that and because I've failed the last time I tried I'd like to ask the developer community for council.

I think the preconditions to create a partner community user in a test class are:
  • Having an account enabled as partner
    • How to enable an account as partner via apex?
  • Having a contact attached to said account
  • Having a partner community profile
    • Necessary, because we use a custom partner community Profile
    • How to create a representation of our real partner community profile?

Thanks for your advice
Roger

Hi,

 

I have my accounts related on a way that one parent Account is pointed by its daughters with the field ParentId.

 

I need to do a trigger that when the parent account is modified in the field Recovery_actions__C(is a checkfield), this change has to go to the daughters accounts.

 

This is my trigger:

 

trigger UpdateCierrePorRecobro on Account (beforeupdate) {

 

Set<Id> addAccountsActivate = newSet<Id>();

Set<Id> addAccountsDeactivate = newSet<Id>();

 

//Aislo los id's

 

for(integer i=0;i<Trigger.new.size();i++){

//If the value has changed add to the list

if ((Trigger.new[i].Recovery_Actions__c!=Trigger.old[i].Recovery_Actions__c)) { 

if (trigger.new[i].recovery_actions__c){//changed to true

addAccountsActivate.add(Trigger.new[i].id);

}

else{//changed to false

addAccountsDeactivate.add(Trigger.new[i].id);

}

}

}

if(addAccountsActivate.size()>0){

 

//create a list of ids with the daughter ids of the main account

//????????????????????????????????????????

List<id> listaToTrue=newList<id>();

listaParaActivar.add([select id fromAccountwhereParentId in:addAccountsActivate]);

//????????????????????????????????????????????

 

Accountacc;

 

//and update the value

for(integer j=0;j<listaToTrue.size();j++){

acc.id=listaParaActivar[j];

acc.Reacovery_Actions__c=1;

updateacc;

}

}

 

}

 

 

---------------------------------------

 

I have the problem in the part where I query in order to get the ids of the daughter accounts, I dont know how to get that list of ids.

 

Anyone could help here?

 

Thanks,

Antonio