• LoneStar69
  • NEWBIE
  • 60 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 15
    Questions
  • 25
    Replies
Hi, have gone through https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines
but still couldn't understand how to resolve my coverage issue.
I have a trigger with the below apex class that works as expected. Right now it is covered 50%, all the 3 FOR loops below the system.debug statement are not covered. The debug logs show records in taskList. Can someone help me to achieve 100% test coverage for the below class?

Apex Class:
public with sharing class TriggerHelper {

public static void processBeforeDelete(List<Task> taskList) {
  processCaseTasks(taskList);
}

public static void processCaseTasks(List<Task> taskList) {

    List<CustomPermission> customPermission =[SELECT Id, DeveloperName FROM CustomPermission WHERE MasterLabel='Not Delete'];
    Id customPermId = customPermission[0].Id;
    List<SetupEntityAccess> setupEntities = [SELECT SetupEntityId FROM SetupEntityAccess
            WHERE SetupEntityId= :customPermId AND
            ParentId IN (SELECT PermissionSetId
            FROM PermissionSetAssignment
            WHERE AssigneeId = :UserInfo.getUserId())]; 
    Set<Id> caseIds = new Set<Id>();
    if(setupEntities.size()>0) {
    System.Debug('----My taskList---'+taskList);  
      for(Task tsk :taskList) {
            if(tsk.WhatId.getSObjectType() == Case.sObjectType) {
            caseIds.add(tsk.WhatId);
        }
      }
    Map<Id, String> recordTypeNames = new Map<Id, String>();
      for (Case c : [SELECT Id, RecordType.Name FROM Case WHERE Id =: caseIds]) {
         if(c.RecordType.Name=='DH') {
           recordTypeNames.put(c.Id, c.RecordType.Name);
         }
      }
      for(Task tsk : taskList) {
        if(recordTypeNames.containsKey(tsk.WhatId)) {
            tsk.addError(Label.Case_Task_Delete_Error_Message);
        }
      }
    }
}
}
Test Class:
@isTest 
public class TriggerHelper_Test {
public static final String DEMO_USER_ALIAS = 'demoUser';
@testSetup static void setupTestData() { 

    Map<String,String> userDataToBeInserted = new Map<String,String>();  
    userDataToBeInserted.put('FirstName','DEMO');
    userDataToBeInserted.put('LastName','OL User');
    userDataToBeInserted.put('Alias','demoUser');  
    User demoUser = TestUtility.createTestUser(userDataToBeInserted,true);

    List<User> userList = new List<User>{demoUser};
    TestUtility.assignPermissionSets(userList,true);
}

@isTest static void testDeletionforDHCase() {

    List<Task> taskList = new List<Task>();
    User demoUser = [select Id,Alias from User where Alias=:DEMO_USER_ALIAS];
    System.assertEquals(true,demoUser.Id!=null);

    Id DHRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('DH').getRecordTypeId();
    System.assertEquals(true,DHRecordTypeId!=null);

    Case DHCase = TestUtility.createTestCase(DHRecordTypeId,true);
    System.assertEquals(true,DHCase.Id!=null);

    Task testTask = TestUtility.createTestTask(DHCase.Id,demoUser.Id,true);
   System.assertEquals(true,testTask.Id!=null);
    taskList.add(testTask);

    System.runAs(demoUser) {
        Task testTask1 = [select Id from Task where OwnerId=:demoUser.Id LIMIT 1];
        try {
            delete testTask1;
        }catch(Exception e) {
            System.assertEquals(true, e.getMessage().contains(Label.Case_Task_Delete_Error_Message));
        }
    }

    Id nondhRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('NONDH').getRecordTypeId();
    System.assertEquals(true,nondhRecordTypeId!=null);

    Case NONDHCase = TestUtility.createTestCase(nondhRecordTypeId,true);
    System.assertEquals(true,nondhCase.Id!=null);

    Task testTask2 = TestUtility.createTestTask(nondhCase.Id,demoUser.Id,true);
    System.assertEquals(true,testTask2.Id!=null); 
    taskList.add(testTask2);

    System.runAs(demoUser) {
    Task testTask1 = [select Id from Task where whatId=:nondhCase.Id LIMIT 1];
    delete testTask1;
    }        

} 
}



 
Guys, we have a survey page built from visualforce hosted on a force.com site that allows users to submit surveys, survey URL is included as a link in the final response template which is sent out on case closure.
In Salesforce, i created master-detail between Case and Survey object. Now my question is how to relate the submitted surveys to the case? Is this possible?
Guys, i have a onclick javascript button that validates fields, uses different templates based on field values.

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var ca = new sforce.SObject("Case");
var p = "{!Case.Cons__c}";
var email = "{!Case.Cons_Email__c}";
var email2 = "{!Case.Cons_2_Email__c}";
var email3 = "{!Case.Cons_3_Email__c}";
var flc = "{!Case.Topic__c}";

if((email =="")&&(email2 =="")&&(email3 ==""))
{
alert("Please select cons and make sure cons has email address ");
}
else if(flc == ""){
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00X60000004dTuo&p26=cons@gmail.com');
}
else if(flc == "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEP&p26=cons@gmail.com');
}
else if(flc != "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEt&p26=cons@gmail.com');
}

How to make this button work on lightning, can someone please share the code, thank you.
Guys,

We have a custom field on case obj called email address.
I want to show the list of cases that have same email address on a case record.

Something like,

A related list on the case record that shows the list of cases(previous inquiries) that are from same email address.

Right now enhanced lookup is not available on the case object,  and also
we dont want to create contacts from these cases.

I couldn't get started on this.

Are there any other ways to do this other than using apex?
If not, how to code this via apex?

Appreciate your help!
Hello Friends,

This might be very simple but unable to get this done!
I have a series of radio buttons on a vf page like this

User-added image

I want text to show up below each radio button. Something like this -
User-added image
Appreciate your help!
Hi Guys,

I have a requirement to show the markup of the href only and to exclude the rest.

For Instance:

<html><body>
<p>This is Paragraph One</p>
<a href="http://www.google.com">This is Google:</a>
<p>This is Paragraph Two</p>
<a href="http://www.yahoo.com">This is Yahoo:</a>
<p>This is Paragraph Three</p>
<a href="http://www.youtube.com">This is YouTube:</a>
</body></html>

Desired output -

<a href="http://www.google.com">This is Google:</a>
<a href="http://www.yahoo.com">This is Yahoo:</a>
<a href="http://www.youtube.com">This is YouTube:</a>

My Code so far -

trigger HtmlBody on EmailMessage (after insert) {

    Set<ID> sid = new Set<ID>();
    
    List<EmailMessage> LEm = new List<EmailMessage>([Select ParentId, HtmlBody from EmailMessage WHERE ParentId = 'SPECIFIC CASE ID' ]);
    
    for(EmailMessage em :LEm ){
        
        if(em.HtmlBody.contains('href')){
            
            sid.add(em.ParentId);
        }
    }

    List<Case> cs =[select id, hrefinfo__c from Case where id IN :sid];
    for(Case c: cs){
        c.HrefInfo__c = ---------------------------------
    }
}

I want to capture the end result into a text field hrefinfo__c.

I am not sure of which string methods to use here in order the achieve the above:

Appreciate your help!
Hi Guys,

I am trying to create a custom button on list view that allows updation of selected records.

VF Page -

<apex:page standardController="Test__c" extensions="SetUpdation" sidebar="false" showHeader="false">
    <apex:form >
    
<apex:pageBlock title="Update">

        <apex:pageBlockSection columns="1">
        <apex:inputField value="{!Test__c.Situation__c}" />
</apex:pageBlockSection>
        
<apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!todo}" value="Save" status="closer"/>
        <apex:commandButton value="Cancel" action="{!cancel}" />
</apex:pageBlockButtons>
        
</apex:pageBlock>    
    
    </apex:form>
</apex:page>

Controller -

public with sharing class SetUpdation {
ApexPages.StandardController stdcontroller ;
    public SetUpdation(ApexPages.StandardController controller) {
    stdcontroller = controller;
    }

public PageReference todo(){
    
stdcontroller.save();
return (new pagereference('/apex/confirm').setredirect(true));
}
}

Now how to code this to update the selected records.
As i don't have that logic in place, it just creates a new record on Test__c when clicking save on my vf page.

Appreciate your help!
Thanks a lot.
Guys, i am trying to write a test class for a simple save method.
This might be simple, but i cannot get this correct!!!

Apex Class -

public with sharing class ExtUpdated {
ApexPages.StandardController stdcontroller ;
    public ExtUpdated(ApexPages.StandardController controller) {
    stdcontroller = controller;    }
public PageReference todo(){
stdcontroller.save();
return (new pagereference('/apex/confirm').setredirect(true));}}

Test Class -

@isTest
public class TestExtUpdated {
    static testMethod void saveNewCase() {
Case co = new Case();
        insert co;
        Test.startTest();
PageReference pageRef = Page.MyVFPage; // Add your VF page Name here
Test.setCurrentPage(pageRef);
ApexPages.StandardController sc = new ApexPages.StandardController(co);
sc.save();
Test.stopTest();
}}

No errors, but the test coverage is 0%.

Thanks for your help!!!
Guys,

I am looking to execute anonymous apex code thru ANT scripts.

Ended up with this -

<!-- Import macros --><!-- created ant-salesforce.xml using code from https://gist.github.com/afawcett/5843110 -->
<import file="C:\apache-ant-1.9.6-bin\apache-ant-1.9.6\lib\ant-salesforce.xml"/>
<target name="anonyscrpt">
<executeApex username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" rollbackOnError="true">
<![CDATA[
 <My Script goes here>
            ]]>
</executeApex>
</target>

But gives error -

[taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.
BUILD FAILED
The following error occurred while executing this line:
C:\apache-ant-1.9.6-bin\apache-ant-1.9.6\lib\ant-salesforce.xml:20: taskdef class org.missinglink.ant.task.http.HttpClientTask cannot be found
 using the classloader AntClassLoader[]

Is this the correct way?

Appreciate if somebody can outline the process of doing this.
Thanks for your help.
Hi Guys!!!

Adding code to already existing page using Cases obj.
Trying to show/hide fields using checkbox selection.
Thanks for your help!!!

<apex:pageBlockSectionItem id="SPContent">                                
                     <apex:inputField required="true"  value="{!c.SP_Topics__c}"  id="sptopics"   />
            </apex:pageBlockSectionItem>    
    
<apex:actionRegion>
    <apex:inputCheckbox value="{!c.SP_Selection__c}" id="SP" >
         <apex:actionSupport event="onchange" reRender="SPContent" status="status" />
         </apex:inputCheckbox>
     </apex:actionRegion>

     <apex:pageBlockSectionItem id="NonSPContent">
                       <apex:inputField required="true" value="{!c.Product__c}"  id="prd" />
               <apex:inputField required="true" value="{!c.Product_Type__c}"  id="ptype" />
         </apex:pageBlockSectionItem>

     <apex:actionRegion>
    <apex:inputCheckbox value="{!c.Non_SP_Selection__c}" id="NonSP" >
         <apex:actionSupport event="onchange" reRender="NonSPContent" status="status" />
         </apex:inputCheckbox>
     </apex:actionRegion>
Basically, i am trying to compare 2 lists,
if a common value exists, i need to pull another value from that common value's record in a outgoing email.

public class Search {
    public static void Compare(){
Map<String, Case> ex1 = new Map<String, Case>();
Map<String, Imp__c> ex2 = new Map<String, Imp__c>();
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
String[] toAddresses = new String[] {'test@sample.com'};
    String s;
List<Case> lstCase = [SELECT Input__c FROM Case WHERE Origin = 'Web' and RecordType.DeveloperName = 'Imp'];
for(Case c : lstCase)
{
    ex1.put(c.Input__c, c);
}
List<Imp__c> mp = [SELECT actual__c FROM Imp__c WHERE actual__c != null];
for(Imp__c e : mp)
{
    ex2.put(e.actual__c, e);
}
        for(Imp__c em: mp){
        if(ex1.containsKey('em.actual__c')){
            s = em.Status__c;
            Messaging.SingleEmailMessage successmail = new Messaging.SingleEmailMessage();
    successmail.setToAddresses(toAddresses);
    successmail.setSenderDisplayName('Support');
              successmail.setSubject('Your Id is found:');
              successmail.setPlainTextBody('Your Id is with status'+s);
        mails.add(successmail);
              Messaging.sendEmail(mails);
        }        }    }    }

No errors, But doesn't seem to work.
Appreciate your time!!
Hi,

I am trying to check the incoming mail for a specific id, which will then send an email whether the id is found or not.

No errors in class.
Class -

global class ProcessIncomingEmail implements Messaging.InboundEmailHandler {
      global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
          Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
          
          String mySubject = email.subject;
      String myReply = email.fromAddress;
                   
          Id s = '35987239';
          Boolean b;
              b = mySubject.contains(s);
          List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
          if (b == true) {
              try{
              Messaging.SingleEmailMessage successmail = new Messaging.SingleEmailMessage();
              successmail.setReplyTo('myReply');
              successmail.setSenderDisplayName('Verification Update');
              successmail.setSubject('Your Id is found:');
              mails.add(successmail);
              Messaging.sendEmail(mails);
          }
          
          catch (System.QueryException e){
              System.debug('The issue is: ' + e);
          }
          }
    
          else    {
              Messaging.SingleEmailMessage failmail = new Messaging.SingleEmailMessage();
              failmail.setReplyTo('test@sample.com');
              failmail.setSenderDisplayName('Verification Update');
              failmail.setSubject('Your Id is not found:');
              mails.add(failmail);
              Messaging.sendEmail(mails);
          }
      result.success = true;
          return result;
  }
}

But gives the below error when i try to send email to the Email Service Address.
Error -

This message was created automatically by the mail system.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

>>> idverification@blah_blah_blah.cs33.apex.sandbox.salesforce.com (Undelivered):
554 The apex class ProcessIncomingEmail failed due to: System.StringException: Invalid id: 35987239

Thanks for your help!!!
Hi,

Wondering is it possible to show alphanumerics in the formula output?

IF( Hours__c < 10, Hours__c *6, Hours__c / 8)

Assuming Hours__c is 8.
So some thing like,
if true, 48 Mins
if not, 1 Day

Are there any other functions i can make use of?

Thanks.
Hi Friends,

I want to write a trigger that defaults the FROM address of outgoing email.
I have written the below code,shows no errors but, it doesn't seem to work.

trigger Validate_OnEmail on EmailMessage (before insert, before update)
    {
       Set<Id> caseIds = new Set<Id>();
       for (EmailMessage newEmail : trigger.new)
        {
            caseIds.add(newEmail.ParentID);
        }
         Map<id,Case> a = new Map<id,Case>([SELECT RecordTypeId FROM Case WHERE RecordTypeId = 'XYZ' AND id IN :caseIds]);
        for (EmailMessage newEmail:trigger.new)
        {
            if( newEmail.Incoming != true && a.containsKey(newEmail.ParentId) )
              
    {
                OrgWideEmailAddress[] oadd = [select Id from OrgWideEmailAddress where Address = 'email@sample.com'];

if ( oadd.size() > 0 ) {
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    mail.setOrgWideEmailAddressId(oadd.get(0).Id);
    
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
            }    
        }
    }

Appreciate your help!!!
 
Hi Guys,

I want to throw an error message when FROM address is not "Email@sample.com" ONLY for a particular record type.

I have written the below code, but for some reason, it evaluates for all the record types.

trigger Validate_OnEmail on EmailMessage (before insert, before update) {
    
    List<Case> cs = [SELECT RecordTypeId FROM Case WHERE RecordTypeId = '000XXX000'];
    
    for (Case cs1:cs)
{
       for (EmailMessage newEmail:trigger.new)
{

    if( newEmail.Incoming!=true && (newEmail.FromAddress!='Email@sample.com'))
 
        newEmail.addError('From:Email Address should be "Email@sample.com"');
}
    }
}
Returns no errors, but triggers for case replies of all record types.

Appreciate your help!!!
Hi, have gone through https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines
but still couldn't understand how to resolve my coverage issue.
I have a trigger with the below apex class that works as expected. Right now it is covered 50%, all the 3 FOR loops below the system.debug statement are not covered. The debug logs show records in taskList. Can someone help me to achieve 100% test coverage for the below class?

Apex Class:
public with sharing class TriggerHelper {

public static void processBeforeDelete(List<Task> taskList) {
  processCaseTasks(taskList);
}

public static void processCaseTasks(List<Task> taskList) {

    List<CustomPermission> customPermission =[SELECT Id, DeveloperName FROM CustomPermission WHERE MasterLabel='Not Delete'];
    Id customPermId = customPermission[0].Id;
    List<SetupEntityAccess> setupEntities = [SELECT SetupEntityId FROM SetupEntityAccess
            WHERE SetupEntityId= :customPermId AND
            ParentId IN (SELECT PermissionSetId
            FROM PermissionSetAssignment
            WHERE AssigneeId = :UserInfo.getUserId())]; 
    Set<Id> caseIds = new Set<Id>();
    if(setupEntities.size()>0) {
    System.Debug('----My taskList---'+taskList);  
      for(Task tsk :taskList) {
            if(tsk.WhatId.getSObjectType() == Case.sObjectType) {
            caseIds.add(tsk.WhatId);
        }
      }
    Map<Id, String> recordTypeNames = new Map<Id, String>();
      for (Case c : [SELECT Id, RecordType.Name FROM Case WHERE Id =: caseIds]) {
         if(c.RecordType.Name=='DH') {
           recordTypeNames.put(c.Id, c.RecordType.Name);
         }
      }
      for(Task tsk : taskList) {
        if(recordTypeNames.containsKey(tsk.WhatId)) {
            tsk.addError(Label.Case_Task_Delete_Error_Message);
        }
      }
    }
}
}
Test Class:
@isTest 
public class TriggerHelper_Test {
public static final String DEMO_USER_ALIAS = 'demoUser';
@testSetup static void setupTestData() { 

    Map<String,String> userDataToBeInserted = new Map<String,String>();  
    userDataToBeInserted.put('FirstName','DEMO');
    userDataToBeInserted.put('LastName','OL User');
    userDataToBeInserted.put('Alias','demoUser');  
    User demoUser = TestUtility.createTestUser(userDataToBeInserted,true);

    List<User> userList = new List<User>{demoUser};
    TestUtility.assignPermissionSets(userList,true);
}

@isTest static void testDeletionforDHCase() {

    List<Task> taskList = new List<Task>();
    User demoUser = [select Id,Alias from User where Alias=:DEMO_USER_ALIAS];
    System.assertEquals(true,demoUser.Id!=null);

    Id DHRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('DH').getRecordTypeId();
    System.assertEquals(true,DHRecordTypeId!=null);

    Case DHCase = TestUtility.createTestCase(DHRecordTypeId,true);
    System.assertEquals(true,DHCase.Id!=null);

    Task testTask = TestUtility.createTestTask(DHCase.Id,demoUser.Id,true);
   System.assertEquals(true,testTask.Id!=null);
    taskList.add(testTask);

    System.runAs(demoUser) {
        Task testTask1 = [select Id from Task where OwnerId=:demoUser.Id LIMIT 1];
        try {
            delete testTask1;
        }catch(Exception e) {
            System.assertEquals(true, e.getMessage().contains(Label.Case_Task_Delete_Error_Message));
        }
    }

    Id nondhRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('NONDH').getRecordTypeId();
    System.assertEquals(true,nondhRecordTypeId!=null);

    Case NONDHCase = TestUtility.createTestCase(nondhRecordTypeId,true);
    System.assertEquals(true,nondhCase.Id!=null);

    Task testTask2 = TestUtility.createTestTask(nondhCase.Id,demoUser.Id,true);
    System.assertEquals(true,testTask2.Id!=null); 
    taskList.add(testTask2);

    System.runAs(demoUser) {
    Task testTask1 = [select Id from Task where whatId=:nondhCase.Id LIMIT 1];
    delete testTask1;
    }        

} 
}



 
Guys, we have a survey page built from visualforce hosted on a force.com site that allows users to submit surveys, survey URL is included as a link in the final response template which is sent out on case closure.
In Salesforce, i created master-detail between Case and Survey object. Now my question is how to relate the submitted surveys to the case? Is this possible?
Guys, i have a onclick javascript button that validates fields, uses different templates based on field values.

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var ca = new sforce.SObject("Case");
var p = "{!Case.Cons__c}";
var email = "{!Case.Cons_Email__c}";
var email2 = "{!Case.Cons_2_Email__c}";
var email3 = "{!Case.Cons_3_Email__c}";
var flc = "{!Case.Topic__c}";

if((email =="")&&(email2 =="")&&(email3 ==""))
{
alert("Please select cons and make sure cons has email address ");
}
else if(flc == ""){
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00X60000004dTuo&p26=cons@gmail.com');
}
else if(flc == "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEP&p26=cons@gmail.com');
}
else if(flc != "PC-AF") {
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Case.Id}&p2_lkid={!Case.ContactId}&p24={!Case.Cons_Email__c};{!Case.Cons_2_Email__c};{!Case.Cons_3_Email__c}&template_id=00Xt0000000LxEt&p26=cons@gmail.com');
}

How to make this button work on lightning, can someone please share the code, thank you.
Hello! Thank you in advance for your assistance! I have been working on this for over 24 total changing the Controller and Component in small ways here and there to test and re-test, and I think I am going in circles at this point.

We have 8 custom Javascript buttons for our Cases - one per department. What these buttons do is allow the user to own the case with one click. It enters their name into a custom user lookup "owner" field for that department, updates their name to the standard Owner field, and updates the Status to Assigned. 

The current, working, custom JS button is:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 
var caseObj = new sforce.SObject("Case"); 
caseObj.Id = '{!Case.Id}'; 

caseObj.CST_Owner__c = '{!$User.Id}'; 
caseObj.OwnerId = '{!$User.Id}'; 
caseObj.Status = "Assigned"; 

var result = sforce.connection.update([caseObj]); 
window.location.href=window.location.href;

My Case Buttons Component is currently - this shows on the page and allows for button clicks and will sometimes throw an error and sometimes not but makes no changes:
<aura:component implements="flexipage:availableForAllPageTypes" access="global">
    <aura:attribute name="CaseObj" type="Case" />
        <lightning:button label="Own CST" onclick="{! c.owncst}"/>
</aura:component>

My Controller is currently:
({
owncst : function(component, event, helper) {
    var btnClicked = event.getSource();
    var CaseObj = component.get('v.CaseObj',true)
    component.set('v.CaseObj.Description', "true");
}})
Hello Friends,

This might be very simple but unable to get this done!
I have a series of radio buttons on a vf page like this

User-added image

I want text to show up below each radio button. Something like this -
User-added image
Appreciate your help!
I am creating a process for task that changes the record type of the task based on the assigned users profile.  Here is my process below that keeps getting the error.


User-added image












 
  • September 21, 2016
  • Like
  • 0
Hi Guys,

I am trying to create a custom button on list view that allows updation of selected records.

VF Page -

<apex:page standardController="Test__c" extensions="SetUpdation" sidebar="false" showHeader="false">
    <apex:form >
    
<apex:pageBlock title="Update">

        <apex:pageBlockSection columns="1">
        <apex:inputField value="{!Test__c.Situation__c}" />
</apex:pageBlockSection>
        
<apex:pageBlockButtons location="bottom">
        <apex:commandButton action="{!todo}" value="Save" status="closer"/>
        <apex:commandButton value="Cancel" action="{!cancel}" />
</apex:pageBlockButtons>
        
</apex:pageBlock>    
    
    </apex:form>
</apex:page>

Controller -

public with sharing class SetUpdation {
ApexPages.StandardController stdcontroller ;
    public SetUpdation(ApexPages.StandardController controller) {
    stdcontroller = controller;
    }

public PageReference todo(){
    
stdcontroller.save();
return (new pagereference('/apex/confirm').setredirect(true));
}
}

Now how to code this to update the selected records.
As i don't have that logic in place, it just creates a new record on Test__c when clicking save on my vf page.

Appreciate your help!
Thanks a lot.
Guys, i am trying to write a test class for a simple save method.
This might be simple, but i cannot get this correct!!!

Apex Class -

public with sharing class ExtUpdated {
ApexPages.StandardController stdcontroller ;
    public ExtUpdated(ApexPages.StandardController controller) {
    stdcontroller = controller;    }
public PageReference todo(){
stdcontroller.save();
return (new pagereference('/apex/confirm').setredirect(true));}}

Test Class -

@isTest
public class TestExtUpdated {
    static testMethod void saveNewCase() {
Case co = new Case();
        insert co;
        Test.startTest();
PageReference pageRef = Page.MyVFPage; // Add your VF page Name here
Test.setCurrentPage(pageRef);
ApexPages.StandardController sc = new ApexPages.StandardController(co);
sc.save();
Test.stopTest();
}}

No errors, but the test coverage is 0%.

Thanks for your help!!!
Guys,

I am looking to execute anonymous apex code thru ANT scripts.

Ended up with this -

<!-- Import macros --><!-- created ant-salesforce.xml using code from https://gist.github.com/afawcett/5843110 -->
<import file="C:\apache-ant-1.9.6-bin\apache-ant-1.9.6\lib\ant-salesforce.xml"/>
<target name="anonyscrpt">
<executeApex username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" rollbackOnError="true">
<![CDATA[
 <My Script goes here>
            ]]>
</executeApex>
</target>

But gives error -

[taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.
BUILD FAILED
The following error occurred while executing this line:
C:\apache-ant-1.9.6-bin\apache-ant-1.9.6\lib\ant-salesforce.xml:20: taskdef class org.missinglink.ant.task.http.HttpClientTask cannot be found
 using the classloader AntClassLoader[]

Is this the correct way?

Appreciate if somebody can outline the process of doing this.
Thanks for your help.
Hi Guys!!!

Adding code to already existing page using Cases obj.
Trying to show/hide fields using checkbox selection.
Thanks for your help!!!

<apex:pageBlockSectionItem id="SPContent">                                
                     <apex:inputField required="true"  value="{!c.SP_Topics__c}"  id="sptopics"   />
            </apex:pageBlockSectionItem>    
    
<apex:actionRegion>
    <apex:inputCheckbox value="{!c.SP_Selection__c}" id="SP" >
         <apex:actionSupport event="onchange" reRender="SPContent" status="status" />
         </apex:inputCheckbox>
     </apex:actionRegion>

     <apex:pageBlockSectionItem id="NonSPContent">
                       <apex:inputField required="true" value="{!c.Product__c}"  id="prd" />
               <apex:inputField required="true" value="{!c.Product_Type__c}"  id="ptype" />
         </apex:pageBlockSectionItem>

     <apex:actionRegion>
    <apex:inputCheckbox value="{!c.Non_SP_Selection__c}" id="NonSP" >
         <apex:actionSupport event="onchange" reRender="NonSPContent" status="status" />
         </apex:inputCheckbox>
     </apex:actionRegion>
Basically, i am trying to compare 2 lists,
if a common value exists, i need to pull another value from that common value's record in a outgoing email.

public class Search {
    public static void Compare(){
Map<String, Case> ex1 = new Map<String, Case>();
Map<String, Imp__c> ex2 = new Map<String, Imp__c>();
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
String[] toAddresses = new String[] {'test@sample.com'};
    String s;
List<Case> lstCase = [SELECT Input__c FROM Case WHERE Origin = 'Web' and RecordType.DeveloperName = 'Imp'];
for(Case c : lstCase)
{
    ex1.put(c.Input__c, c);
}
List<Imp__c> mp = [SELECT actual__c FROM Imp__c WHERE actual__c != null];
for(Imp__c e : mp)
{
    ex2.put(e.actual__c, e);
}
        for(Imp__c em: mp){
        if(ex1.containsKey('em.actual__c')){
            s = em.Status__c;
            Messaging.SingleEmailMessage successmail = new Messaging.SingleEmailMessage();
    successmail.setToAddresses(toAddresses);
    successmail.setSenderDisplayName('Support');
              successmail.setSubject('Your Id is found:');
              successmail.setPlainTextBody('Your Id is with status'+s);
        mails.add(successmail);
              Messaging.sendEmail(mails);
        }        }    }    }

No errors, But doesn't seem to work.
Appreciate your time!!
Hi,

I am trying to check the incoming mail for a specific id, which will then send an email whether the id is found or not.

No errors in class.
Class -

global class ProcessIncomingEmail implements Messaging.InboundEmailHandler {
      global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
          Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
          
          String mySubject = email.subject;
      String myReply = email.fromAddress;
                   
          Id s = '35987239';
          Boolean b;
              b = mySubject.contains(s);
          List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
          if (b == true) {
              try{
              Messaging.SingleEmailMessage successmail = new Messaging.SingleEmailMessage();
              successmail.setReplyTo('myReply');
              successmail.setSenderDisplayName('Verification Update');
              successmail.setSubject('Your Id is found:');
              mails.add(successmail);
              Messaging.sendEmail(mails);
          }
          
          catch (System.QueryException e){
              System.debug('The issue is: ' + e);
          }
          }
    
          else    {
              Messaging.SingleEmailMessage failmail = new Messaging.SingleEmailMessage();
              failmail.setReplyTo('test@sample.com');
              failmail.setSenderDisplayName('Verification Update');
              failmail.setSubject('Your Id is not found:');
              mails.add(failmail);
              Messaging.sendEmail(mails);
          }
      result.success = true;
          return result;
  }
}

But gives the below error when i try to send email to the Email Service Address.
Error -

This message was created automatically by the mail system.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

>>> idverification@blah_blah_blah.cs33.apex.sandbox.salesforce.com (Undelivered):
554 The apex class ProcessIncomingEmail failed due to: System.StringException: Invalid id: 35987239

Thanks for your help!!!
Hi Friends,

I want to write a trigger that defaults the FROM address of outgoing email.
I have written the below code,shows no errors but, it doesn't seem to work.

trigger Validate_OnEmail on EmailMessage (before insert, before update)
    {
       Set<Id> caseIds = new Set<Id>();
       for (EmailMessage newEmail : trigger.new)
        {
            caseIds.add(newEmail.ParentID);
        }
         Map<id,Case> a = new Map<id,Case>([SELECT RecordTypeId FROM Case WHERE RecordTypeId = 'XYZ' AND id IN :caseIds]);
        for (EmailMessage newEmail:trigger.new)
        {
            if( newEmail.Incoming != true && a.containsKey(newEmail.ParentId) )
              
    {
                OrgWideEmailAddress[] oadd = [select Id from OrgWideEmailAddress where Address = 'email@sample.com'];

if ( oadd.size() > 0 ) {
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    mail.setOrgWideEmailAddressId(oadd.get(0).Id);
    
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
            }    
        }
    }

Appreciate your help!!!
 

Hello,

I'm new in this forum and I hope to have choosen the right category where asking help.

I need to change the sharing setting of 800+ files form "Your Company" to "Private".

Is it possible without lose time doing it for each file????

thanks

Hi,

 

As part of a Project, we are in the process of identifying the

1. Number of ways to connect to an External System from Salesforce(As we need to connect to the external system, get required data from the external system and use that data in the Salesforce application) and

2. Finalizing the feasible/suitable approach of the above.

 

Can anyone please provide the different approaches of connecting Salesforce to External Systems and their feasibility in usage.

If you can give me a sample code for each of the approaches that would be of really great help for me.

 

Thanks in advance,

Sush.