• RadDude89
  • NEWBIE
  • 120 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 34
    Questions
  • 28
    Replies
Hi,

I’m hoping someone can help me on writing a test class for an apex class that uses a visualforce page to create a registration record.  I just don’t understand how to create a test class to call a method called AddProducts() and add data to test the validation rules I have built into the apex class.

Please see below:

APEX CLASS:


Enrg_PartnerRegister_Ext_New {
public Registrations__c regObj {get; set;}
    public Register_Class(ApexPages.StandardController stdController) {
        PgId = System.currentPageReference().getParameters().get('p3_lkId');
     regObj = (Registrations__C)stdController.getRecord();
            
    }
                   public PageReference addProducts(){
        try{ 

                    if(regObj.Name__c == regObj.Legal_Name__c){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Name can not be the same as Legal Name'));
                        return null;
                    }
                                                                           if(regObj.Cost__c == regObj.Price__c){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Cost can not be the same as Price'));
                        return null;
                    }
                      }
}

VISUALFORCE PAGE:

<apex:page standardController="Registrations__c" Extensions="Register_Class">
  
        <apex:sectionHeader title="Registration " ></apex:sectionHeader>
        <apex:outputPanel id="error">
            <b><apex:pagemessages /></b>
        </apex:outputPanel>    
<apex:pageblockSection title="Details">
                <apex:inputField value="{!regObj.Name__c}" required="true" />
                <apex:inputField value="{!regObj.Legal_Name__c}"  />
                <apex:inputField value="{!regObj.Cost__c}" required="true"/>
                <apex:inputField value="{!regObj.Price__c}" required="true"/>
                                                            ......

So essentially, I need a test class to test attempting to create a registration record with the Name = Legal Name and Cost = Price and then allowing the records to save.
I’ve tried a number of methods but I just can’t get anything to compile on the test class.

Can someone help point me in the right direction please?

Thanks,
RadDude89

 

Hi,

I'm having difficulty in writing a test class for my apex class that creates a new lead record based on whether an existing lead has met the conditions.  So if a lead has Web to Lead = True and H M!=null and WTL G!=null, it will take the values from that record and create a new one.  Please see below class:

APEX CLASS:

public class CreateNewLead {
 
   public static void createnewrecords(List<Lead> leadMap){
 
        List<Lead> insertList = new List<Lead>();

        for (Lead rec:LeadMap){
               if ((rec.WTL_G__c != null) && (rec.H_M__c != null) && (rec.Web_to_Lead__c==TRUE))
               {                                          
                      // Creating new record
                       Lead newlist = new Lead();      
                       newlist.WTL_M__c = rec.H_M__c;                  
                       newlist.FirstName = rec.FirstName;
                       newlist.LastName = rec.LastName;
                       insertList.add(newlist);        
               }
             
         }
        
        if(insertList.size()>0){
        insert  insertList;  
        Constantclass.isenteredtrigger=true;
        }
   }
}

 

TEST CLASS:

@isTest
private class CreateNewLead_Test {
    
    
        static  testMethod void UPDATEMPRNGRPN_Test_TestMethod1(){
                       List<Lead> leadMap = new List<Lead>();
                       List<Lead> insertList = new List<Lead>();
                       Lead Ld = new Lead(FirstName='Name2', Web_To_Lead__c=TRUE, H_M__c='12345678901', WTL_G__c='1234567');
                       insert Ld;
                       insertList.add(Ld);
                       CreateNewLead.createnewrecords(insertList);
                       }     
               }

I'm getting 0% coverage on this class however I'm not sure on what I'm doing wrong.  Can someone please help?

Hi,

I'm trying to set up data loader to use on Server 2019 in order to create .bat files to export data from Salesforce.  When I try to run the batch job I get the error message "invalid username, password, security token or user locked out".  I have configured the connection using command line on Server 2008 R2 and this works successfully.  I have transferred the config over to Server 2019 and I get the error message on this OS.  I know that there are no issues with connection on 2008 server so I'm not sure on why it wouldn't connect on Server 2019.

Does anyone know what could possibly be causing this issue on server 2019?  Are there any changes that I can do to ensure this connection works on both 2008 server and 2019 server?

Any help is much appreciated.

 

Hi,

I am trying to use the pattern.matches function on an apex trigger on our sandbox, what we are trying to do is update a record to Pending Validation based on whether a linked record meets the format required.

So on the trigger we have:

 

trigger Enrg_PendingValidation_Trigger on Registrations__c (Before Update, Before Insert){
for(Registrations__c reg:trigger.new){

Boolean validTelephone;
telephonePat='[0-9]{3} [0-9]{4} [0-9]{4}';

telephone = reg.Site__r.Site_Phone__c;
validTelephone= Pattern.matches(telephonePat,telephone);

if(reg.Site__r.Site_Phone__c != null && validTelephone!= true ){
               reg.Registration_Status__c='Pending Validation';                                   
               }
}
}

This trigger saves ok on Salesforce but when I try to edit and save the registration I get the error message
Script-thrown exception: Class.System.Pattern.matcher

It appears that the issue is being caused by the line validTelephone= Pattern.matches(telephonePat,telephone); as when I comment this out I am able to save the record.

Can anyone help me on this?  I can't see what I am doing wrong here.

Thanks in advance.

Hi,

We appear to be having an issue on our Salesforce portal - it looks like when we attempt to register a customer as 'Renewal' there is no record type assigned to the record.  So when we press the save button we get an error message saying about a Bad Value for Record Type with the ID being null.

In order to resolve this issue I want to add a condition so that if the user selects Renewal then to apply a particular record type or if the recordtypeID is blank then apply a record type.

Does anyone know how to do this?

I've tried some code but when I do I get the attempt to de-reference a null object error on the visualforce page.

This is what I have currently in the apex class which is causing the issue.

if(regObj.RecordTypeID==null){                 
regObj.RecordTypeID = recmap1.get('Partner MPRN ROI');

I've also tried the code below but same results:

if(regObj.RecordTypeID==null){                    
                    regObj.RecordTypeID=Schema.SObjectType.site__c.getRecordTypeInfosByName().get('Partner MPRN ROI').getRecordTypeId();
                }

Is there something I'm doing wrong?

Thanks in advance.

 

Hi,

We use an apex class and visualforce page for calculate which users can select which pricebooks (custom object).
Within the logic I can see that Userinfo will has been added - so this looks like it will only return pricebooks for standard license users (I think I'm correct in saying this).

What I want to do within this selection query is return the pricebooks which have the same value on User field and the same value on the current users custom field Agent.
E.g. Pricebook.User__c = User.Agent_Name__c.

Below is the current code:
if(Userinfo.getUserType() == 'Standard'){           
            priceBookList = [select Product__c,name,id, name,Description__c,Contract_Start_Date__c, Internal__c from 
            Pricebook__c where Product__c=:selectedProduct and Active__c = True];

Does anyone know how I can add this in?
Anything I seem to try doesn't work.

Thanks in advance

Hi,

I'm looking into creating a process in which Salesforce will update the parent record if a field on the child has the value 'Rejected'.

So we have a parent object - Offer and child - Offer SIte.
Then if the field Status__c on Offer Site = 'Rejected', I want to apply the same value to a field called Status on Offer automatically once the field on Offer site is updated.

Does anyone know how to do this?
I'm not too sure on how I can write this into trigger as my experience with triggers is basic

Any help is much appreciated.
Thanks.

Hi,

We have added additional logic to an aex class on our Salesforce - the logic is applied to a custom object called Registration__c.

When you create a registration, the system will go through a number of conditions and will create a record called Credit - only if sertian criteria is met.
When we test this on our sandboxes, it works perfectly but when we attempt to register a site on production:
"Insert failed. First exception on row 0; first error: TOO_MANY_ENUM_VALUE, Credit Risk Reason: too many items selected: 18517 [Credit_Risk_Reason__c}"

Below is the code which causes the issue:
    listregQry2=[Select High_Risk_Email__c, High_Risk_Phone_Number__c from High_Risk__c]                           
                if(listregQry!=null){
                    for(Registrations__c r:listregQry){
                        String CreditComReason='';
                        if(sitenames==null||!sitenames.contains(r.site__r.name)){
                            Credit_Committee__c CCobj = new Credit_Committee__c(status__c='Referred');
                            CCobj.Comments_For_Credit_Committee__c=r.Comments_For_Credit_Committee__c;
                            sitenames.add(r.site__r.name);
                            if(listregQry2!=null){                               
                                for(Bad_Debt_Data__c r1:listregQry2){                                                                      
                                    if(r1.High_Risk_Email__c == r.site__r.contact__r.email)  {                                     
                                        System.debug('high risk email');
                                        CreditComReason=CreditComReason+'High Risk Email Found;';
                                    }
                                }
                               
                                if(r.site__r.contact__r.Phone != NULL){
                                    for(Bad_Debt_Data__c r2:listregQry2){
                            if(r2.High_Risk_Phone_Number__c == r.site__r.contact__r.Phone){ 
                                System.debug('high risk contact');
                                CreditComReason=CreditComReason+'High Risk Phone Number Found;';
                            }
                            }
                            }
                        }

Does anyone know what is causing this issue? Any ideas on how to resolve?

Any help is much appreciated.

Regards,
RadDude89

Hi,

I'm writing a small apex class test for a trigger we have but when I run the test it fails with the error message "Missing id at index".

This is the test class below.

@istest
public class DeleteJunk_trigger_test {

    public static testmethod void DeleteJunk_trigger()
    {
       test.startTest();
         Registrations__c reg = new Registrations__c(GPRN__c = '',  Source__c = '' , Source_System__c = '' , Region__c = '' ,     
        MPRN__c = '');
       delete reg;
       }
       }

Can anyone see what I am missing?

Thanks.

Hi,

We have created an apex class and 2 triggers which execute once a registration record is created/updated in order to update the record based on certain criteria.
From this we have noticed that in the mornings the registration process can be quite slow for some users and in some cases they will get the request timed out error message.
When a system admin tries it, sometimes its slow but most of the time we can create the registration fairly quickly.

Is there anything that I should check to maybe increase the request time of the users/triggers? I've never got an error like this and we never had the error in any of our sandboxes - it just appears to be production.
Does anyone know how to resolve this/had a similiar problem?

Thanks.

Hi,

I'm trying to return values from a list in an apex class using the value from another list.
So I have list1 = [Select Contact__r.ContactEmail from Registrations__c Id in : lstRegistrations]

and what I want to do is check all the records from another object using the value of ContactEmail from above list.
So something like this:
list2=[Select Email from Site__c where Email contains (list1.Contact__r.ContactEmail)]

Can this be done?

Any help is much appreciated.

Thanks

Hi,

We are trying to add logic into our apex class where if the user registers a site and the mobile phone value held at contact is found on any other contact records it will update a field on registration.

So below I have these 2 lists.

listregQry= this contains the mobilephone from the contact being registered.
listregMobile= this contains all Mobile Phone values from our system

listregQry=[Select site__r.Contact__r.MobilePhone from Registrations__c where Id in : lstRegistrations ];
listregMobile=[Select Contact__r.MobilePhone from Site__c];

What I want to do is update a field called Mobile Used to TRUE when the Mobile Phone from listregQry is found on the system on a different contact record.

Does anyone know how I can achieve this?


Thanks in advance.

Hi,

I'm wondering if it is possible to create a dynamic lookup on a visualforce page in Salesforce.  We want to be able to allow the user to start typing into a field and it will return site names based on what the user typed.

For example - typing 'T' into Company name would show a drop down of sites beginning with T.  Then if the user added 'e' it would show the sites beginning with Te.

Is this posible to achieve on Salesforce?

Thanks.

Hey guys,

We have an apex class and VF page called Register.  On this page the user can select from 4 different values on a picklist field called Type.

Is it possible to show all fours selections to all users that have Agent (checkbox) as TRUE on their user profile?

So what I would need is any currently logged in user with Agent as TRUE will see Options 1,2,3,4 and any user with Agent as FALSE will see options 1,2,3.

Can this be done?

Hi,

We have set up an approval process called Renew.  This approval process was created via the standard process (adding email alerts, approval/rejection field updates, etc). When we create an offer record the approval process doesn't start - the user must press submit for approval.  Can you create an apex trigger to initiate an approval process when a record has been created?
So in a way we would be pressing the submit for approval for the user automatically.
Can the trigger call on the ID of the approval process to initiate it if certain requirements are met?

Hi,

I have created an approval process for a custom object called Offer which is based on several selections regarding the creation of the offer.
The offer is to be locked and sent to a manager for approval when the criteria is
Price <0.200 and Region= NI
What I have realised is that when the offer is created the approval won't start - the user has to press the Submit for Approval for it to start.

Is it possible to create a trigger to kick the approval process off automatically when the offer has been created?

Hi,

I'm trying to introduce validation on one of our apex classes which is based on a custom field value on the user's record.

So we have a custom field setup on the user object called Consultant (checkbox).
When a user logs in I want to return an error message if that current logged in user has Consultant = FALSE then show them the error message whereas for users where Consultant = TRUE they can bypass the error.

List<User> lstUser = [Select Agent_Name__c from User where userinfo.Consultant__c=TRUE];
 if(lstUser.size()==0 ){
                                apexpages.addmessage(new ApexPages.Message(ApexPages.severity.FATAL,' You can not proceed'));

When I try using userinfo. it doesn't compile so does anyone know how to retrieve a value from a custom field on user object for the current user?

Hi,

I'm trying to create a validation rule that looks at a picklist field and return an error if the value has been changed after the record is approved.

The field contains 4 selections: 14, 30, 45 and 60.

What I'm trying to achieve is a validation rule that if a user (originally created the record with 14 as the selection) was to change it to 30, then they would get an error message "you can not change after approval".

When I try using the priorvalue, it says that this function can not be used in this type of formula.
I tried changing it to use TEXT values i.e.
(TEXT(Payment_Date__c) != TEXT(PRIORVALUE(Payment_Date__c)))

However this doesn't return the error message even I'm able to save the validation rule.

Does anyone know how to achieve using priorvalue for picklists? What is the best method for this?

Hi,

Is it possible to update a dependent picklist based on the selection of the controlling picklist?
For example - we have a list of countries on a controlling picklist and a dependent picklist of the abbreviated versions of the countries.
So if a user selected "England" then "Eng" would be available to select but the user would have to manually select it.

Can a visualforce page be changed so that if a user selected "England" then "Eng" would be automatically be selected on the dependent picklist rather the user having to select it?

Thanks in advance.

Hi,
I'm creating 2 columns on one of our visualforce pages and I am able to seperate the fields into 2 columns but whenever I get this happening the field labels are removed.  The visualforce page only shows the actual input text fields but not the labels.
Below is my code on the VF page:


<apex:pageBlockSection columns="2">
            <apex:pageblock title="Account Information">
                <apex:inputField label="Lead Status" value="{!newLead.Status}" required="true" /> <br> </br>
                <apex:inputField label="Fuel Type" value="{!newLead.Fuel_Type__c}" /> <br> </br>
                <apex:inputField label="Region" value="{!newLead.Region__c}" /> <br> </br>
                <apex:outputField value="{!newLead.RecordTypeId}" /> <br> </br>
                </apex:pageblock>
                <apex:pageblock title="Account Information 2">
                <apex:inputField value="{!newLead.Consumption__c}" /> <br> </br>
                <apex:inputField value="{!newLead.Dual_Fuel__c}" /> <br> </br>
                <apex:inputField value="{!newLead.Associated_Dual_Fuel_Site__c}" /> <br> </br>
                <apex:inputField value="{!newLead.Qualification_Check__c}" /> <br> </br>
                </apex:pageBlock>
            </apex:pageBlockSection>


Am I doing something wrong here?  Does anyone know how I can get the labels to appear?
Any help is much appreciated

Hi,

We updated our data loader from version 20 to 34 yesterday and since we made the change a few of our batch jobs have stopped working - most of them are fine but 2 of the batch jobs (via windows batch file/command line) are receiving the error below.

FATAL [main] process.ProcessRunner topLevelError (ProcessRunner.java:238) - Unable to run process extractBillingAgentGas
java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot parse empty string
 at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:162)
 at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:100)
 at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:253)
Caused by: java.lang.IllegalArgumentException: Cannot parse empty string
 at com.salesforce.dataloader.mapping.SOQLInfo.getTrimmed(SOQLInfo.java:162)
 at com.salesforce.dataloader.mapping.SOQLInfo.access$000(SOQLInfo.java:38)
 at com.salesforce.dataloader.mapping.SOQLInfo$SOQLFieldInfo.<init>(SOQLInfo.java:52)
 at com.salesforce.dataloader.mapping.SOQLInfo$SOQLFieldInfo.<init>(SOQLInfo.java:72)
 at com.salesforce.dataloader.mapping.SOQLMapper.putPropertyEntry(SOQLMapper.java:99)
 at com.salesforce.dataloader.mapping.Mapper.putPropertyFileMappings(Mapper.java:139)
 at com.salesforce.dataloader.mapping.Mapper.putPropertyFileMappings(Mapper.java:134)
 at com.salesforce.dataloader.mapping.Mapper.<init>(Mapper.java:86)
 at com.salesforce.dataloader.mapping.SOQLMapper.<init>(SOQLMapper.java:58)
 at com.salesforce.dataloader.controller.Controller.createMapper(Controller.java:194)
 at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:146)

I don't know how to fix this and I can't seem to find much information on the error message - has anyone come across this issue before?
Can anyone know how to fix this error message?

Any help is much appreciated.

Hi,

We have visualforce pages in SF which contain 3 picklists, see code below.
<apex:inputField value="{!newLead.Site_County_1__c}" />

Something strange is happening for these fields, when a user has the field populated and then opens the record to edit and save. the values have disppeared when they save it again.

Has this happened to anyone before?

Hi,

I’m hoping someone can help me on writing a test class for an apex class that uses a visualforce page to create a registration record.  I just don’t understand how to create a test class to call a method called AddProducts() and add data to test the validation rules I have built into the apex class.

Please see below:

APEX CLASS:


Enrg_PartnerRegister_Ext_New {
public Registrations__c regObj {get; set;}
    public Register_Class(ApexPages.StandardController stdController) {
        PgId = System.currentPageReference().getParameters().get('p3_lkId');
     regObj = (Registrations__C)stdController.getRecord();
            
    }
                   public PageReference addProducts(){
        try{ 

                    if(regObj.Name__c == regObj.Legal_Name__c){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Name can not be the same as Legal Name'));
                        return null;
                    }
                                                                           if(regObj.Cost__c == regObj.Price__c){
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Cost can not be the same as Price'));
                        return null;
                    }
                      }
}

VISUALFORCE PAGE:

<apex:page standardController="Registrations__c" Extensions="Register_Class">
  
        <apex:sectionHeader title="Registration " ></apex:sectionHeader>
        <apex:outputPanel id="error">
            <b><apex:pagemessages /></b>
        </apex:outputPanel>    
<apex:pageblockSection title="Details">
                <apex:inputField value="{!regObj.Name__c}" required="true" />
                <apex:inputField value="{!regObj.Legal_Name__c}"  />
                <apex:inputField value="{!regObj.Cost__c}" required="true"/>
                <apex:inputField value="{!regObj.Price__c}" required="true"/>
                                                            ......

So essentially, I need a test class to test attempting to create a registration record with the Name = Legal Name and Cost = Price and then allowing the records to save.
I’ve tried a number of methods but I just can’t get anything to compile on the test class.

Can someone help point me in the right direction please?

Thanks,
RadDude89

 

Hi,

I'm having difficulty in writing a test class for my apex class that creates a new lead record based on whether an existing lead has met the conditions.  So if a lead has Web to Lead = True and H M!=null and WTL G!=null, it will take the values from that record and create a new one.  Please see below class:

APEX CLASS:

public class CreateNewLead {
 
   public static void createnewrecords(List<Lead> leadMap){
 
        List<Lead> insertList = new List<Lead>();

        for (Lead rec:LeadMap){
               if ((rec.WTL_G__c != null) && (rec.H_M__c != null) && (rec.Web_to_Lead__c==TRUE))
               {                                          
                      // Creating new record
                       Lead newlist = new Lead();      
                       newlist.WTL_M__c = rec.H_M__c;                  
                       newlist.FirstName = rec.FirstName;
                       newlist.LastName = rec.LastName;
                       insertList.add(newlist);        
               }
             
         }
        
        if(insertList.size()>0){
        insert  insertList;  
        Constantclass.isenteredtrigger=true;
        }
   }
}

 

TEST CLASS:

@isTest
private class CreateNewLead_Test {
    
    
        static  testMethod void UPDATEMPRNGRPN_Test_TestMethod1(){
                       List<Lead> leadMap = new List<Lead>();
                       List<Lead> insertList = new List<Lead>();
                       Lead Ld = new Lead(FirstName='Name2', Web_To_Lead__c=TRUE, H_M__c='12345678901', WTL_G__c='1234567');
                       insert Ld;
                       insertList.add(Ld);
                       CreateNewLead.createnewrecords(insertList);
                       }     
               }

I'm getting 0% coverage on this class however I'm not sure on what I'm doing wrong.  Can someone please help?

Hi,

I am trying to use the pattern.matches function on an apex trigger on our sandbox, what we are trying to do is update a record to Pending Validation based on whether a linked record meets the format required.

So on the trigger we have:

 

trigger Enrg_PendingValidation_Trigger on Registrations__c (Before Update, Before Insert){
for(Registrations__c reg:trigger.new){

Boolean validTelephone;
telephonePat='[0-9]{3} [0-9]{4} [0-9]{4}';

telephone = reg.Site__r.Site_Phone__c;
validTelephone= Pattern.matches(telephonePat,telephone);

if(reg.Site__r.Site_Phone__c != null && validTelephone!= true ){
               reg.Registration_Status__c='Pending Validation';                                   
               }
}
}

This trigger saves ok on Salesforce but when I try to edit and save the registration I get the error message
Script-thrown exception: Class.System.Pattern.matcher

It appears that the issue is being caused by the line validTelephone= Pattern.matches(telephonePat,telephone); as when I comment this out I am able to save the record.

Can anyone help me on this?  I can't see what I am doing wrong here.

Thanks in advance.

Hi,

We use an apex class and visualforce page for calculate which users can select which pricebooks (custom object).
Within the logic I can see that Userinfo will has been added - so this looks like it will only return pricebooks for standard license users (I think I'm correct in saying this).

What I want to do within this selection query is return the pricebooks which have the same value on User field and the same value on the current users custom field Agent.
E.g. Pricebook.User__c = User.Agent_Name__c.

Below is the current code:
if(Userinfo.getUserType() == 'Standard'){           
            priceBookList = [select Product__c,name,id, name,Description__c,Contract_Start_Date__c, Internal__c from 
            Pricebook__c where Product__c=:selectedProduct and Active__c = True];

Does anyone know how I can add this in?
Anything I seem to try doesn't work.

Thanks in advance

Hi,

I'm looking into creating a process in which Salesforce will update the parent record if a field on the child has the value 'Rejected'.

So we have a parent object - Offer and child - Offer SIte.
Then if the field Status__c on Offer Site = 'Rejected', I want to apply the same value to a field called Status on Offer automatically once the field on Offer site is updated.

Does anyone know how to do this?
I'm not too sure on how I can write this into trigger as my experience with triggers is basic

Any help is much appreciated.
Thanks.

Hi,

We have added additional logic to an aex class on our Salesforce - the logic is applied to a custom object called Registration__c.

When you create a registration, the system will go through a number of conditions and will create a record called Credit - only if sertian criteria is met.
When we test this on our sandboxes, it works perfectly but when we attempt to register a site on production:
"Insert failed. First exception on row 0; first error: TOO_MANY_ENUM_VALUE, Credit Risk Reason: too many items selected: 18517 [Credit_Risk_Reason__c}"

Below is the code which causes the issue:
    listregQry2=[Select High_Risk_Email__c, High_Risk_Phone_Number__c from High_Risk__c]                           
                if(listregQry!=null){
                    for(Registrations__c r:listregQry){
                        String CreditComReason='';
                        if(sitenames==null||!sitenames.contains(r.site__r.name)){
                            Credit_Committee__c CCobj = new Credit_Committee__c(status__c='Referred');
                            CCobj.Comments_For_Credit_Committee__c=r.Comments_For_Credit_Committee__c;
                            sitenames.add(r.site__r.name);
                            if(listregQry2!=null){                               
                                for(Bad_Debt_Data__c r1:listregQry2){                                                                      
                                    if(r1.High_Risk_Email__c == r.site__r.contact__r.email)  {                                     
                                        System.debug('high risk email');
                                        CreditComReason=CreditComReason+'High Risk Email Found;';
                                    }
                                }
                               
                                if(r.site__r.contact__r.Phone != NULL){
                                    for(Bad_Debt_Data__c r2:listregQry2){
                            if(r2.High_Risk_Phone_Number__c == r.site__r.contact__r.Phone){ 
                                System.debug('high risk contact');
                                CreditComReason=CreditComReason+'High Risk Phone Number Found;';
                            }
                            }
                            }
                        }

Does anyone know what is causing this issue? Any ideas on how to resolve?

Any help is much appreciated.

Regards,
RadDude89

Hi,

We have created an apex class and 2 triggers which execute once a registration record is created/updated in order to update the record based on certain criteria.
From this we have noticed that in the mornings the registration process can be quite slow for some users and in some cases they will get the request timed out error message.
When a system admin tries it, sometimes its slow but most of the time we can create the registration fairly quickly.

Is there anything that I should check to maybe increase the request time of the users/triggers? I've never got an error like this and we never had the error in any of our sandboxes - it just appears to be production.
Does anyone know how to resolve this/had a similiar problem?

Thanks.

Hi,

We are trying to add logic into our apex class where if the user registers a site and the mobile phone value held at contact is found on any other contact records it will update a field on registration.

So below I have these 2 lists.

listregQry= this contains the mobilephone from the contact being registered.
listregMobile= this contains all Mobile Phone values from our system

listregQry=[Select site__r.Contact__r.MobilePhone from Registrations__c where Id in : lstRegistrations ];
listregMobile=[Select Contact__r.MobilePhone from Site__c];

What I want to do is update a field called Mobile Used to TRUE when the Mobile Phone from listregQry is found on the system on a different contact record.

Does anyone know how I can achieve this?


Thanks in advance.

Hi,

We have set up an approval process called Renew.  This approval process was created via the standard process (adding email alerts, approval/rejection field updates, etc). When we create an offer record the approval process doesn't start - the user must press submit for approval.  Can you create an apex trigger to initiate an approval process when a record has been created?
So in a way we would be pressing the submit for approval for the user automatically.
Can the trigger call on the ID of the approval process to initiate it if certain requirements are met?

Hi,

I have created an approval process for a custom object called Offer which is based on several selections regarding the creation of the offer.
The offer is to be locked and sent to a manager for approval when the criteria is
Price <0.200 and Region= NI
What I have realised is that when the offer is created the approval won't start - the user has to press the Submit for Approval for it to start.

Is it possible to create a trigger to kick the approval process off automatically when the offer has been created?

Hi,

I'm trying to introduce validation on one of our apex classes which is based on a custom field value on the user's record.

So we have a custom field setup on the user object called Consultant (checkbox).
When a user logs in I want to return an error message if that current logged in user has Consultant = FALSE then show them the error message whereas for users where Consultant = TRUE they can bypass the error.

List<User> lstUser = [Select Agent_Name__c from User where userinfo.Consultant__c=TRUE];
 if(lstUser.size()==0 ){
                                apexpages.addmessage(new ApexPages.Message(ApexPages.severity.FATAL,' You can not proceed'));

When I try using userinfo. it doesn't compile so does anyone know how to retrieve a value from a custom field on user object for the current user?

Hi,

I'm trying to create a validation rule that looks at a picklist field and return an error if the value has been changed after the record is approved.

The field contains 4 selections: 14, 30, 45 and 60.

What I'm trying to achieve is a validation rule that if a user (originally created the record with 14 as the selection) was to change it to 30, then they would get an error message "you can not change after approval".

When I try using the priorvalue, it says that this function can not be used in this type of formula.
I tried changing it to use TEXT values i.e.
(TEXT(Payment_Date__c) != TEXT(PRIORVALUE(Payment_Date__c)))

However this doesn't return the error message even I'm able to save the validation rule.

Does anyone know how to achieve using priorvalue for picklists? What is the best method for this?

Hi,
I'm creating 2 columns on one of our visualforce pages and I am able to seperate the fields into 2 columns but whenever I get this happening the field labels are removed.  The visualforce page only shows the actual input text fields but not the labels.
Below is my code on the VF page:


<apex:pageBlockSection columns="2">
            <apex:pageblock title="Account Information">
                <apex:inputField label="Lead Status" value="{!newLead.Status}" required="true" /> <br> </br>
                <apex:inputField label="Fuel Type" value="{!newLead.Fuel_Type__c}" /> <br> </br>
                <apex:inputField label="Region" value="{!newLead.Region__c}" /> <br> </br>
                <apex:outputField value="{!newLead.RecordTypeId}" /> <br> </br>
                </apex:pageblock>
                <apex:pageblock title="Account Information 2">
                <apex:inputField value="{!newLead.Consumption__c}" /> <br> </br>
                <apex:inputField value="{!newLead.Dual_Fuel__c}" /> <br> </br>
                <apex:inputField value="{!newLead.Associated_Dual_Fuel_Site__c}" /> <br> </br>
                <apex:inputField value="{!newLead.Qualification_Check__c}" /> <br> </br>
                </apex:pageBlock>
            </apex:pageBlockSection>


Am I doing something wrong here?  Does anyone know how I can get the labels to appear?
Any help is much appreciated

Hi,

We updated data loader yesterday from version 20 to 34 and now one of our command line batch jobs has stopped working.  I'm unsure of the error message as I've never seen it before.

Error:

action.AbstractAction execute (AbstractAction.java:120) - Loading: upsert
2015-08-14 12:40:59,920 ERROR [upsertSiteElectricity] action.AbstractAction handleException (AbstractAction.java:204) - Exception occured during loading
java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
 at java.util.ArrayList.RangeCheck(Unknown Source)
 at java.util.ArrayList.get(Unknown Source)
 at com.salesforce.dataloader.dao.csv.CSVFileReader.readRow(CSVFileReader.java:191)
 at com.salesforce.dataloader.util.DAORowUtil.calculateTotalRows(DAORowUtil.java:67)
 at com.salesforce.dataloader.dao.csv.CSVFileReader.getTotalRows(CSVFileReader.java:218)
 at com.salesforce.dataloader.action.AbstractLoadAction.initOperation(AbstractLoadAction.java:100)
 at com.salesforce.dataloader.action.AbstractAction.execute(AbstractAction.java:122)
 at com.salesforce.dataloader.controller.Controller.executeAction(Controller.java:121)
 at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:149)
 at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:100)
 at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:253)
2015-08-14 12:40:59,920 ERROR [upsertSiteElectricity] progress.NihilistProgressAdapter doneError (NihilistProgressAdapter.java:58) - Index: 5, Size: 5

Does anyone know how to resolve this?

Any help is much appreciated.