• Prosenjit Sarkar 7
  • NEWBIE
  • 473 Points
  • Member since 2015
  • 4x Certified Salesforce Developer
  • Cognizant Technology Solutions


  • Chatter
    Feed
  • 14
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 14
    Questions
  • 146
    Replies
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 0012800000vRs6sAAC; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account Number is not numeric.: [AccountNumber]
I have 2 triggers calling 2 different handler classes on the same object . As part of best practise I want to call both the classes from a single trigger. I am not sure how to call them. Below are my two triggers.
 
trigger ShippingAddress on Shipping_Address__c (after delete, 
                             after insert,  
                             after undelete, 
                             after update, 
                             before delete, 
                             before insert, 
                             before update ) {
    try  
    {
        ITriggerHandler handler = new SingleTriggerHandler (
                                        new ShippingAddressTriggerHandler(),
                                        Trigger.isExecuting,
                                        Trigger.isInsert, 
                                        Trigger.isUpdate, 
                                        Trigger.isDelete, 
                                        Trigger.isBefore, 
                                        Trigger.isAfter, 
                                        Trigger.isUndelete, 
                                        Trigger.new, 
                                        Trigger.newMap, 
                                        Trigger.old, 
                                        Trigger.oldMap, 
                                        Trigger.size );
        handler.process(); 
    }
    catch (AbstractTriggerHandler.InvalidTriggerInvocationException itie)
    {
        SystemExceptionLogger.insertSystemExceptionLogEntry(
                                        itie, 
                                        'Shipping Address Application - Common Use', 
                                        'Shipping Address Trigger', 
                                        SystemExceptionLogger.EXCEPTION_LEVEL_INFO);
        
    }
    catch (Exception e)
    {
        SystemExceptionLogger.insertSystemExceptionLogEntry(
                                        e, 
                                        'Shipping Address Trigger Application - Common Use', 
                                        'Shipping Address Trigger', 
                                        SystemExceptionLogger.EXCEPTION_LEVEL_CRITICAL);
        throw e;
    }

}
Trigger 2
trigger StagingShippingAddress on Shipping_Address__c (after delete, 
                             after insert,  
                             after undelete, 
                             after update, 
                             before delete, 
                             before insert, 
                             before update ) {
    try  
    {
        ITriggerHandler handler = new SingleTriggerHandler (
                                        new StagingShippingTriggerHandler(),
                                        Trigger.isExecuting,
                                        Trigger.isInsert, 
                                        Trigger.isUpdate, 
                                        Trigger.isDelete, 
                                        Trigger.isBefore, 
                                        Trigger.isAfter, 
                                        Trigger.isUndelete, 
                                        Trigger.new, 
                                        Trigger.newMap, 
                                        Trigger.old, 
                                        Trigger.oldMap, 
                                        Trigger.size );
        handler.process(); 
    }
    catch (AbstractTriggerHandler.InvalidTriggerInvocationException itie)
    {        SystemExceptionLogger.insertSystemExceptionLogEntry(itie,'Shipping Address Application - Common Use','Shipping Address Trigger',SystemExceptionLogger.EXCEPTION_LEVEL_INFO);
        
    }
    catch (Exception e)
    {        SystemExceptionLogger.insertSystemExceptionLogEntry(e,'Shipping Address Trigger Application - Common Use','Shipping Address Trigger',SystemExceptionLogger.EXCEPTION_LEVEL_CRITICAL); throw e;
    }

}


 

Hi there,

Below is some code I have in a custom button to tick a checkbox that runs a workflow rule

It has worked for almost a year and has now jut stopped working and I don't know why.

It runs the alerts but doesn't check the faculty Trial request box anymore, any help appreciated.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Lead");
console.log("{!Lead.Faculty_Trial_test__c}");
if
("{!Lead.Faculty_Trial_test__c}" == "no")
{
alert("You can only request a Faculty Trial to SRM, Business or SAGE Video products. Plesae make sure you have added at least one of these products to the related Opportunity.");
}
if("{!Lead.Department__c}" == "")
{
alert("You must add a Department to request a Faculty Trial.");
}
if
("{!Lead.Email}" == "")
{
alert("You must add an Email to request a Faculty Trial.");
}
else
{
c.id ="{!Lead.Id}";
c.Faculty_Trial_Request__c = false;
c.Faculty_Trial_Request__c = true;
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();}
Hello,

A user has access to a public groupe, but he is not able to Add or remove memberes in that groupe, hos is it possible to give him access.

thank for suggestion.

Hi all,

I have written a code to update all the siblings records and parent records of the record getting updated. I want to use MAP in below trigger if it is possible. I want to optimize it using MAP. Can anyone please help me? Thank you so much.

 

trigger Addressflag on Address__c (After update, After Insert) {
    if(Trigger.isUpdate || Trigger.isInsert){
    List<ID> ConIds = new List<ID>();
    Boolean needsUpdate = FALSE; 
    for (Address__c Adds: trigger.new)
    {
    ConIds.add(Adds.contact__c);
    }
    system.debug('parent con ids'+ConIds);
    contact con = [select id, checkbox__c, recordTypeId from contact where Id IN :conIds];
    List<Address__c> otherAlt = new List<Address__c>([select id, contact__c, checkbox__c, contact__r.recordTypeId from Address__c where contact__c in: conIDs]);
        for (Address__c adds: trigger.new)
        {
            for (integer i=0; i < otherAlt.size(); i++)
            {
                if ((otherAlt[i].contact__c==adds.contact__c) && (otherAlt[i].id != adds.id))
                {
                     otherAlt[i].checkbox__c = FALSE;
                     con.checkbox__c=FALSE;
                     needsUpdate = TRUE;
                }
            }
        }

        if(checkrecursive.runOnce())
        {
              if (needsUpdate)
              {
                  update otherAlt;
                  update con;
              }
        }
    }
 }
Contact has master detail relationship with address. What I am trying to do is whenever the checkbox on any of the address is checked I am unchecking the same checkbox from all other siblings and parent record. I am acheving it through above trigger but I am concerned about the time when 1000s f records will get inserted at same time.
Hi All
Here is my trigger to limit a user to create only 10 cases in a month,it is half working accordingly, but i would like to put the logic in the apex class which is currently in the trigger, more over my trigger is restricting the users to create cases when they exceeded specified limit but i am seeing the first line of error 'Invalid Date' which is unexpected along with the custom error message that i have written in the trigger.
User-added image
 
Trigger LimitNoOfCases on case(Before insert){
    If (Trigger.IsInsert){
    Integer MonthNumber = Date.Today().Month();
    Integer YearNumber = Date.Today().Year();
    Integer MaxCases = Integer.valueof(System.Label.MaxCasesLimit);//configured maximum number of cases per user by creating Custom label.
    Id Xuser = UserInfo.Getuserid();
    User Usr = [select name from user where id=:userinfo.getuserid()];
    List<Case> LstCase = [select id,CreatedById,CreatedDate from case where CALENDAR_YEAR(CreatedDate) =:YearNumber and CALENDAR_MONTH(CreatedDate)=:monthnumber and CreatedById=:UserInfo.GetUserId()];
 
    If (Lstcase.Size()>=MaxCases)         
   {   
      Trigger.New[0].addError('Dear user you have exceeded the maximum number of cases allowed this month.');
   }  
     
  }
}

 
  • June 15, 2016
  • Like
  • 0
I have written a test class for apex class.i got 89% but 'for loop' is not covered represented as below screenshot.how to achieve morethan 90%?can you anybody help me where iam missing exactly.
apex class:

public with sharing class Rfleet_Financial_Informations {
    //Variable Declaration Parts
    public List < RFLEET_Account_Protocol__c > contt {get;set;}
    public List < EditableContact > myAssociatedContact {get;set;}
    public Integer editableContactNumber {get;set;}
    public Boolean refreshPage {get;set;}
    public String protocolname {get;set;}
    public String id;
    //Constructor for invoking the Records from AccountProrocol Object
    public Rfleet_Financial_Informations(ApexPages.StandardController stdCtrl) {
            id = ApexPages.currentPage().getParameters().get('id');
            myAssociatedContact = new List < EditableContact > ();
            Integer counter = 0;
            RFLEET_Protocol__c conn = [select name from RFLEET_Protocol__c where id = : id];
            protocolname = conn.name;
            contt = [select Name,Rfleet_Billing_Account__r.Name, Rfleet_Id_Alcor__c, Rfleet_Billing_Account_Type__c, Rfleet_Billing_Account__r.Rfleet_Street_Number__c, Rfleet_Billing_Account__r.Rfleet_Country__c, Rfleet_Billing_Account__r.Rfleet_Zip_Code__c, Rfleet_Billing_Account__r.Rfleet_State_Province__c, Rfleet_Billing_Account__r.Rfleet_City__c, Rfleet_Billing_Account__r.Rfleet_Street_Name__c from RFLEET_Account_Protocol__c where Rfleet_Protocol__c = : id];
            for (RFLEET_Account_Protocol__c myContact: contt) {
                myAssociatedContact.add(new EditableContact(myContact, false, counter));
                counter++;
            }
        }
        // This method is used for deleting the Row
    public void deleteRowEditAction() {
        try {
            myAssociatedContact.get(editableContactNumber).editable = false;
            delete(myAssociatedContact.get(editableContactNumber).myContact);
        } catch (Exception e) {}
        refreshPage = true;
    }
    public class EditableContact {
        public RFLEET_Account_Protocol__c myContact {get;set;}
        public Boolean editable {get;set;}
        public Integer counterNumber {get;set;}
        public EditableContact(RFLEET_Account_Protocol__c myContact, Boolean editable, Integer counterNumber) {
            this.myContact = myContact;
            this.editable = editable;
            this.counterNumber = counterNumber;
        }
    }
}

test class:
@isTest
public class Rfleet_Financial_Informations_Test {
    static testMethod void financialtest() {
    Billing_Repository__c brc = new Billing_Repository__c(Name='frest',Rfleet_City__c='cger',Rfleet_Country__c='japan',Rfleet_Zip_Code__c='7854',CurrencyIsoCode='EUR');
        Account acc = new Account(Name = 'cooluma',montant__c=0.2);
        acc.Rfleet_Id_Alcor__c=brc.id;
        acc.Rfleet_Street_Name__c ='gff';
        acc.Rfleet_Street_Number__c ='232';
        acc.Rfleet_Country__c ='fdffd';
        acc.Rfleet_City__c ='cdfdf';
        acc.Rfleet_State_Province__c ='dfdf';
        acc.Rfleet_Zip_Code__c ='dfdfnhj';
    insert acc;
        acc.Name = 'vfggf';
        update acc;

        RFLEET_Protocol__c test = new RFLEET_Protocol__c(Name = 'prabu');
        insert test;
        test.Name = 'prabu';
        update test;
        RFLEET_Account_Protocol__c myContact = new RFLEET_Account_Protocol__c(Rfleet_Billing_Account__c = acc.Id, Rfleet_Billing_Account_Type__c = 'Vehicle', Rfleet_City__c =acc.Rfleet_City__c,Rfleet_Country__c =acc.Rfleet_Country__c, Rfleet_Id_Alcor__c = acc.Rfleet_Id_Alcor__c,
            Rfleet_Protocol__c = acc.Id, Rfleet_State_Province__c =acc.Rfleet_State_Province__c , Rfleet_Street_name__c =acc.Rfleet_Street_Name__c, Rfleet_Street_number__c = acc.Rfleet_Street_Number__c, Rfleet_Zip_code__c =acc.Rfleet_Zip_Code__c);


        string name = 'ListConditionCheck';
        Boolean editable;
        Integer counternumber;

        Rfleet_Financial_Informations.editableContact wra = new Rfleet_Financial_Informations.EditableContact(mycontact, editable, counterNumber);
        test = [select id, Name from RFLEET_Protocol__c LIMIT 1];
        PageReference vfpage = Page.Rfleet_Financial_Informations;
        System.test.SetCurrentpage(vfpage);
        Apexpages.currentPage().getparameters().put('id',test.id);
        Apexpages.StandardController sc = new Apexpages.StandardController(test);
        Rfleet_Financial_Informations fintest = new Rfleet_Financial_Informations(sc);
        fintest.deleteRowEditAction();
        fintest.id = acc.Id;
    }
   
}
screenshot:
not covered in test class
 
I've written a trigger that duplicates an opportunity when we change its status to "Closed-Won." The idea is that every time we close an opportunity, we want to create a follow-up opportunity for pursuing that client again. My trigger makes a clone of the opportunity, adds some new products and schedule items, sets the status to discovery, and a couple of other minor things. As of right now, the trigger doesn't actually copy any objects associated with opportunity. Ideally, if there's a way to do this, I want to copy all of the existing Contact Roles from the closed Opp to the new one. Here's my code...let me know if you have any questions about it or need to know anything about our setup. 

​Thanks! 

trigger Create_followup on Opportunity (before update, after insert) {

Pricebook2 standardBook = [SELECT Id FROM Pricebook2 WHERE Name = :'Ambition'];//Create an instance of the standard pricebook


if(Trigger.isUpdate){


List<Opportunity> listOppor = new List<Opportunity>();
for (Opportunity o: Trigger.new){

    if (o.StageName == 'Closed Won' && o.Stage_Change__c == false && o.Is_Clone__c == false){

        Opportunity oppNew = o.clone();
        oppNew.Name = oppNew.Name  + ' - Annual ' + o.CloseDate.year();
        
        if(o.Renewal_Date__c != null){
        oppNew.Renewal_Date__c = o.Renewal_Date__c.addYears(1);
        oppNew.CloseDate = o.Renewal_Date__c.addYears(1);}
        
        oppNew.StageName = 'Discovery';
        oppNew.Probability = 25;
       
        
        
        oppNew.Pricebook2Id = standardBook.Id;//associate the standard pricebook with this opportunity
        
        oppNew.Is_Clone__c = true;
        listOppor.add(oppNew);
        o.Stage_Change__c = true;
        
}

 
}//end of for loop

   if(listOppor.size() > 0){
 insert listOppor;       
        
}

}

if(trigger.isInsert){

try{
OpportunityLineItem[] lines = new OpportunityLineItem[0];
PricebookEntry entry = [SELECT Id, UnitPrice FROM PricebookEntry WHERE Pricebook2Id = :standardBook.Id AND Product2.ProductCode = 'ENTERPRISE_ANNUAL_UPFRONT'];
List<Event> eventList = new List<Event>();
//List<Note> noteList = new List<Note>();


for(Opportunity o: Trigger.new){
if(o.Is_Clone__c == true){

//noteList.add(new Note(ParentId=o.id,Title='Matt is the Apex_God',Body='Matt is the Apex_God',isPrivate=false));

lines.add(new OpportunityLineItem(PricebookEntryId=entry.Id, OpportunityId=o.Id, UnitPrice=entry.UnitPrice, Quantity=1));

if(o.Renewal_Date__c != null){

DateTime myDateTime = o.Renewal_Date__c.addMonths(-10);
 

eventList.add(new Event(whatid=o.id,startdatetime=myDateTime,subject='Account Management Follow-Up', EndDateTime=myDateTime, IsAllDayEvent=true));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(2),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(2), IsAllDayEvent=true));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(4),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(4), IsAllDayEvent=true));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(6),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(6), IsAllDayEvent=true));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(8),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(8), IsAllDayEvent=true));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Account Management Follow-Up', EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(10),subject='Renewal',EndDateTime=myDateTime.addMonths(10), IsAllDayEvent=true));
eventList.add(new Event(whatid=o.id,startdatetime=myDateTime.addMonths(9),subject='Sales Contract Follow-Up',EndDateTime=myDateTime.addMonths(9), IsAllDayEvent=true));

}//end of if

}
}
insert lines;
insert eventList;
//insert noteList;

}
catch(Exception e){

}
}


}
I have a trigger that I created that is working fine, but when i try to deploy it to our production org, it will not allow me to and gives me a few errors on apex test classes that i know work fine. Any help as to why this trigger is making these test classes fail woud be greatly appreciated. The trigger and error information is below. Another issue is I seem to have a problem with these test classes in eclipse. Any test class that references a Case object has a red X near the case where there's a insert case with a message stating sytax error mismatched input expecting RCurly Bracket)). But these test worked fine in my older galilieo eclipse. I am using Eclipse IDE for Java Developers Version: Luna Service Release 1a (4.4.1)

Case Currency Trigger:
trigger Trigger_ChangeCaseCurrency on Case (before update) {
    Set<Id> accIds=new Set<Id>();
    for (Case cs: trigger.new){
        accIds.add(cs.AccountId);
    }
    Map<Id,Account> accMap=new Map<Id,Account>([SELECT id, OwnerId,currencyisocode,Shipping_Country__c FROM Account WHERE  Id IN :accIds]);
    for (Case cs : trigger.new){
        if(accMap.get(cs.AccountId).Shipping_Country__c == 'GBR' || accMap.get(cs.AccountId).Shipping_Country__c == 'IRL' ){
           //update currency from Account
            cs.currencyisocode=accMap.get(cs.AccountId).currencyisocode;
           //set the curreny to GBP
           cs.currencyisocode='GBP';
           cs.Reason='Other';
           
        }
    }
}

Test Classes:

Test_AssignWebCaseQueue
@isTest
private class Test_AssignWebCaseQueue {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        
        test.startTest();
        
        Account acc = new Account( Name ='Key West Services', Market_Segment__c='Finance Company', Customer_Type__c='Finance Company', Preferred_SP__c ='0017000000WitqP', Registered_for_Seminar__c=true );
      insert acc;
      
      acc.Name='Key West Services';
      acc.Market_Segment__c ='Finance Company';
      acc.Customer_Type__c='Finance Company';
      acc.Preferred_SP__c ='0017000000WitqP';
      update acc;
      
      Case cse = new Case( Status='Open', Origin='Parts Support - Web', Subject='Parts', Web_Case_Type__c='Part Support');
      insert cse;

      cse.Status = 'Open';
      cse.Origin = 'Parts Support - Web';
      cse.OwnerId='00G70000001JGIA';
      cse.Web_Case_Type__c='Part Support';
      update cse;
      
      cse.Status = 'Open';
      cse.Origin = 'Tech Support- Web';
      cse.OwnerId='00G70000001hJGH';
      cse.Web_Case_Type__c='Tech Support';
      update cse;

      test.stopTest();
    }
}

Test_CaseFileUpload
@isTest
public class Test_CaseFileUpload {

      static testMethod void testAttachments()
    {
        Case cse=new Case();
        insert cse;
        BL_CaseFileUpload controller=new BL_CaseFileUpload(new ApexPages.StandardController(cse));
 
        controller.fileName='Unit Test Attachment';
        controller.fileBody=Blob.valueOf('Unit Test Attachment Body');
        controller.uploadFile();
        
        List<Attachment> attachments=[select id, name from Attachment where parent.id=:cse.id];
        System.assertEquals(1, attachments.size());
    }
}

Test_VFController_survey_oppsmyUnitTest

@isTest
private class Test_VFController_survey_opps {

    static testMethod void myUnitTest() {
        VFController_survey_opps sv = new VFController_survey_opps();
        sv.qte1 = 'Excellent';
        sv.qte2 = 'Excellent';
        sv.qte3 = 'Excellent';
        sv.qte4 = 'Excellent';
        sv.qte5 = 'Excellent';
        sv.qte6 = 'Excellent';
        sv.qte7 = 'Excellent';
        sv.qte8 = 'Excellent';
        sv.qte9 = 'Excellent';
        sv.qte10 = 'Excellent';
        sv.qte11 = 'Excellent';
        sv.qte12 = 'Excellent';
        sv.qte13 = 'Excellent';
        sv.qte14 = 'Excellent';       
        sv.company = 'Key West Services';
        sv.Address = '10 Trotter' ;
        sv.city = 'Milford' ;
        sv.Country = 'USA,CAN,MEX';
        sv.zip = '02703' ;
        sv.state= 'MA' ;
        sv.email = 'bpoliquin@cybexintl.com' ;
        sv.Phone = '508-533-4300' ;
        sv.Comments = 'Test Commment' ;
        sv.oppId = '123456' ;
        sv.survey = true;
        sv.caseid = '123456';
        sv.getItemc();
        sv.getItems();
        sv.getItems2();
        sv.getItems3();
        sv.getItemst();
        
       
       
               
        
        // insert a case
        Case cs = new Case();
        cs.Subject = 'test';
        cs.Reason = 'test reason';
       insert cs;
        //--
        
        sv.caseid = cs.id;    
               
        
         //insert account
        Account acc = new Account();
        acc.Name = 'Lorenco';
        acc.Market_Segment__c = 'Commercial';
        acc.Customer_Type__c = 'Hospitality';
        acc.Shipping_Country__c = 'USA';  
        
        
        insert acc;           
       
        
        //insert opportunity
        Opportunity opp = new Opportunity();
        opp.Name = 'Lorenco';
        
        opp.Market_Segment__c = 'Commercial';
        opp.Customer_Type__c = 'Hospitality';
        opp.Lead_Source_Detail__c = 'Trade Show';
        opp.Direction__c = 'Incoming';
        opp.StageName= 'In Progress';
        opp.Original_Created_Date__c = date.today();
        opp.CloseDate = date.today();
        opp.Survey_Returned__c = true;
       
        opp.Id = opp.id;
        insert opp;
        
         Boolean good = True;
        System.assert(good);
    }
}



 
  • June 25, 2015
  • Like
  • 0
I have a field called "Call_Count__c" which is a number field in Contact. I want that when some one logs a call and if the Subject Category is "Call" or "Update" the Call Count field should increase by 1. for eg if value in call count field is 3 it should become 1. Please help me with a trigger for this.
I'm working on a visual force page for a mobile app

Code from Controller (summarized to relevant parts):
global with sharing class DTCI_Remote_Methods_Ctrl {   
    public String attendeeId {get; set;}         
                           
    public DTCI_Remote_Methods_Ctrl (ApexPages.StandardSetController controller) {
        attendeeId = ApexPages.currentPage().getParameters().get('attendeePageId');          
    }


 @RemoteAction
        //Get attendee specified by attendeeId
        global static List<CnP_PaaS_EVT__Event_attendee_session__c> getconfirmedAttendee(string attendeeId){
           
            List<CnP_PaaS_EVT__Event_attendee_session__c> confirmedAttendee = [SELECT Id, Name, CnP_PaaS_EVT__First_name__c, CnP_PaaS_EVT__Last_name__c                                                                                                               
                                                                       FROM CnP_PaaS_EVT__Event_attendee_session__c                                                                            
                                                                       WHERE Id = :attendeeId       
                                                                           AND DTCI_Agreement_Active__c = TRUE
                                                                       ORDER BY Name                                                                                    
                                                                      ];
            return confirmedAttendee;                                
        }

Code from VF Page (summarized):

<apex:page standardController="CnP_PaaS_EVT__Event_attendee_session__c" extensions="DTCI_Remote_Methods_Ctrl" recordSetVar="attendees"
           docType="html-5.0" standardStylesheets="false" showheader="false" sidebar="false">

<script>    
    $j=jQuery.noConflict();  
    var attendeeJsId = '{!$CurrentPage.Parameters.attendeePageId}';

   DTCI_Remote_Methods_Ctrl.getconfirmedAttendee(attendeeJsId, function(result,event){
        if(result.length === 0){
            $j("#confirmedAttendeeId").append("No results<br />");
        }else 
                              
            $j("#confirmedAttendeeId").append("<title1>" + result.Name + "has checked in</title1>" + "<br/><br/>" );                                                                                                                                                                                                                                                                                
        
                    
    }, {escape:true});

Everything works great on the page with the exception of returning the value of result.Name, it simply says 'undefined'.

I think I just need a little syntax tweak, but for the life of me can't figure it out!

assistance much appreciated, Amanda 
I have two custom objects [access.log & trans.log] who receive daily updates [New Records] from an external system. After 31 days we don't need them anymore and we would like to delete them. Both objects have a date field on the record 'Log_date__c'.

I know that you can make a job that deletes these records on a daily basis.

My question;

- How do I write a code that deletes the right records? (Log_date__c older than 31 days)
- How/where do I put in SFDC? (Apex Class or Trigger! - Both!)

Are there any who can help me progress. In which case it will be my first code in SFDC.
Hi ,

I am working on salesforce standard email sending feature, which we used to find from Send Email button of Activity History related list of a detail page. I need to do some coputation after the email has sent. So, I need to capture the send email button's event any how. Is there any way to do this ?

Thanks in advance,
Prosenjit
How to get User Information in Lightning Component or Javascript Controller ?
How can I attach a visual workflow in a Lightning Component ?

Thanks
Prosenjit
How can I attach a visual workflow in a Lightning Component ?
Hi developers,

I have not found in Lightning Component Developers Guide that how to maintain FLS and Look up  in Lightning Components. Can you please suggest some thing ?
Recently Salesforce has enabled a feature to assign supported objects to a custom queue. I need to get the names (or API) of those supported objects from a queue Id through Apex and SOQL or Meta data. Any body had idea about that ? 
Hi Developers,

I want to start an open source project using Lightning Component. Any idea about how to start an open source project in salesforce and relate it to developer forum.

P.S. - If any idea or some requiements are in your mind please share with me for the project. 
We can get REST callouts from Workbench. I want to know how to call this REST callouts from apex, with a proper simple example.
Hi, I have seen a  BLOG: Introducing Trailhead Contest 2015 in Partners.Salesforce.com. Here is the link https://partners.salesforce.com/partnerNews?id=a033000000C8In9AAF According to this I have completed data security module for June 2015. I want to know that, how can I get the information about next challane . Any body have some idea ?
 
User-added image



 
trigger updateact on Account(before update) {
 List<ID> accs=new List<ID>();
    Map<Id,Account> oldMap=Trigger.oldMap;
    Map<Id,Account> newMap=Trigger.NewMap;
   for(Id aid:oldMap.keySet())
   {
        if(oldMap.get(aid).AccountNumber!=newMap.get(aid).AccountNumberr)
        {
     accs.AccountNumber.addError(' Please contact Master Data to make this change.');
       }
    }
 
}

 
Hi,

Please give me solution for header & footer coloring for Customer portal page layout.

I have attach screen shot for better help.

Customer Portal Page

Thanks in advance,
Arvind Kumar
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Update failed. First exception on row 0 with id 0012800000vRs6sAAC; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account Number is not numeric.: [AccountNumber]
My requirement for writing a trigger is there are two picklist fields and a textarea in case.So when a the two picklist fields have particular values i have to populate the description field  with a premade text.so i am using custom metadata for this as the description can be changed however i want
the trigger i have written is:
trigger UpdateDescription on Case (before insert) {
    String objOrigine;
    String objOriginalDetail;
        for(Case obj:trigger.new){
        //Set<ID> setAccId = new Set<ID>();
        if (obj.FrCCC_Origine_Defect_Location__c!= null && obj.FrCCC_Original_detail__c!=null)
        {
        objOrigine=obj.FrCCC_Origine_Defect_Location__c;
        objOriginalDetail=obj.FrCCC_Original_detail__c;
        }
List<FrCCC_Description_Text__mdt> CM=[select FrCCC_Description_Text_1__c from FrCCC_Description_Text__mdt where FrCCC_Detail_Origine__c='objOrigine' and FrCCC_OrigineDefectLocation__c ='objOriginalDetail'];
List<FrCCC_Description_Text__mdt> CM1=[select Description_Text_2__c from FrCCC_Description_Text__mdt where FrCCC_Detail_Origine__c='objOrigine' and FrCCC_OrigineDefectLocation__c ='objOriginalDetail'];
For(case s: CM)
{
s.Description=CM.get(0);
}

}

}
Is it correct approach.Please suggest anyother approach.i am having trouble in assigning a list to string.
I've created a button with this java script:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 
sforce.apex.execute("buttonHandler","copyOLItoPP",{id:"{!Opportunity.Id}"}); 
location.reload();

but I keep getting this error whenever I try to click it:
{faultcode:'soapenv:Client; faultstring:'No such parameter id defined for operation. please check the WSDL for the service.'}
I have 2 triggers calling 2 different handler classes on the same object . As part of best practise I want to call both the classes from a single trigger. I am not sure how to call them. Below are my two triggers.
 
trigger ShippingAddress on Shipping_Address__c (after delete, 
                             after insert,  
                             after undelete, 
                             after update, 
                             before delete, 
                             before insert, 
                             before update ) {
    try  
    {
        ITriggerHandler handler = new SingleTriggerHandler (
                                        new ShippingAddressTriggerHandler(),
                                        Trigger.isExecuting,
                                        Trigger.isInsert, 
                                        Trigger.isUpdate, 
                                        Trigger.isDelete, 
                                        Trigger.isBefore, 
                                        Trigger.isAfter, 
                                        Trigger.isUndelete, 
                                        Trigger.new, 
                                        Trigger.newMap, 
                                        Trigger.old, 
                                        Trigger.oldMap, 
                                        Trigger.size );
        handler.process(); 
    }
    catch (AbstractTriggerHandler.InvalidTriggerInvocationException itie)
    {
        SystemExceptionLogger.insertSystemExceptionLogEntry(
                                        itie, 
                                        'Shipping Address Application - Common Use', 
                                        'Shipping Address Trigger', 
                                        SystemExceptionLogger.EXCEPTION_LEVEL_INFO);
        
    }
    catch (Exception e)
    {
        SystemExceptionLogger.insertSystemExceptionLogEntry(
                                        e, 
                                        'Shipping Address Trigger Application - Common Use', 
                                        'Shipping Address Trigger', 
                                        SystemExceptionLogger.EXCEPTION_LEVEL_CRITICAL);
        throw e;
    }

}
Trigger 2
trigger StagingShippingAddress on Shipping_Address__c (after delete, 
                             after insert,  
                             after undelete, 
                             after update, 
                             before delete, 
                             before insert, 
                             before update ) {
    try  
    {
        ITriggerHandler handler = new SingleTriggerHandler (
                                        new StagingShippingTriggerHandler(),
                                        Trigger.isExecuting,
                                        Trigger.isInsert, 
                                        Trigger.isUpdate, 
                                        Trigger.isDelete, 
                                        Trigger.isBefore, 
                                        Trigger.isAfter, 
                                        Trigger.isUndelete, 
                                        Trigger.new, 
                                        Trigger.newMap, 
                                        Trigger.old, 
                                        Trigger.oldMap, 
                                        Trigger.size );
        handler.process(); 
    }
    catch (AbstractTriggerHandler.InvalidTriggerInvocationException itie)
    {        SystemExceptionLogger.insertSystemExceptionLogEntry(itie,'Shipping Address Application - Common Use','Shipping Address Trigger',SystemExceptionLogger.EXCEPTION_LEVEL_INFO);
        
    }
    catch (Exception e)
    {        SystemExceptionLogger.insertSystemExceptionLogEntry(e,'Shipping Address Trigger Application - Common Use','Shipping Address Trigger',SystemExceptionLogger.EXCEPTION_LEVEL_CRITICAL); throw e;
    }

}


 
On the click of this checkbox it should bring a popup but based on a condition.


<input id="showprompt" type="checkbox" name="Name" value="Name "onclick="if({!item.name='test'),ShowPrompt(this.checked)" />

I want the correct syntax
  • April 18, 2017
  • Like
  • 0

Hi there,

Below is some code I have in a custom button to tick a checkbox that runs a workflow rule

It has worked for almost a year and has now jut stopped working and I don't know why.

It runs the alerts but doesn't check the faculty Trial request box anymore, any help appreciated.

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Lead");
console.log("{!Lead.Faculty_Trial_test__c}");
if
("{!Lead.Faculty_Trial_test__c}" == "no")
{
alert("You can only request a Faculty Trial to SRM, Business or SAGE Video products. Plesae make sure you have added at least one of these products to the related Opportunity.");
}
if("{!Lead.Department__c}" == "")
{
alert("You must add a Department to request a Faculty Trial.");
}
if
("{!Lead.Email}" == "")
{
alert("You must add an Email to request a Faculty Trial.");
}
else
{
c.id ="{!Lead.Id}";
c.Faculty_Trial_Request__c = false;
c.Faculty_Trial_Request__c = true;
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();}
Hello Developers,

I have the test class below that is receiving this error: "Line -1 Expression cannot be assigned​"

Your assistance is greatly appreciated!
@isTest
public class testClassSuccessPlan
{
    static testMethod void test()
    {      
                  
            //Create success plan record
            test.startTest();
            Success_Plan__c Success_Plan = new Success_Plan__c();
            Success_Plan__c.Name = 'Test Plan';
            Success_Plan__c.Account__c = '0015000000SsYnN';
            Success_Plan__c.Member_Success_Manager__c = '00550000006Rkqu';
            insert Success_Plan;  

            //Create initiative record
            Initiatives__c Initiative = new Initiatives__c();
            Initiatives__c.Name = 'Test Int';
            Initiatives__c.Service_Discipline__c = 'a035000000BdWzV';
            insert Initiative;           
         
          
                
            test.stopTest();
    }
}

 
Hi Expert, 

I created a contact wtih (name= "AA" ,Email="aa@gmail.com"), if i insert a new contact with same Email id (name= "BB" ,Email="aa@gmail.com") then existing record will become (name= "BB" ,Email="aa@gmail.com") and new record will be delete. I want to use  upsert method. this is my code please suggest where is mistake
 
Trigger NewContact on Contact (before insert) {
    Set<String> con = new Set<String>();
    List<Contact> cont = new  List<Contact>();
     List<Id> duplicateIds = new List<Id>();  
      Map<string, Contact> existing = new Map<string, Contact>();
    
    for (Contact c : Trigger.New) 
    {
        con.add(c.Email);
        
    }
    
   
    for(Contact c: [SELECT Id,Email,Phone,Title
                    FROM Contact
                    WHERE Email IN :con])
    {
      existing.put(c.Email, c);
    }
    
    if(existing.size()>0){
       for (Contact c : Trigger.New) 
    {
        if(existing.containsKey(c.Email)){
            duplicateIds.add(c.id);
            Contact clone = c.clone();
            clone.Id = existing.get(c.Email).Id;
            existing.put(c.Email, clone); 
        }
    }
    }
    
    try {
    update existing.values();
   Database.delete(duplicateIds);
} catch (System.DmlException e) {
   
}
    
  
}

 
Hi,

i want to fire onchange event without going out of input text box and save the values.
Onchange fucntion works whenever i enter a field value and click somewhere outside and then save.
Is there any other event to make this scenario possible?

User-added image

My code:
<b style="vertical-align:inherit">New: </b>
<apex:InputField style="height:70px;width:180px;" value="{!a.acc.Updates__c}" rendered="{!disableInput}" id="updatetext">
          <apex:actionSupport event="onchange" action="{!handleUpdateChange}" reRender="AccDMLTable">
                   <apex:param id="updval" name="updval" value="{!a.acc.ID}" assignTo="{!objSelectedStudentId1}"/>
         </apex:actionSupport>
</apex:inputField>

Thanks
Vivekh
Hi,

We have a text field which has a date of format of d-mmm-yy (22-Jun-16). Unfortunaly, we are having problem converting to Salesforce Date format (mm-dd-yyyy)

Suggestions will be highly appreciated.

Thanks!

I have set private access to Account records on my administrator profile in sharing settings section

User-added image

And for example I want to extend Account records  access with one particualr user. For this option I  chose manual sharing. and added sharing in my Administrator profile with another user as below 

User-added image

But as a result Jenifer manager still dont't see any Acoount records. 

User-added image

What the problem is? Are there any rules of sharing settings, sharing rules, object, field level security  priority execution?

 

 

Hi,
I am using Salesforce Lightning. I need to create a 'Log a Meeting' button, exactly like 'Log a Call'.

I have gone through the forums and found how to create the button in Salesforce Classic mode - following the below
Firstly, create this new custom button.
1. Navigate to Setup > App Setup > Customise > Activities > Event Buttons and Links
2. Click New
3. Type under Label 'Log a Meeting'
4. Tab once at you will see 'Log_a_Meeting' is populated under Name field
5. Leave the behaviour as 'Display in existing window with sidebar'
6. Leave the Content Source as 'URL'
7. Enter in the blank space the following:
/00T/e?who_id={!Contact.Id}&followup=1&tsk5=Meeting:Enter Activity Subject Here&retURL=%2F{!Contact.Id}
8. Click Save.

Then I added it to the page layout
Setup > App Setup > Customize > Accounts > Page Layout > Edit > Go to related list > Properties of  Related list > Buttons >

The button works - but only when in Salesforce Classic. When I swap back to lightening, I can't see it.

How do I see it in Salesforce Lightening?

User-added image
I have a field called "Call_Count__c" which is a number field in Contact. I want that when some one logs a call and if the Subject Category is "Call" or "Update" the Call Count field should increase by 1. for eg if value in call count field is 3 it should become 1. Please help me with a trigger for this.