• Prosenjit Sarkar 7
  • SMARTIE
  • 707 Points
  • Member since 2015
  • 5x Certified Salesforce Senior Developer
  • Slalom, LLC

  • Chatter
    Feed
  • 22
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 15
    Questions
  • 199
    Replies
I created a simple Apex Class and VFC to display my query results in an email template.
The only thing it displays is the correct size of the list and a blank POId . No List results.
*********************Apex Code
global class POComponent
{
global string POId
    {
    get;
    set;
    }
global integer leng
    {
    get;
    set;
    }
global List<rstk__poline__c> RSNPOLine2
    {
    get;
    set;
    }
public POComponent()
    {
    POComponentCore();
    }
public List<rstk__poline__c> POComponentCore()
    {
    POId = ApexPages.currentPage().getParameters().get('id');
    List<rstk__poline__c> RSNPOLine2  = new List<rstk__poline__c>();
    RSNPOLine2 = [SELECT rstk__poline_lne__c,rstk__poline_item__c, rstk__poline_descr__c FROM rstk__poline__c where rstk__poline_ordno__c = :POId];
     leng = RSNPOLine2.size();
    return RSNPOLine2;
    }
}
*************************VFC code:
<apex:component controller="POComponent" access="global">
<apex:attribute name="configproducts" description="DCPId" type="String" assignTo="{!POId}"/>
            <table>
            <apex:repeat var="arr" value="{!RSNPOLine2}">
                <tr>
                    <td style="width: 010mm;   height: 004mm;">Just a test inside VFC</td>
                    <td style="width: 025mm;   height: 004mm;">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden;">{!arr.rstk__poline_descr__c}</div>
                    </td>
                    <td style="width: 067mm; height: 004mm; ">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden;">{!arr.rstk__poline_item__c}</div>
                    </td>
                    <td style="width: 010mm;   height: 004mm;">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden; text-align: right;">{!arr.rstk__poline_lne__c}</div>
                    </td>
                    <td style="width: 010mm;   height: 004mm; ">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden; text-align: left; margin-left: 1mm;">CCCCC</div>
                    </td>
                    <td style="width: 025mm;   height: 004mm;">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden; text-align: right;">1111.99</div>
                    </td>
                </tr>
             </apex:repeat>
            </table>
                <table>
                <tr><td>This is outside the repeat loop, list size = {!leng} and POId is {!POId}</td></tr></table>
</apex:component>
******************Email Template code:
<messaging:emailTemplate subject="Purchase Order" recipientType="User" relatedToType="rstk__PO_Print_Header__c">
<messaging:htmlEmailBody >
<html>
<head>
<style type="text/css" media="print">
 @page {
     size:A4;
     margin-left: 0.8cm;
     margin-right: 0.8cm;
     margin-top: 12.0cm;
     margin-bottom: 4.5cm;
     @top-center {
           content: element(header);
       }
     @bottom-left {
           content: element(footer);
       }
}
 </style>
 </head>
 <body>
        <c:POComponent configproducts="{!relatedTo.Id}"/>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Hi, Please let me know how to cover EmailMessaging class in below code:

Class:
global class UpdateLastWorkedDate_onContactBatch implements Database.Batchable<sObject>, Schedulable {
     public EmailTemplate et{get;set;}
      
    global DataBase.QueryLocator start(Database.BatchableContext bc){
                       system.debug('>>>>');

        return DataBase.getQueryLocator([select id,owner.email,TR1__Candidate_Status__c,Last_Day_Worked__c,TRSCHED__Compliance_Owner__r.email from contact where Last_Day_Worked__c!=null]);
        }
    global void execute(Database.BatchableContext BC, List<contact> scope)
       {
                      system.debug('>>>>');

       list<contact> conlist=new list<contact>();
       et=[select id,Name FROM EmailTemplate where Name='3monthsgap' Limit 1];
       list<string> to=new list<string>();
       List<Messaging.SingleEmailMessage> mailsList = new List<Messaging.SingleEmailMessage>();

       for(contact c:scope){
               system.debug('>>>>');

        integer i;
        //i=system.today().monthsBetween(c.Last_Day_Worked__c);
        i=c.Last_Day_Worked__c.monthsBetween(system.today());

        system.debug('>>>>'+i);
        if(i==3){
        c.TR1__Candidate_Status__c='InActive';
        conlist.add(c);
        }
        if(i==2)
        {
                       system.debug('>>>>');

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
               to.add(c.owner.email);
                 to.add(c.TRSCHED__Compliance_Owner__r.email);

                 mail.setTargetObjectId(c.id);
                 mail.setSaveAsActivity(false);
                 mail.setTreatTargetObjectAsRecipient(false);
                 mail.setTemplateId(et.id);
                 //mail.setWhatId(AQ.id);
                 mail.setToAddresses(to);
          mailsList.add(mail);
        
        }
       }
      if(conlist.Size()>0){

       update conlist;
       }
        if(mailsList.Size()>0){
                       system.debug('>>>>');

            Messaging.sendEmail(mailsList);
            }  
       
       }   
    
    global void finish(Database.BatchableContext BC){
        }
       global void execute(SchedulableContext sc) {
        UpdateLastWorkedDate_onContactBatch b1 = new UpdateLastWorkedDate_onContactBatch();
        ID batchprocessid = Database.executeBatch(b1,200);    
    }
    
}

Test class: 59% coverage

@isTest
public class Test_UpdateLastWorkedDate_onContactBatch {
public static testMethod void test() 
     {
   /*   Profile p = [SELECT Id FROM Profile WHERE Name='system administrator'];
         
    User us = new User(Alias='Admin',Email='test@gamil.com',LastName='Testing',Username='standardus@testorg.com',LanguageLocaleKey='en_US',LocaleSidKey='en_US',ProfileId = p.Id, 
           TimeZoneSidKey='America/Los_Angeles',EmailEncodingKey='UTF-8');
    insert us;*/
   User us = [Select id from User where Id = :UserInfo.getUserId()];
         
    Account acc = new Account(Name = 'test13');
    insert acc;
    
    Contact con = new Contact(LastName = 'One', Last_Day_Worked__c=system.today().adddays(-90), Email ='test.user@gmail.com',  TR1__Candidate_Status__c ='DNU', TRSCHED__Compliance_Owner__c=us.id,  AccountId=acc.id);
    insert con;
         
 //     EmailTemplate eT = new EmailTemplate (developerName = 'X3monthsgap', subject='test', FolderId = UserInfo.getUserId(), TemplateType= 'Text', Name = '3monthsgap'); 
     //    insert eT;
   System.runAs(us)
   {
   Test.startTest();
     UpdateLastWorkedDate_onContactBatch obj = new UpdateLastWorkedDate_onContactBatch();
     DataBase.executeBatch(obj); 
         
   Test.stopTest();
   }  
    }
    
}

Below code not covered:

 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
               to.add(c.owner.email);
                 to.add(c.TRSCHED__Compliance_Owner__r.email);

                 mail.setTargetObjectId(c.id);
                 mail.setSaveAsActivity(false);
                 mail.setTreatTargetObjectAsRecipient(false);
                 mail.setTemplateId(et.id);
                 //mail.setWhatId(AQ.id);
                 mail.setToAddresses(to);
          mailsList.add(mail);
       
 global void execute(SchedulableContext sc) {
        UpdateLastWorkedDate_onContactBatch b1 = new UpdateLastWorkedDate_onContactBatch();
        ID batchprocessid = Database.executeBatch(b1,200);    
    
Thanks
@isTest
private class tprotest {


     @isTest static void testCallout() {   
                          
           Account acc = new Account(name = 'test', ia_crm__Sync_With_Intacct__c = true ,ia_crm__IntacctID__c = 'C111',Phone = '33333344444', 
 billingstreet = '4th avenue', billingcity = 'tampa',billingstate = 'FL',  billingcountry = 'United States', BillingPostalCode = '11001', Description = 'javascript :: null');
 insert acc;

          Opportunity op = new Opportunity(
          Name = 'Prasadam',                       
          Accountid = acc.id,                      
          IsPrivate = false,                       
          Amount = 1000.00,
          StageName = 'Contract Signed',                
          CloseDate = Date.parse('09/09/2019'),  
          Probability = 100  ,      
          Card_Holder_s_Name__c =   'rajni bala',
          Credit_Card_Number__c = '5446886522351236',
         Credit_Card_Expiration_Date__c = '07/2019',    
          Routing_Number__c = '123556985',
          Accounting_Number__c = '445669',
          TPro_Success__c = 'true',
          TPro_AuthID__c = null,
          TPro_CC_StoredAccountID__c = null,
          Billing_First_Name__c = 'Anna',
          Billing_Last_Name__c ='Jordan',
          Billing_Contact_Email__c = 'anna@jumpcrew.com'
        //  test__c = 'C111'
          );
          
         insert op;


         
    }                  
            //op.Routing_Number__c = '552236996';
           // op.Credit_Card_Number__c= '5546886522351236';
          //  op.Account.Name = 'testacc';
    
 
                // Set mock callout class 
                  
   @isTest static void testCalloutt(){
   
   Opportunity opp = [Select Id, Name FROM Opportunity WHERE Name = 'Prasadam' Limit 1];
      
   Test.setMock(HttpCalloutMock.class, new MocktProOpportunity()); 
   
                 Test.startTest();
               new tproOpportunityTriggerHandler().sendCardToTPro(opp);
               tproOpportunityTriggerHandler.send(opp.Id);             
            
                Test.stopTest(); 
                opp = [SELECT Id,Accountid, Card_Holder_s_Name__c,Credit_Card_Number__c,Credit_Card_Expiration_Date__c,Account.ia_crm__IntacctID__c,  Account.Name, test__c,Billing_Contact_Email__c,
              Event_Code__c,Routing_Number__c,Accounting_Number__c,TPro_Success__c,TPro_AuthID__c,StageName ,TPro_CC_StoredAccountID__c
             FROM Opportunity where id =: opp.Id];
             
             System.assertEquals('Prasadam', opp.Name ); 
             System.assertEquals('Contract Signed', opp.StageName ); 
             
           
 
}
      
}
Problem is here...   Opportunity opp = [Select Id, Name FROM Opportunity WHERE Name = 'Prasadam' Limit 1];

2nd problem is : System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Hi All
Anyone give any idea regarding on sorting the wrapper list.
I have combined task and event into a single list using the wrapper class. Using the list I am showing the information to the VF page. But I want to show the result descending order so that I want to sort the list.

Please, anyone, give an idea to resolve the issue.
Hi,

I am new to APEX and have modified a trigger to fit my needs, but don't know how to properly modify the test class.  Could someone please help?

APEX Trigger:
trigger JIRATrigger on JIRA__c (after insert, after update) {
    for (JIRA__c j : Trigger.new) {
        if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Arkham' && j.Issue_Type__c == 'Bug') {
            JCFS.API.createJiraIssue('10103', '10103');
        }
        if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Arkham' && j.Issue_Type__c == 'Story') {
            JCFS.API.createJiraIssue('10103', '10100');
        }
        if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Arkham' && j.Issue_Type__c == 'Epic') {
            JCFS.API.createJiraIssue('10103', '10000');
        }
        if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Harvey' && j.Issue_Type__c == 'Bug') {
            JCFS.API.createJiraIssue('10300', '10103');
        }
        if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Harvey' && j.Issue_Type__c == 'Story') {
            JCFS.API.createJiraIssue('10300', '10100');
        }
        if (Trigger.isInsert && Trigger.isAfter && j.Project__c == 'Harvey' && j.Issue_Type__c == 'Epic') {
            JCFS.API.createJiraIssue('10300', '10000');
        }
        if (Trigger.isUpdate && Trigger.isAfter) {
            JCFS.API.pushUpdatesToJira();
        }
    }
}

Current APEX Class: (0% code coverage)
@isTest public class JIRATriggerTest {
    @isTest static void caseAfterInsertTest() {
        JCFS.JiraTriggerTestHelper.testAfterInsert('JIRA__c');
    }
    @isTest static void caseAfterUpdateTest() {
        JCFS.JiraTriggerTestHelper.testAfterUpdate('JIRA__c');
    }
}

 
public class EC_CaseDetailController {
public String currentRecordId {get;set;}
public String parameterValue {get;set;}
public Case ca{get;set;} 
    public EC_CaseDetailController(ApexPages.StandardController controller) {
        currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        ca = [select Casenumber,
              PRX_Entity__c,
              PRX_Type_of_request__c,
              Status, 
              CreatedDate,
              ClosedDate,
              PRX_Number_of_requests__c,
              PRX_Partner_Customer_name__c,
              ContactEmail,
              PRX_Name__c,
              PRX_Free_text_field__c,
              PRX_Mobile_number__c from Case where id =: currentRecordId ];
        parameterValue = ApexPages.CurrentPage().getparameters().get('nameParam');
    }
Hi all,

I have below code. I want to show error on VF page when particular condition not met and records not found.I have added my code in try catch block and added apex:messages as well.
Please suggest me what is wrong.
The error should be displayed when combination of service family and sub service category is not found in database.
 
Class:


public with sharing class SurveyClass{

Public Account acc{get;set;}
Public Proposal_Form__c pfc;
Public Proposal_Form__c pfc1 {get;set;}
public ProposalFields__c pf {get;set;}
public List<String> fieldSet {get;set;}
Public ID rid;
private ApexPages.StandardController standardController;
    
public SurveyClass(ApexPages.StandardController controller) {
    this.standardController = standardController;
    pfc1 = new Proposal_Form__c();
  }

public void Selected(){
    system.debug(pfc1.Service_Family__c +'------------'+pfc1.Sub_Service_Category__c);
    
    try{
        pfc = [SELECT Fields_Associated__c FROM Proposal_Form__c where Service_Family__c =: pfc1.Service_Family__c and Sub_Service_Category__c =: pfc1.Sub_Service_Category__c LIMIT 1];
        
    } catch(Exception ex){
     ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'No such combination exists');
     ApexPages.addMessage(myMsg);
      
    }
     
    fieldSet = new List<String>();
    List<String> fields = new List<String>();
    if(pfc.Fields_Associated__c != null && pfc.Fields_Associated__c != ''){
        fields = String.valueof(pfc.Fields_Associated__c).split(',');
        system.debug('*********Fields******'+fields);
    }
    else{
        Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,''+'No questions to Display"'));
    
    }
    Map<String,String> labelMap = new Map<String,String>();
    labelMap = getLabel.retLabelMap('ProposalFields__c');
    system.debug(labelMap);
    system.debug(labelMap);
    for(String s : fields){
        fieldSet.add(labelMap.get(s));
        system.debug('********fieldset*******'+fieldSet);
    }
    
}
}


VF Page:;


<apex:page standardController="Account" extensions="SurveyClass" sidebar="false" showHeader="false" tabStyle="Account">

<apex:form >
<apex:pageMessages rendered="true"/>
<apex:pageBlock title="Client Survey Form"> 
<apex:pageBlockSection title="Service Requirements" >

<apex:inputField value="{!pfc1.Service_Family__c}"/>
 
<apex:pageblocksectionItem >
    <apex:outputLabel value="Sub Service Category"/>
    <apex:outputPanel >
        
            <apex:inputfield value="{!pfc1.Sub_Service_Category__c}">
                <apex:actionSupport event="onchange" action="{!Selected}" rerender="fieldst" />
                <apex:pageMessages rendered="true"/>
            </apex:inputField>
       
    </apex:outputPanel>
</apex:pageblocksectionItem>
</apex:pageBlockSection> 

<apex:pageblockSection title="Question Set" id="fieldst">
    <apex:repeat value="{!fieldSet}" var="f">
      <apex:inputField value="{!pf[f]}"/> 
    </apex:repeat>
</apex:pageblockSection>

<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Submit" action="{!Save}"/>
</apex:pageBlockButtons>



</apex:pageBlock>
</apex:form> 
</apex:page>


 
Hi, on my account object, I created a picklist field - testPicklist1__c. The picklist field has various values in it. One picklist value is "abc t" & its API name is "abc". I retrieved the Account object using ANT & tried to deploy to another Salesforce org using ANT. I got the below error message -:
User-added image
Error Message says -:  "Picklist value: abc t in picklist: testPicklist1__c not found". 

When I viewed the Account.object file I found that under "testPicklist1" field definition, the picklist value is shown with full name "abc" like this <fullName>abc</fullName> as shown below -:    
<fields>
        <fullName>testPicklist1__c</fullName>
        <externalId>false</externalId>
        <label>testPicklist1</label>
        <picklist>
            <picklistValues>
                <fullName>abc</fullName>
                <default>false</default>
            </picklistValues>  
        </picklist>
</fields>

Wheras in "AOC" record type definition under the enabled picklist value, this picklist is being referenced using "abc t" as the full name like this <fullName>abc t</fullName> as shown below -:
<recordTypes>
        <fullName>AOC</fullName>
        <active>true</active>
        <label>AOC</label>
       <picklistValues>
            <picklist>testPicklist1__c</picklist>
            <values>
                <fullName>abc t</fullName>
                <default>false</default>
            </values>
     </picklistValues>
</recordTypes>
Is this what causing the above error ? How can I remove this error & deploy successfully without manually doing changes ? Thanks in advance. 
 
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.
  • June 24, 2016
  • Like
  • 0

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 
Hi developers, 

I need to extract a list of users who have attached some files to a record in which they have only read only permission. This query need to search across all objects in an org. Also, I need to find the record Ids of those files. 

is there any way to do that ?

Thanks in advance,
Prosenjit
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 ?
 
Hi All,

how to write a Trigger after insert the account Records create Task and send email .


Thanks
akkk
  • January 29, 2021
  • Like
  • 0
I am trying to display records grouped by Module custom field in standard Contact object using Salesforce LWC. There are records displaying so far, but only Module and Name values are visible. Been trying to display also Email and Phone values, but unfortunately only the headers are visible.I have already tried searching for same scenarios and modified codes many times but still haven't had any progress with it,

Meanwhile, here's what I achieved:

contactLWC.html
<template>

    <table class="slds-table slds-table_cell-buffer slds-table_bordered ">
     <thead>
      <tr class="slds-line-height_reset">
       <th class="" scope="col">
        <div class="slds-truncate" title="contactModule">Module</div>
       </th>
       <th class="" scope="col">
        <div class="slds-truncate" title="contactName">Name</div>
       </th>
       <th class="" scope="col">
        <div class="slds-truncate" title="contactEmail">Email</div>
       </th>
       <th class="" scope="col">
        <div class="slds-truncate" title="contactPhone">Phone</div>
       </th>
      </tr>
     </thead>
     <tbody>
      <template if:true={mapData}>
       <template for:each={mapData} for:item="keyValue">
        <tr key={keyValue.key} class="slds-hint-parent">
            <th scope="col">
                <div>{keyValue.key}</div>
            </th>
            <template for:each={keyValue.value} for:item="value">
                <div key={value.Name}>
                    {value.Name}
                </div> 
                <div key={value.Email}>
                    {value.Email}
                </div> 
                <div key={value.Phone}>
                    {value.Phone}
                </div> 
            </template>
        </tr>      
       </template>
      </template>
     </tbody>
    </table>
</template>
contactLWC.js
 
import { LightningElement, track, wire } from 'lwc';

import getDataFromApex from '@salesforce/apex/ContactController.getData';

export default class contactLWC extends LightningElement {

    @track mapData = [];

    @wire(getDataFromApex) 
    wiredcontactdata({ data, error }) {
        if (data) {
            for(let key in data) {

                if (data.hasOwnProperty(key)) { 
                    this.mapData.push({key: key, value: data[key]});
                }
            }
        } else if (error) {
            window.console.log(error);
        }
    }

}
ContactController.cls
 
public class ContactController{

    @AuraEnabled(cacheable=true)

    public static Map<String, List<ContactWrapper>> getData()
    {

     Map<String, List<ContactWrapper>> mapModule = new Map<String, List<ContactWrapper>>();
     Map<String, Integer> moduleCountMap = new Map<String, Integer>();

     List<Contact> contactList = [SELECT Name, Email, Phone, Module__c 
            FROM Contact 
            WHERE Module__c != null 
            ORDER BY Module__c];

     for(Contact contObj:contactList)
     {
      List<ContactWrapper> conWrapperList = new List<ContactWrapper>();

      if(mapModule.containsKey(contObj.Module__c))
      {

       conWrapperList = mapModule.get(contObj.Module__c);


       conWrapperList.add(new ContactWrapper(contObj));

       mapModule.put(contObj.Module__c, conWrapperList);


       moduleCountMap.put(contObj.Module__c, conWrapperList.size());
      }
      else
      {

       conWrapperList.add(new ContactWrapper(contObj));
       mapModule.put(contObj.Module__c, conWrapperList);


       moduleCountMap.put(contObj.Module__c, conWrapperList.size());
      }
     }

     return mapProjectType;

    }

    public Class ContactWrapper {

     public ContactWrapper(Contact contObj)
     {
      this.Name = contObj.Name;
      this.Email = contObj.Email;
      this.Phone = contObj.Phone;
      this.Module = contObj.Module__c;
     }

     @AuraEnabled
     public String Name {get;set;}
     @AuraEnabled
     public String Email {get;set;}
     @AuraEnabled
     public String Phone {get;set;}
     @AuraEnabled
     public String Module {get;set;}
    }


   }
Hoping someone could help me on this, and thanks in advance!
 
Hi,
I have a custom vf page, 
I have used this component in the page 
 
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
                    hideOnEdit="editButton" event="ondblclick"
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
This is the output
InlineEdit

Why am I not able to Edit If there is No data in for that particular field?
I created a simple Apex Class and VFC to display my query results in an email template.
The only thing it displays is the correct size of the list and a blank POId . No List results.
*********************Apex Code
global class POComponent
{
global string POId
    {
    get;
    set;
    }
global integer leng
    {
    get;
    set;
    }
global List<rstk__poline__c> RSNPOLine2
    {
    get;
    set;
    }
public POComponent()
    {
    POComponentCore();
    }
public List<rstk__poline__c> POComponentCore()
    {
    POId = ApexPages.currentPage().getParameters().get('id');
    List<rstk__poline__c> RSNPOLine2  = new List<rstk__poline__c>();
    RSNPOLine2 = [SELECT rstk__poline_lne__c,rstk__poline_item__c, rstk__poline_descr__c FROM rstk__poline__c where rstk__poline_ordno__c = :POId];
     leng = RSNPOLine2.size();
    return RSNPOLine2;
    }
}
*************************VFC code:
<apex:component controller="POComponent" access="global">
<apex:attribute name="configproducts" description="DCPId" type="String" assignTo="{!POId}"/>
            <table>
            <apex:repeat var="arr" value="{!RSNPOLine2}">
                <tr>
                    <td style="width: 010mm;   height: 004mm;">Just a test inside VFC</td>
                    <td style="width: 025mm;   height: 004mm;">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden;">{!arr.rstk__poline_descr__c}</div>
                    </td>
                    <td style="width: 067mm; height: 004mm; ">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden;">{!arr.rstk__poline_item__c}</div>
                    </td>
                    <td style="width: 010mm;   height: 004mm;">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden; text-align: right;">{!arr.rstk__poline_lne__c}</div>
                    </td>
                    <td style="width: 010mm;   height: 004mm; ">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden; text-align: left; margin-left: 1mm;">CCCCC</div>
                    </td>
                    <td style="width: 025mm;   height: 004mm;">
                        <div style="width: 100%; max-width:100%; white-space: nowrap; overflow: hidden; text-align: right;">1111.99</div>
                    </td>
                </tr>
             </apex:repeat>
            </table>
                <table>
                <tr><td>This is outside the repeat loop, list size = {!leng} and POId is {!POId}</td></tr></table>
</apex:component>
******************Email Template code:
<messaging:emailTemplate subject="Purchase Order" recipientType="User" relatedToType="rstk__PO_Print_Header__c">
<messaging:htmlEmailBody >
<html>
<head>
<style type="text/css" media="print">
 @page {
     size:A4;
     margin-left: 0.8cm;
     margin-right: 0.8cm;
     margin-top: 12.0cm;
     margin-bottom: 4.5cm;
     @top-center {
           content: element(header);
       }
     @bottom-left {
           content: element(footer);
       }
}
 </style>
 </head>
 <body>
        <c:POComponent configproducts="{!relatedTo.Id}"/>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Hi everyOne,

I have written first actionfunction code but it not calling to that scipt method as it supose to do so can anyone help me out withthis

This is my controller 
public class wrapperWithRadioButtonCtrl {
    List<Account> acc{get;set;}
    Public Integer records{get;set;}
    public String passedValue{get;set;}
    public wrapperWithRadioButtonCtrl(){
        acc = [select id, name, type from Account limit 10];
        records = acc.size();
        System.debug('Total records are '+ records);
        passedValue ='';
    }
    public List<Account> getaccounts(){
        return acc;
    }
    
    public pageReference dummyCall(){
        System.debug(passedValue);
        return null;
    }
        
}


Visualforce page

<apex:page Controller="wrapperWithRadioButtonCtrl" readOnly="true" >
   <apex:form >
       <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
        function MyFunction(){
        alert('hi');
            var i = {!records};
            var selectedRecordIds;
           for(j = 0; j < i; j++){
               console.log('value of j'+ j+'\n');
               if(document.getElementByName("SelectedAccount")[j].checked)
               {
                selectedRecordIds = document.getElementByName("SelectedAccount")[j].value;   
                  console.log('selected Record Id is'+ selectedRecordIds);
               }
           }
            passVariableToController(selectedRecordIds);
    </script>
 
        
    
    <apex:pageBlock >
        <table>
            <Tr><th>Selected Account</th>
            <th>Account Name</th>
            <th>Account Type</th>
           </Tr>
            <apex:repeat value="{!accounts}" var="a" >
            <tr>
                
                <td><input type="radio" value="{!a.id}" name="SelectedAccount"/> </td>
                <td><apex:outputText >{!a.name}</apex:outputText></td>
                <td><apex:outputText >{!a.type}</apex:outputText></td>
                
            </tr>
            </apex:repeat>
        </table>
    </apex:pageBlock>
    <apex:actionFunction name="passVariableToController" action="{!dummyCall}" reRender="pd2">
        <apex:param name="pi" assignTo="{!passedValue}" value="" />
    </apex:actionFunction>
    <apex:commandButton onclick="MyFunction(); return false;" value="Search" />
        <apex:pageBlock id="pb2" title="Account Value">
            <apex:outputText >{!passedValue}</apex:outputText>
       </apex:pageBlock>
     </apex:form>
</apex:page>
<apex:page standardcontroller="Position__c">

    <p>This map shows the locations of candidates who have 
       applied for the {!Position__c.Name} position.</p>

    <!-- For development use only.
         Add a Google API key to use in production. See 
         https://developers.google.com/maps/documentation/javascript/tutorial 
         for details of how to obtain a Google API key. -->
    <apex:includeScript value="https://maps.googleapis.com/maps/api/js"/>
    
    <script type="text/javascript">
        var applicants = [];
        var countApplicantsGeocoded = 0;
        var map;
        var mapBoundary;
        var geocoder;
        var applicantInfoPanel = new google.maps.InfoWindow();
        
        function loadMap() {
            var mapCanvas = document.getElementById('{!$Component.mapContainer}');
            var mapOptions = {
                center: { lat: 40, lng: -95 },
                zoom: 4,
                maxZoom: 10,
                scrollwheel: false
            };
            map = new google.maps.Map(mapCanvas, mapOptions);
            mapBoundary = new google.maps.LatLngBounds();
                   
            loadApplicants();
            plotApplicantMarkers();
        }
        
        // Convert applicants from sObjects to JavaScript objects
        function loadApplicants() {
            <apex:repeat value="{!Position__c.Job_Applications__r}" var="jobApp">
                applicants.push({ 
                    name: "{!JSENCODE(jobApp.Candidate__r.First_Name__c + ' ' + 
                                     jobApp.Candidate__r.Last_Name__c)}",
                    address: "{!JSENCODE(jobApp.Candidate__r.Street__c  + ', ' + 
                                        jobApp.Candidate__r.City__c + ', ' + 
                                        jobApp.Candidate__r.State_Province__c)}",
                    viewLink: "{!JSENCODE(LINKTO(jobApp.Candidate__r.First_Name__c + 
                                           ' ' + jobApp.Candidate__r.Last_Name__c, 
                                        $Action.Candidate__c.View, 
                                        jobApp.Candidate__c))}"
                });
            </apex:repeat>
        }
        
        // Place markers on the map for each applicant
        function plotApplicantMarkers() {
            geocoder = new google.maps.Geocoder();
            for(var idex = 0 ; idex < applicants.length ; idex++) {
                geocodeAndCreateMarker(applicants[idex]);
            }
        }
        
        // Convert address to lat & long, and create actual marker
        function geocodeAndCreateMarker(applicant) {
            geocoder.geocode({'address':applicant.address},function(results, status){

                countApplicantsGeocoded++;

                // Add marker for geocoded address
                if(status == google.maps.GeocoderStatus.OK) {
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location,
                    });
                    mapBoundary.extend(marker.position);
                    
                    google.maps.event.addListener(marker, 'click', function() {
                        applicantInfoPanel.setContent(applicant.viewLink + 
                            "<br/>\n" + applicant.address);
                        applicantInfoPanel.open(map, marker);
                    });
                }
                
                // If we're done geocoding, re-center and zoom the map
                if(countApplicantsGeocoded >= applicants.length) {
                    map.fitBounds(mapBoundary);
                }
            });
        }
        
        google.maps.event.addDomListener(window, 'load', loadMap);
    </script>

    <apex:outputPanel layout="block" id="mapContainer" style="height: 400px">
        Loading map...
    </apex:outputPanel>

</apex:page>




Can someone help me why i am getting this error while greating a visualforce page! 

Error: Invalid field Candidate__r for SObject Job_Application__c
Hi,

I am having an error when I push my triggers to production. I have added appropriate test classes for them too.
In developer console they show up as 100% covered for Code coverage like below.

User-added image
But when I try to deploy the triggers in production it gives me below error

User-added image

Can somebody please suggest me what could be the reason for that ?

Thank you :)
 
@isTest

private class ContactInfoDeleteTriggerTestMVN {
    
    @isTest 
    private static void testDelete() {
        TestDataFactoryMVN.createFieldSetMappings();
        TestDataFactoryMVN.createPSSettings();

        Account doc = TestDataFactoryMVN.createPhysician();
        Account pat = TestDataFactoryMVN.createMember();
        Program_MVN__c prog = TestDataFactoryMVN.createProgram();
        Program_Stage_MVN__c parent = TestDataFactoryMVN.createParentProgramStage(prog);
        Program_Stage_MVN__c child = TestDataFactoryMVN.createChildProgramStage(prog, parent);
        Program_Member_MVN__c member = TestDataFactoryMVN.createProgramMember(prog, pat);
        Address_vod__c add = TestDataFactoryMVN.createTestAddress(pat);

        List<Contact_Information_MVN__c> info = [SELECT Id,Name FROM Contact_Information_MVN__c WHERE Address_MVN__c = :add.Id];
        system.debug('Varun1'+info);
        //System.assertEquals(1, info.size(), 'Incorrect number of contact information records retrieved.');

        List<Communication_Preference_MVN__c> pref = [SELECT Id,Name FROM Communication_Preference_MVN__c WHERE Contact_Information_MVN__c = :info[0].Id];
        system.debug('VArun'+pref);
        System.assertEquals(1, pref.size(), 'Incorrect number of communication preference records retrieved.');
        Id testCommPrefId = pref[0].Id;

        delete info[0];

        info = [SELECT Id FROM Contact_Information_MVN__c WHERE Address_MVN__c = :add.Id];
        pref = [SELECT Id FROM Communication_Preference_MVN__c WHERE Id = :testCommPrefId];
        List<Address_vod__c> adds = [SELECT Id FROM Address_vod__c WHERE Id = :add.Id];

        System.assertEquals(0, info.size(), 'Should have returned no contact information records');
        System.assertEquals(0, pref.size(), 'Should have returned no communcation preference records');
        System.assertEquals(0, adds.size(), 'Should have returned no address records');
    }
}

I am getting System.List Exception at Line         List<Communication_Preference_MVN__c> pref = [SELECT Id,Name FROM Communication_Preference_MVN__c WHERE Contact_Information_MVN__c = :info[0].Id];

Any help why this error is coming in production?
I have following code:
Http httpProtocol = new Http();
            HttpRequest request = new HttpRequest();
            system.debug(logginglevel.INFO , '$$ ' + ValueProvider.constructEndpoint(addressToDetermineCoordinates));
            String endpoint = ValueProvider.constructEndpoint(addressToDetermineCoordinates);
            System.debug(Logginglevel.INFO , '#$ endpoint url: ' + endpoint);
            request.setEndpoint(endpoint);
            request.setMethod('GET');
            HttpResponse response = httpProtocol.send(request);
            system.debug(logginglevel.info , '## ' + response.toString() );
            
            System.debug(logginglevel.info , '@#response' + response.getBody());


            
And I am trying to send request to google maps api and recieve an answer as JSON. My variable "endpoint" contains following value:

https://maps.googleapis.com/maps/api/geocode/json?address=Lodz Tuszynska 101/7&key=[myAPIKey]

and when I am trying to do it manually via FIrefox i get proper JSON representation, but in apex I get: "12:41:58:073 USER_DEBUG [17]|INFO|## System.HttpResponse[Status=Bad Request, StatusCode=400]" . I have tried to replace all spaces to "%" in my endpoint but it did not work. COuld you please give me some advice what I am doing wrong?
Hi, Please let me know how to cover EmailMessaging class in below code:

Class:
global class UpdateLastWorkedDate_onContactBatch implements Database.Batchable<sObject>, Schedulable {
     public EmailTemplate et{get;set;}
      
    global DataBase.QueryLocator start(Database.BatchableContext bc){
                       system.debug('>>>>');

        return DataBase.getQueryLocator([select id,owner.email,TR1__Candidate_Status__c,Last_Day_Worked__c,TRSCHED__Compliance_Owner__r.email from contact where Last_Day_Worked__c!=null]);
        }
    global void execute(Database.BatchableContext BC, List<contact> scope)
       {
                      system.debug('>>>>');

       list<contact> conlist=new list<contact>();
       et=[select id,Name FROM EmailTemplate where Name='3monthsgap' Limit 1];
       list<string> to=new list<string>();
       List<Messaging.SingleEmailMessage> mailsList = new List<Messaging.SingleEmailMessage>();

       for(contact c:scope){
               system.debug('>>>>');

        integer i;
        //i=system.today().monthsBetween(c.Last_Day_Worked__c);
        i=c.Last_Day_Worked__c.monthsBetween(system.today());

        system.debug('>>>>'+i);
        if(i==3){
        c.TR1__Candidate_Status__c='InActive';
        conlist.add(c);
        }
        if(i==2)
        {
                       system.debug('>>>>');

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
               to.add(c.owner.email);
                 to.add(c.TRSCHED__Compliance_Owner__r.email);

                 mail.setTargetObjectId(c.id);
                 mail.setSaveAsActivity(false);
                 mail.setTreatTargetObjectAsRecipient(false);
                 mail.setTemplateId(et.id);
                 //mail.setWhatId(AQ.id);
                 mail.setToAddresses(to);
          mailsList.add(mail);
        
        }
       }
      if(conlist.Size()>0){

       update conlist;
       }
        if(mailsList.Size()>0){
                       system.debug('>>>>');

            Messaging.sendEmail(mailsList);
            }  
       
       }   
    
    global void finish(Database.BatchableContext BC){
        }
       global void execute(SchedulableContext sc) {
        UpdateLastWorkedDate_onContactBatch b1 = new UpdateLastWorkedDate_onContactBatch();
        ID batchprocessid = Database.executeBatch(b1,200);    
    }
    
}

Test class: 59% coverage

@isTest
public class Test_UpdateLastWorkedDate_onContactBatch {
public static testMethod void test() 
     {
   /*   Profile p = [SELECT Id FROM Profile WHERE Name='system administrator'];
         
    User us = new User(Alias='Admin',Email='test@gamil.com',LastName='Testing',Username='standardus@testorg.com',LanguageLocaleKey='en_US',LocaleSidKey='en_US',ProfileId = p.Id, 
           TimeZoneSidKey='America/Los_Angeles',EmailEncodingKey='UTF-8');
    insert us;*/
   User us = [Select id from User where Id = :UserInfo.getUserId()];
         
    Account acc = new Account(Name = 'test13');
    insert acc;
    
    Contact con = new Contact(LastName = 'One', Last_Day_Worked__c=system.today().adddays(-90), Email ='test.user@gmail.com',  TR1__Candidate_Status__c ='DNU', TRSCHED__Compliance_Owner__c=us.id,  AccountId=acc.id);
    insert con;
         
 //     EmailTemplate eT = new EmailTemplate (developerName = 'X3monthsgap', subject='test', FolderId = UserInfo.getUserId(), TemplateType= 'Text', Name = '3monthsgap'); 
     //    insert eT;
   System.runAs(us)
   {
   Test.startTest();
     UpdateLastWorkedDate_onContactBatch obj = new UpdateLastWorkedDate_onContactBatch();
     DataBase.executeBatch(obj); 
         
   Test.stopTest();
   }  
    }
    
}

Below code not covered:

 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
               to.add(c.owner.email);
                 to.add(c.TRSCHED__Compliance_Owner__r.email);

                 mail.setTargetObjectId(c.id);
                 mail.setSaveAsActivity(false);
                 mail.setTreatTargetObjectAsRecipient(false);
                 mail.setTemplateId(et.id);
                 //mail.setWhatId(AQ.id);
                 mail.setToAddresses(to);
          mailsList.add(mail);
       
 global void execute(SchedulableContext sc) {
        UpdateLastWorkedDate_onContactBatch b1 = new UpdateLastWorkedDate_onContactBatch();
        ID batchprocessid = Database.executeBatch(b1,200);    
    
Thanks
Sorry if this is a stupid question but I am an Admin rather than a developer. We have a trigger that creates renewal opportunites - and one of the criteria is to ignore inactive accounts. 
User-added image

On the account there is a field called account status and it is a picklist with the values of active and inactive. If the account has no value in this field - will it return a true or false value? i.e will the trigger ignore this account in the code.

 

Hi Folks,
I need to third party soapservice web alesforce.I am confusing where i need to give username and password of third  party system.please help me

//Generated by wsdl2apex

public class PED_SmartinfoWSDL {
    public class DatiClienteType {
        public String Nome;
        public String Cognome;
        public String CodiceFiscale;
        public String RagioneSociale;
        public String PartitaIva;
        public PED_SmartinfoWSDL.IndirizzoType Indirizzo;
        private String[] Nome_type_info = new String[]{'Nome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Cognome_type_info = new String[]{'Cognome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] CodiceFiscale_type_info = new String[]{'CodiceFiscale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] RagioneSociale_type_info = new String[]{'RagioneSociale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] PartitaIva_type_info = new String[]{'PartitaIva','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Indirizzo_type_info = new String[]{'Indirizzo','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Nome','Cognome','CodiceFiscale','RagioneSociale','PartitaIva','Indirizzo'};
    }
    public class ServizioSIRicercaResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public PED_SmartinfoWSDL.ArrayOfEsitoRicercaType EsitiRicerca;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] EsitiRicerca_type_info = new String[]{'EsitiRicerca','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','EsitiRicerca'};
    }
    public class ServizioSIGeneraFileRequest_element {
        public String Pod;
        public String SIIdentifier;
        public String NIDIdentifier;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NIDIdentifier_type_info = new String[]{'NIDIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','SIIdentifier','NIDIdentifier','IdUtente','NomeUtente'};
    }
    public class ServizioSIAssociazioneResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public String ConfigurazioneSI;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] ConfigurazioneSI_type_info = new String[]{'ConfigurazioneSI','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','ConfigurazioneSI'};
    }
    public class ServizioSIAssociazioneRequest_element {
        public String Pod;
        public String SIIdentifier;
        public String NIDIdentifier;
        public String TipoConfigurazione;
        public String PodPROD;
        public String EneltelPROD;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NIDIdentifier_type_info = new String[]{'NIDIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] TipoConfigurazione_type_info = new String[]{'TipoConfigurazione','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] PodPROD_type_info = new String[]{'PodPROD','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] EneltelPROD_type_info = new String[]{'EneltelPROD','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','SIIdentifier','NIDIdentifier','TipoConfigurazione','PodPROD','EneltelPROD','IdUtente','NomeUtente'};
    }
    public class ServizioSISostituzioneResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public String ConfigurazioneSI;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] ConfigurazioneSI_type_info = new String[]{'ConfigurazioneSI','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','ConfigurazioneSI'};
    }
    public class ServizioSIRimozioneRequest_element {
        public String Pod;
        public String Eneltel;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] Eneltel_type_info = new String[]{'Eneltel','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','Eneltel','IdUtente','NomeUtente'};
    }
    public class ServizioSIGeneraFileResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        public String ConfigurazioneSI;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] ConfigurazioneSI_type_info = new String[]{'ConfigurazioneSI','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','ConfigurazioneSI'};
    }
    public class ServizioSIRimozioneResponse_element {
        public PED_SmartinfoWSDL.EsitoType Esito;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito'};
    }
    public class ServizioSIRicercaRequest_element {
        public PED_SmartinfoWSDL.DatiFornituraType DatiFornitura;
        public PED_SmartinfoWSDL.DatiAnagraficiType DatiAnagrafici;
        public PED_SmartinfoWSDL.DatiBaseType DatiBase;
        public String IdUtente;
        public String NomeUtente;
        private String[] DatiFornitura_type_info = new String[]{'DatiFornitura','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] DatiAnagrafici_type_info = new String[]{'DatiAnagrafici','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] DatiBase_type_info = new String[]{'DatiBase','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'DatiFornitura','DatiAnagrafici','DatiBase','IdUtente','NomeUtente'};
    }
    public class EsitoType {
        public Integer Esito;
        public String Descrizione;
        private String[] Esito_type_info = new String[]{'Esito','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] Descrizione_type_info = new String[]{'Descrizione','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Esito','Descrizione'};
    }
    public class IndirizzoType {
        public String Via;
        public String NumeroCivico;
        public String CAP;
        public String Localita;
        public String CodiceIstat;
        private String[] Via_type_info = new String[]{'Via','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NumeroCivico_type_info = new String[]{'NumeroCivico','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] CAP_type_info = new String[]{'CAP','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Localita_type_info = new String[]{'Localita','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] CodiceIstat_type_info = new String[]{'CodiceIstat','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Via','NumeroCivico','CAP','Localita','CodiceIstat'};
    }
    public class DatiBaseType {
        public String Nome;
        public String Cognome;
        public String RagioneSociale;
        public PED_SmartinfoWSDL.IndirizzoType Indirizzo;
        private String[] Nome_type_info = new String[]{'Nome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Cognome_type_info = new String[]{'Cognome','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] RagioneSociale_type_info = new String[]{'RagioneSociale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Indirizzo_type_info = new String[]{'Indirizzo','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Nome','Cognome','RagioneSociale','Indirizzo'};
    }
    public class FornituraType {
        public String POD;
        public String Eneltel;
        public String Matricola;
        public PED_SmartinfoWSDL.DatiClienteType DatiCliente;
        public String PotenzaContrattuale;
        public String SIIdentifier;
        public String TipoFornitura;
        public String VersoInserzione;
        public String TipoConfigurazione;
        private String[] POD_type_info = new String[]{'POD','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Eneltel_type_info = new String[]{'Eneltel','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Matricola_type_info = new String[]{'Matricola','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] DatiCliente_type_info = new String[]{'DatiCliente','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] PotenzaContrattuale_type_info = new String[]{'PotenzaContrattuale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] TipoFornitura_type_info = new String[]{'TipoFornitura','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] VersoInserzione_type_info = new String[]{'VersoInserzione','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] TipoConfigurazione_type_info = new String[]{'TipoConfigurazione','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'POD','Eneltel','Matricola','DatiCliente','PotenzaContrattuale','SIIdentifier','TipoFornitura','VersoInserzione','TipoConfigurazione'};
    }
    public class ServizioSISostituzioneRequest_element {
        public String Pod;
        public String SIIdentifier;
        public String NIDIdentifier;
        public String Causale;
        public String IdUtente;
        public String NomeUtente;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] SIIdentifier_type_info = new String[]{'SIIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] NIDIdentifier_type_info = new String[]{'NIDIdentifier','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] Causale_type_info = new String[]{'Causale','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] IdUtente_type_info = new String[]{'IdUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] NomeUtente_type_info = new String[]{'NomeUtente','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod','SIIdentifier','NIDIdentifier','Causale','IdUtente','NomeUtente'};
    }
    public class ArrayOfEsitoRicercaType {
        public PED_SmartinfoWSDL.EsitoRicercaType[] EsitoRicerca;
        private String[] EsitoRicerca_type_info = new String[]{'EsitoRicerca','http://xmlns.enel.it/wsdl/smartInfo',null,'1','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'EsitoRicerca'};
    }
    public class EsitoRicercaType {
        public PED_SmartinfoWSDL.FornituraType Fornitura;
        private String[] Fornitura_type_info = new String[]{'Fornitura','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Fornitura'};
    }
    public class DatiAnagraficiType {
        public String CodiceFiscale;
        public String PartitaIva;
        private String[] CodiceFiscale_type_info = new String[]{'CodiceFiscale','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] PartitaIva_type_info = new String[]{'PartitaIva','http://xmlns.enel.it/wsdl/smartInfo',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'CodiceFiscale','PartitaIva'};
    }
    public class DatiFornituraType {
        public String Pod;
        private String[] Pod_type_info = new String[]{'Pod','http://xmlns.enel.it/wsdl/smartInfo',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo','true','false'};
        private String[] field_order_type_info = new String[]{'Pod'};
    }
    public class ServizioSIRicerca {
     //public String endpoint_x = 'https://smartinfo.risorse.enel:8013/smartInfo/services/ServizioSIRicerca';
      public String endpoint_x = 'https://4ele-collaudo-wssf.enel.it/smartInfo/services/ServizioSIRicerca';
     // public String endpoint_x = 'https://requestb.in/130albk1';
      
  ;
      
      
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
       private String[] ns_map_type_info = new String[]{'http://xmlns.enel.it/wsdl/smartInfo', 'PED_SmartinfoWSDL'};
        
            public PED_SmartinfoWSDL.ServizioSIRicercaResponse_element ServizioSIRicerca(PED_SmartinfoWSDL.DatiFornituraType DatiFornitura,PED_SmartinfoWSDL.DatiAnagraficiType DatiAnagrafici,PED_SmartinfoWSDL.DatiBaseType DatiBase,String IdUtente,String NomeUtente) {
            PED_SmartinfoWSDL.ServizioSIRicercaRequest_element request_x = new PED_SmartinfoWSDL.ServizioSIRicercaRequest_element();
            system.debug('i am wsdl class');
            request_x.DatiFornitura = DatiFornitura;
            request_x.DatiAnagrafici = DatiAnagrafici;
            request_x.DatiBase = DatiBase;
            request_x.IdUtente = IdUtente;
            request_x.NomeUtente = NomeUtente;
            
            system.debug('the value in the reuuest'+request_x);
             system.debug('Endpoint URL'+endpoint_x );
            
            PED_SmartinfoWSDL.ServizioSIRicercaResponse_element response_x;
            Map<String, PED_SmartinfoWSDL.ServizioSIRicercaResponse_element> response_map_x = new Map<String, PED_SmartinfoWSDL.ServizioSIRicercaResponse_element>();
            response_map_x.put('response_x', response_x);
            
            system.debug('the value'+ response_map_x);
           
            
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://xmlns.enel.it/wsdl/smartInfo/ServizioSIRicerca',
              'http://xmlns.enel.it/wsdl/smartInfo',
              'ServizioSIRicercaRequest',
              'http://xmlns.enel.it/wsdl/smartInfo',
              'ServizioSIRicercaResponse',
              'PED_SmartinfoWSDL.ServizioSIRicercaResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x;
        }
    }
}
 
// Custom apex class created me

GLOBAL Class PED_callingsoapservice{
    GLOBAL PED_callingsoapservice()  {
        
        PED_SmartinfoWSDL.DatiBaseType DatiBase =  new PED_SmartinfoWSDL.DatiBaseType();
        PED_SmartinfoWSDL.DatiAnagraficiType DatiAnagrafici = new  PED_SmartinfoWSDL.DatiAnagraficiType();
        DatiAnagrafici.CodiceFiscale='LLLSRG70E09H501O';
        PED_SmartinfoWSDL.DatiFornituraType DatiFornitura = new   PED_SmartinfoWSDL.DatiFornituraType();
        
        DatiFornitura =NULL;
        DatiBase =null;
                
        // PED_SmartinfoWSDL.ServizioSIRicerca obj= new PED_SmartinfoWSDL.ServizioSIRicerca(DatiFornitura , DatiAnagrafici  ,DatiBase ,'TEST','TEST POD');
        PED_SmartinfoWSDL.ServizioSIRicerca obj= new PED_SmartinfoWSDL.ServizioSIRicerca();
        PED_SmartinfoWSDL.ServizioSIRicercaResponse_element res= obj.ServizioSIRicerca(DatiFornitura , DatiAnagrafici  ,DatiBase ,'TEST','TEST POD');
        
        system.debug('Response value'+res);
        
        
        
        
 
    
   }
   }
Hi Community,
I have created a new 'OpportunityOffer' object and I can only create a new OpportunityOffer object as a child object of an Opportunity.

So I want to override the New button of the OppertunityObject, because I have to set the recordtype automatically. If I have an Opportunity with type (custom field) X, than I have to set the recordtype X for the new OpportunityOffer.

I created the following:

<apex:page standardController="OpportunityOffer__c" extensions="ManualOfferRecordTypeSelectionExtension"
           action="{!URLFOR($Action.OpportunityOffer__c.New, null, [retURL=URLFOR($Action.Opportunity.Tab, $ObjectType.Opportunity), RecordType='{!recordType}'], true)}">

My Controller finds the right recordtype - but I think that the action does not wait for the result of my controller - the wrong recordtype is set. I tested to set a recordtype Id into the action, that worked - but not with a controller value.

Is there a way to create the action in the controller? I found nothing in the internet that help me.. 
  • October 12, 2017
  • 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.