• UV
  • SMARTIE
  • 548 Points
  • Member since 2011

  • Chatter
    Feed
  • 21
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 202
    Replies

how to check the user provided credentials(password and username) are correct or incorrect .

 

this is my page /////////////////////////////

<apex:page controller="Beaconlogin" sidebar="false" showHeader="false" id="page1">
<apex:form id="form1">

<table >
          <tr>
            <td><apex:outputText value="User id" style="color:Black;font-size:16px;font-weight:bold"/></td>
            <td><apex:inputField value="{!login.User_id__c}" id="Userid2" style="color:Black;font-size:16px;font-weight:bold" /></td>
          </tr>
          <tr>
            <td><apex:outputText value="Password" style="color:Black;font-size:16px;font-weight:bold"/></td>
            <td><apex:inputsecret value="{!login.User_password__c}" id="Password2" style="color:Black;font-size:16px;font-weight:bold" /></td>
          </tr>
          <tr><td colspan="2">&nbsp;</td></tr>
          <tr><td colspan="2">&nbsp;</td></tr>
          <tr>
            <td></td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:commandButton value="Login" action="{!login_check}"  onclick="return logincheck()" id="Login"/></td>
          </tr>
        </table>

</apex:form>

</apex:page>

 

/////////////////////////////////controller ////////////////////////////////////

public with sharing class Beaconlogin {

 public PageReference login_check() {
   
      insert login;
       pagereference ref = new pagereference('https://c.ap1.visual.force.com/apex/ApplicationForm');
   ref.setredirect(true);
        return ref;
    }

 public Beacon_login__c login { get; set; }
    public Beaconlogin()
    {
    login= new Beacon_login__c();
    }

}

Having a little trouble understand how to reference an SObject ID in my test class. The SObject was created earlier in the class and now I need to get the ID from that to populate a lookup field on another SObject for the test.  Actually, there are 3 fields in total.  I put the 2 lists in question below:

 

List 1 - No errors received here

List<IndividualAddress__c> indaddrlist = new List<IndividualAddress__c>();

for (Integer x=0;x<200;x++){
IndividualAddress__c ia = new IndividualAddress__c (Active__c=True,Address__c=addrlist.get(x).Id,Address_Type__c='Practice',
Individual__c=indlist.get(x).Id
);
indaddrlist.add(ia);
}
System.assertEquals(indaddrlist.size(),200);
insert indaddrlist;

 

List 2 - Getting an error on line below.  For IndividualAddress__c, I'm trying to iterate to get the IDs of the SObjects created in list above and populate from those.
// create individual schedule
List<Indvidual_Schedule__c> indschlist = new List<Indvidual_Schedule__c>();

for (Integer x=0;x<200;x++){
Indvidual_Schedule__c is = new Indvidual_Schedule__c (Comment__c='Test Schedule', Day__c='Monday',
Start_Time__c='08:00:00 AM', End_Time__c='09:00:00 AM', RecordTypeId='01240000000I4yx',
**TROUBLE SPOT  IndividualAddress__c =indaddrlist.get(x).Id, Individual__c = indaddrlist.Individual__c, Address__c = indaddrlist.Address__c
);
indschlist.add(is);
}

 

Thanks for any help!

Darrell

Hi,

 

I have a custom field on the opportunity object named 'contact__c'. This is a simple lookup field.

If populated I want a trigger that creates an Opportunity contact role for that same contact.

 

Any ideas?

 

I can update the contact__c field based on the primary contact role but I need this work the other way round.

 

Any ideas?

 

Thanks

 

 

Hi All,

 

I am trying to run a batsh class at regular intervals. I have writen below class but geting an error " expecting a right parentheses, found 'One'.

 

global class scheduledMerge10 implements Schedulable{

global void execute(SchedulableContext SC) {

AverageSpentDays b = new AverageSpentDays();

database.executebatch(b);
}
Schedulemerge10 b = new Schedulemerge10();
String sch = '0 0 7 07 12 ?';
system.schedule ('One', sch, b);

}

 

Is above the right way of writing a class for  scheduler?

 

~Alok

My JSON parsing code runs properly in my Sandbox env.  However when I ported it to Production I get this message: "Don't know the type of the Apex object to deserialize"

 

Help!

When the Calculate your Organization's code coverage is clicked it showed us 70% of code is covered in production

We updated around 10 test methods to have the 100% code coverage and deployed to production. Now when we checked Calculate your Organization's code coverage  again it still shows 70%.

 

Can anyone shed some light on what i am missing and what else to look at?

 

Thanks

  • December 02, 2011
  • Like
  • 0

Hi Friends,

 

          I am new to work with Batch apex. As per my requirement, i have to create one Batch apex class to process the 25000 records along the with some business validations. For this, i have some questions, which are mentioned below. Pls suggest me the way to use this.

 

1. Can we call another class in our Batch Apex class execute method()?

2. What is the maximum records size, we can set for the scope?(no.of records per batch)

3. upto how many records, the Batch Apex can work?

4.How to execute this Batch Apex? Types of executing the Batch Apex?

5. Can we call Batch Apex class in Trigger,Schedule Apex Class and VF Page?If yes, How to use?

 

   Pls provide me the information, even though i am studying the document of Batch Apex which is available from developers.salesforce.com

 

Regards,

Phanikumar

 

 

Is it possible to use a guest user via API calls to webservices?

 

If not, what are the alternatives?  Is there a way to set up your own guest users and authenticate using that guest user's credentials?

  • November 30, 2011
  • Like
  • 0

Hi,

 

I am trying to write a test class for the below web service class....

 

Any help would be highly appreciated as I don't have enough knowledge on writing test classes...

 

CLASS:

 

global class AwebservClass {
public static final list<id> pricebookidlist= new list<ID>();

public static final list<String> productlist=new list<string>();

public static list<opportunitylineitem> olilist=new list<opportunitylineitem>();

global class result{

webservice list<list<oviidresultmap>> ovimapping=new list<list<oviidresultmap>>();

}
global class oviidresultmap{
webservice id Lineitemid;
webservice list<id> oviids= new list<id>();
webservice double LocalMRS;  //number 
webservice double LocalNRS;  //number 
webservice double MRS;    //number 
webservice double NRS;    //number 
webservice id localcurrency; //look up to custom object exchange rates

}
Webservice static result getOpplineitems(id oppid){

oviidresultmap ovii=new oviidresultmap();
map<id, map<id,list<id>>> OVIIds=new Map<id, map<id,list<id>>>();
result res=new result();
Map<id,list<id>> resultsmap=new Map<id,list<id>>();
res.ovimapping.add(getovimappedids(oppid));
system.debug('result'+res);
return res;
}

public static oviidresultmap[] getOVIMappedids(id oppid){
list<oviidresultmap> ress=new list<oviidresultmap>();
map<id,list<id>> p2OlmidMap=new map<id,list<id>>();
map<id,list<list<id>>> OVImap=new map<id,list<list<id>>>();

list<id> testid=new list<id>();
map<id,id> p2Olmidmap1= new map<id,id>();
olilist =[select id,product_family_pr4__c,pricebookentryid,Local_Currency__c,Local_MRS__c,Local_NRS__c,MRC__c,NRC__c from Opportunitylineitem where opportunityid =:oppid];
if(olilist.size()>0){
for(OpportunitylineItem olm:olilist){
pricebookidlist.add(olm.pricebookentryid);
productlist.add(olm.product_family_pr4__c);

}
system.debug('productnames'+productlist);

Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>(
[select product2.id from pricebookentry
where id in :pricebookidlist]);

for(OpportunitylineItem ollm:olilist){
oviidresultmap resss=new oviidresultmap();
resss.LocalMRS=ollm.Local_MRS__c;
resss.LocalNRS=ollm.Local_NRS__c;
resss.MRS=ollm.MRC__c;
resss.NRS=ollm.NRC__c;
resss.localcurrency=ollm.Local_Currency__c;
id test=entries.get(ollm.pricebookentryid).product2.id;
resss.oviids.addall(productids(test));
system.debug('finalll'+resss.oviids);
testid.add(ollm.id);
p2OlmidMap1.put(test,ollm.id);
system.debug('oviproduct'+p2OlmidMap1);
resss.Lineitemid=p2OlmidMap1.get(test);

ress.add(resss);
}

system.debug('fff'+ress);

}
return ress;
}
public static list<id> productids(id productid){
list<id> idlist=new list<id>();
for(OVI_value__c ovi:[select id,Product__c from OVI_value__c where Product__c=:productid]){
idlist.add(ovi.id);
system.debug('ss'+idlist);

}
return idlist;
}
}

I'm only getting 79% coverage, the lines in red aren't cover, any ideas on how to increase my coverage?  Thanks!

 

Test Method:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@isTest
private class wrapperClassControllerTest {

static testmethod void wrapperClassController()
  
  {
  
 Profile p = [select id from profile where name='Standard User'];
  User user=new User(alias = 'test123', email='test123@noemail.com',
            emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
            localesidkey='en_US', profileid = p.Id, country='United States',
            timezonesidkey='America/Los_Angeles', username='test123@noemail.com');
        insert user;     

Account account = new Account();// specify all the required fields
account.name = 'testing';
insert account;
Contact contact = new Contact();// specify all the required fields
contact.lastname = 'test';
insert contact;
Case ca = new Case();
ca.accountId = account.Id;
ca.contactId = contact.Id;
insert ca;

 string userIndex=user.ID; 

        
        ApexPages.StandardController controller = new ApexPages.StandardController(ca);
        wrapperClassController sc = new wrapperClassController(controller);      
         Pagereference S = sc.processSelected();
         
 
 system.assertEquals(3,sc.userList.size());   
 
 sc.userList=sc.getUsers();  
 sc.userList[0].selected=true;    


       }

    }

 

 

 

Class:

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
public class wrapperClassController {

    public wrapperClassController(ApexPages.StandardController controller) {

    }
    
    //Our collection of the class/wrapper objects cUser 
    public List<cUser> userList {get; set;}



    //This method uses a simple SOQL query to return a List of Users
   
    public List<cUser> getUsers() {
        if(userList == null) {
            userList = new List<cUser>();
            for(User u: [select Id, Name, Email, Phone from User]) {
                // As each contact is processed we create a new cContact object and add it to the contactList
                userList.add(new cUser(u));
            }
        }
        return userList;
    }

    public PageReference processSelected() {

                //We create a new list of Users that we be populated only with Users if they are selected
        List<User> selectedUsers = new List<User>();
      

        //We will cycle through our list of cUsers and will check to see if the selected property is set to true, if it is we add the User to the selectedUsers list
        for(cUser cUse: getUsers()) {
            if(cUse.selected == true) {
                selectedUsers.add(cUse.use);
            }
        }

        // Now we have our list of selected users and can add them to the User notification object on Cases
       

      
      for(User us : selectedUsers) {
      
             // Create new Case Associate Record and Insert
         Case_Associate__c newCaseAssociateRecord = new Case_Associate__c();
         newCaseAssociateRecord.User__c =  us.ID;
         newCaseAssociateRecord.Case__c = (''+ApexPages.currentPage().getParameters().get('id'));
         
         insert newCaseAssociateRecord;  
   
      }
       // Redirect back to case record   
              
      return new PageReference('/'+ApexPages.currentPage().getParameters().get('id'));
        
    }
    // This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. 
    // In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
    
    public class cUser {
        public User use {get; set;}
        public Boolean selected {get; set;}

        //This is the contructor method. When we create a new cUser object we pass a User that is set to the 'use' property. We also set the selected value to false
        public cUser(User u) {
            use = u;
            selected = false;
        }
    }
    
  
    
}

Hi,

 

I am generating 4 fields in a WSDL from environment and I want to make 3 of them mandatory. Is there any way to make those fields mandatory in WSDL? How can I change the class to do so.

 

 

  • November 30, 2011
  • Like
  • 0

Hello, my overall goal here is to copy multiple users on any case record. 

 

I've created a custom object called Case Associate, which is a master/detail to Case.  The records in this object will include a lookup field to the selected user. Once the record is created on this object, an workflow will send an email to the user specified in the record.

 

To automate this task, I've created a custom button on the Case object called "Select Users", which brings the user to a visualforce page, which has an extension to list and select multiple users.

 

Once the users selects multiple users and clicks "Processed Selected", I want the Case Associate records to automatically populate with the amount of Users the user selects.  So to be more clear, the user is on a Case, clicks a button and selects 5 different users, then clicks "process selected"  They will then be redirected to the Case record and will see 5 records appear in the related list of Case Associate object.  Each of these records will contain a lookup to the user that was selected.

 

I altered the following code to help create this page and class, but I'm struggling on the process request method:

http://wiki.developerforce.com/page/Wrapper_Class

 

Any ideas on the code needed to pass the ID of the selectedUser into each record of the Case_Associate?

 

Below is what I've tried so far, but I get an error message:

 

public PageReference processSelected() {

//We create a new list of Users that we be populated only with Users if they are selected
List<User> selectedUsers = new List<User>();

//We will cycle through our list of cUsers and will check to see if the selected property is set to true, if it is we add the User to the selectedUsers list
for(cUser cUse: getUsers()) {
if(cUse.selected == true) {
selectedUsers.add(cUse.use);
}
}

// Now we have our list of selected users and can add them to the Case Associate object on Cases
 for(User use: selectedUsers) {
Case_Associate__c caseA = new Case_Associate__c (User__c=selectedUsers.Id);

Compile Error: Initial term of field expression must be a concrete SObject: LIST<User> 

}

insert selectedUsers;

I am trying to call a web service in PeopleSoft from salesforce (Apex class). The service requires a SOAP XML request with necessary security (username and password) in SOAP header.

 

I generated Apex classes from the WSDL following this document.

http://wiki.developerforce.com/page/Apex_Web_Services_and_Callouts

 

But there is not an option to create a SOAP request using the classes generated from WSDl2Apex.

 

Is it possible to create a complete SOAP XML HTTP request to call an external web service from an Apex class?

Is it possible to use the standard SOAP APIs in Apex to create a complete SOAP XML request in a Apex class?

 

Thanks,

Raji

 

 

 

Unable to process more than one batch. Please help. Here is the code. 

 

global class ICG_Opportunity_Disp_App_Booked implements Database.Batchable<sObject> {

global string query = null;
global string clause='';
global Boolean calledByTestClass = false;
global Datetime startDate;
global Datetime endDate;
global Datetime testdate;
global list<string> op_List = new list<string>();
// global list<string> products = new list<string>();

global ICG_Opportunity_Disp_App_Booked (){
ApexClass apexClass = [SELECT Name, Id FROM ApexClass where name = 'ICG_Opportunity_Disp_App_Booked'];
//AsyncApexJob asyncApexJob =[SELECT Id, ApexClassId, CompletedDate, JobType, Status FROM AsyncApexJob where ApexClassId=:apexClass.Id order by CompletedDate desc limit 1];
setStartEndDate();
// disposition();
// productcategory();

if(startdate!=NULL && enddate!=NULL){
system.debug('startdate:'+startdate);
system.debug('enddate:'+enddate);

op_list.add('Application booked');
op_list.add('Application in progress');
op_list.add('Application Approved');
op_list.add('Entered in Net Oxygen');
op_list.add('Application Entered');
system.debug('Op_list @@@@@@@@ ' +op_list);


query = 'select accountid,Product_Category__c,StageName,createddate FROM Opportunity where createddate >=:startdate AND createddate <=:enddate AND stagename IN :op_list';

}else{
//testdate = asyncApexJob.CompletedDate;
system.debug('testdate:'+testdate);
query = 'select accountid,Product_Category__c,stageName,createddate FROM Opportunity where createddate >=:testdate AND stagename IN :op_list';
}

system.debug('Query:'+query);
}


global private void setStartEndDate(){
Job_scheduler__c jobSchedulerSettings = Job_scheduler__c.getInstance('Date_Range_Oppty');
startdate = jobSchedulerSettings.Start_date__c;
enddate = jobSchedulerSettings.End_date__c ;
}

// Global method - start

global Database.QueryLocator start(Database.BatchableContext BC){
if(calledByTestClass) {
query +=' limit 200';
System.debug('query value: ' +query );
}
system.debug('Query:'+query);
return Database.getQueryLocator(query);
}

// Global method - execute

global void execute(Database.BatchableContext BC, List<sObject> scope){
system.debug('Executing...');
Map<ID,Set<String>> AccMap = new Map<ID,Set<String>>();
Map<String,Opportunity> AccMap2 = new Map<String,opportunity>();
try{
for(Sobject s: scope){
Opportunity custPros= new Opportunity ();
custPros = (Opportunity)s;


if(!(AccMap.containsKey(custPros.accountid))) {
Set<String> temp1 = new SET<String>();
//Date temp2;
//DateTime testdate = custPros.CreatedDate;
String key = custPros.accountid+'-'+custPros.Product_Category__c;
temp1.add(custPros.Product_Category__c);
//temp2= custPros;
AccMap.put(custPros.accountid,temp1);
AccMap2.put(key,custPros);
}else {
Set<String> temp = AccMaP.get(custPros.AccountId);
//Date temp2;
String key = custPros.accountid+'-'+custPros.Product_Category__c;
temp.add(custPros.Product_Category__c);
system.debug('this is the date we have a prob'+custPros.CreatedDate.date());
//temp2 = custPros.CreatedDate.date();
AccMap.put(custPros.accountid,temp);
AccMap2.put(key,custPros);
}

}
}Catch(Exception e){
System.debug('Preparing the Key Map Logic'+e);
}
List<Customer_Product__c> cpList = new list<Customer_Product__c>();
try{
cpList= [SELECT id,customer_Prospect__c,Product__r.Product_Category_Desc__c,CreatedDate FROM Customer_Product__c where Customer_prospect__c In:AccMap.keySet() order by createddate desc];
system.debug('Size of CP list'+cpList.size());

}Catch(Exception e){
System.debug('Customer Products Query'+e);
}

set<Opportunity> Opps= new set<Opportunity>();
list<opportunity> updateopps = new list<opportunity>();

String keyMatch;

try{
for(Customer_Product__c cp: cpList){
if(AccMap.containsKey(cp.customer_prospect__c)){
keymatch = cp.customer_prospect__c+'-'+cp.product__r.product_category_desc__c;
system.debug('KeyMatch' +keymatch);
if(AccMap2.get(keymatch)!= NULL) {
Opportunity opp = AccMap2.get(keyMatch);

if(!(opps.contains(opp))){
system.debug('OPP@@@@@@@@ ' +opp);
if(cp.createddate>opp.createddate){

opp.StageName='Application Booked';
system.debug('Created Date' +cp.createddate);
opp.CloseDate = cp.CreatedDate.date();
opps.add(opp);
system.debug('Opp..............'+opps);
}
}
}
}
}

system.debug('set of opportunities' +opps);
for(opportunity unique_op: opps){
updateopps.add(unique_op);
}
system.debug('List of opportunities' +updateopps);

}Catch(Exception e){
System.debug('Looping Customer products'+e);
}


if(UpdateOpps.size() > 0){
Database.update(UpdateOpps,false);
}
}


global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.

AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email
from AsyncApexJob
where Id =:BC.getJobId()];

// Send an email to the Apex job's submitter notifying of job completion.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {a.CreatedBy.Email};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Opportunity update ' + a.Status);
mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +' batches with '+ a.NumberOfErrors + ' failures.');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

  • November 28, 2011
  • Like
  • 0

Hi,

 

Can someone post SOQL query in apex to retrive all the opportunities created an hour ago.

 

Regards

Surender

Hello,

I am using a soql query to retrieve records from Call Report.

I am able to execute this if i have less records but if i have more records that is fr about 200 Records i am getting an exception:
Too many SOQL queries: 101 .
Please help me out of this issue.


Here is my code :

 

 

trigger DisplayRltdCallRepOnAcc on Call_Report__c(after insert, after update,after delete){
    List<Call_Report__c> lastcallRltdCallRepOnAcc = new List<Call_Report__c>();
    String relatedToClientLastCall;
    List<Account> updateAccLastCall = new List<Account>();
    Set<Id> updatelastCallAccountIds = new set<Id>();
   
    List<Call_Report__c> nextCallRltdCallRepOnAcc = new List<Call_Report__c>();
    List<Account> accsToUpdateNextCall = new List<Account>();
    String relatedToClientNextCall;
    List<Account> updateAccNextCall = new List<Account>();
    Set<Id> updateNextCallAccountIds = new set<Id>();

   
    List<Call_Report__c> rltdToClientIds = new List<Call_Report__c>();
       
    if(trigger.isInsert || trigger.isUpdate){
    System.debug('Trigger.New values:::::: '+trigger.new);
        rltdToClientIds = trigger.new;
    }else if(trigger.isDelete){
     // Note -- there is no trigger.new in delete 
       rltdToClientIds = trigger.old;
     }
     System.debug('Related to Client IDS '+ rltdToClientIds.size());
     for(Call_Report__c calldates : rltdToClientIds){
    
        if(calldates.Related_to_Client__c != null){
            lastcallRltdCallRepOnAcc = [Select Call_Date__c,Related_to_Client__c From Call_Report__c c where Status__c='Complete'
                               and c.Type__c not in ('Attempt','Email') and Call_Date__c <= TODAY
                               and Related_to_Client__c!=null and
                               Related_to_Client__c =:calldates.Related_to_Client__c order by Call_Date__c desc];
        relatedToClientLastCall = calldates.Related_to_Client__c;
        }
        if(lastcallRltdCallRepOnAcc.size() > 0){
             System.debug('Last Call Date '+lastcallRltdCallRepOnAcc[0].Call_Date__c);
             Account acc = new Account(Id = lastcallRltdCallRepOnAcc[0].Related_to_Client__c,Last_Call_Date__c = lastcallRltdCallRepOnAcc[0].Call_Date__c);
             if(updatelastCallAccountIds.add(acc.Id)){
                 updateAccLastCall.add(acc);
             }
         }
         else{
             if(relatedToClientLastCall != null){
                 Account acc = new Account(Id = relatedToClientLastCall, Last_Call_Date__c = null);
                 if(updatelastCallAccountIds.add(acc.Id)){
                     updateAccLastCall.add(acc);
                 }
             }
         }
       }

}

 

 

 

 

 

 

Thanks in advance,
Ajit.

  • October 14, 2011
  • Like
  • 0

 

Hi,

 

Please help me to deploy a trigger in production. My IDE got crashed. I used to deploy through ForceIDE, but now i want to deploy it through sandbox application. Please help..

 

Thanks and Regards

Hari G S

Any idea how to get a 100% testcov of this get set method?

 

    public List<Job_Offer__c> jobOfferList
    {
        get{
        jobOfferList = [Column1, Column2, Column3
                        From Job_Offer__c
                        Where Job__c =: jobId And (Status__c = 'Rejected' Or Status__c = 'Timed Out')
                        ORDER BY CreatedDate];
                       
        return jobOfferList;
       
        }
        set;
    }

I have written (with much help from Darshan Farswan ) a test class with an extenison. I need  some help writting the test method. I have started writting it but I'm not sure if I am heading in the right direction.

 

Here is my test method so far:

public class testNewRentalOpportunity {
 static testMethod void myUnitTest(){
 
   ApexPages.standardController controller = new ApexPages.standardController(new Renter__c());
 
 NewRenterOpportunity nro = new NewRenterOpportunity(controller);
    
    test.startTest();
    

 
 nro.rentr.Name = 'Alice Cooper';
 nro.rentr.Renters_Phone__c = '(456) 125-7895';
 nro.rentr.Renters_Email__c = 'acooper@bfr.com';
 


 
 test.stopTest();
  }
  }

 Here is my Visualforce page:

<apex:page standardController="Renter__c" extensions="NewRenterOpportunity">
 
  <apex:pagemessages /> 
 <apex:pageBlock title="Introduction">
  <apex:pageBlockSection title="Introduce Brook and yourself">
  <b><font color="green">Thank you for calling Brook Furniture Rental, This is {!$User.FirstName}!"</font></b><p/>
  
</apex:pageBlockSection>
</apex:pageBlock>  
   <apex:form >
  
<apex:pageBlock title="Renter's Information">
    <apex:pageBlockSection columns="2" title="Ask for the Customer's Information">
          <apex:inputField value="{!Renter__c.Renter_s_First_Name__c}" /> 
          <apex:inputField value="{!Renter__c.Name}" /> 
          <apex:inputField value="{!Renter__c.Renters_Phone__c}" /> 
          <apex:inputField value="{!Renter__c.Renters_Email__c}" />
   
<apex:pageBlockSectionItem ><b>Tell me about your situation and your need for renting furniture?</b> </apex:pageBlockSectionItem><p/>
    <apex:inputField value="{!Renter__c.Why_the_need_to_rent_furniture__c}" style="Width:80%;Height:80px"  /> <p/>
     <apex:inputField value="{!Renter__c.Classification__c}"  /> <p/>
    
<apex:pageBlockSectionItem ><b>How long will you to rent furniture? </b> </apex:pageBlockSectionItem><p/>
    <apex:inputField value="{!Renter__c.Lease_Terms__c}" /> <p/>
 
<apex:pageBlockSectionItem ><b> How did you hear about Brook? </b></apex:pageBlockSectionItem><p/>
    <apex:inputField value="{!Renter__c.Source__c}" /> <p/>
    
<br></br><br></br> 
<br>  
<apex:pageBlockSectionItem ><b><font color="green"> Provide 20-30 second overview of our product and service.&nbsp;&nbsp;&nbsp;--&nbsp;&nbsp;&nbsp; Offer to walk them through the website.</font></b></apex:pageBlockSectionItem><p/>  
</br> 
<br></br>

<apex:pageBlockSectionItem ><b>What is the name of your Company?</b></apex:pageBlockSectionItem><p/>
     <apex:inputField id="Company" value="{!Renter__c.Company__c}" /><p/>
<apex:pageBlockSectionItem > <b>Do you have a price range that you’re working with for renting furniture?</b></apex:pageBlockSectionItem><p/>
    <apex:inputField value="{!Renter__c.Budget__c}" /><p/>
  
<br></br><br></br>
<apex:pageBlockSectionItem ><b><font color="green"> Our collections are STARTING POINTS  - be sure to add: additional end table, nightstand, upgraded bed, lamps.</font></b></apex:pageBlockSectionItem><p/>  
<br></br> 


<apex:pageBlockSectionItem > <b>Will you need? </b> </apex:pageBlockSectionItem><p/>
    <apex:inputField value="{!Renter__c.Need_Housewares__c}" />  <p/> 
    <apex:inputField value="{!Renter__c.Need_Electronics_Appliances__c}" /><p/>
    <apex:inputField value="{!Renter__c.Need_Office_Furniture__c}" /><p/>
    <apex:inputField value="{!Renter__c.Need_Finishing_Touches__c}" /><p/>
    <apex:inputField value="{!Renter__c.Details_of_what_they_need__c}" style="Width:80%;Height:80px"  /><p/>
   
<br></br><br></br>
<apex:pageBlockSectionItem > <b><font color="green"> Present distribution fee and waiver.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Offer to create a lease or quote  </font></b> </apex:pageBlockSectionItem><p/>  
<br></br>
<apex:pageBlockSectionItem > <b><font color="green"> Find out when they will be making a decision. </font></b></apex:pageBlockSectionItem><p/>  
<br></br>
<apex:pageBlockSectionItem ><b><font color="green"> Instill urgency about fast moving furniture or closing delivery dates.  </font></b></apex:pageBlockSectionItem><p/>
<br></br>
<apex:pageBlockSectionItem > <b><font color="green"> Arrange specific day and time for follow up.  </font></b></apex:pageBlockSectionItem><p/>     
<br></br><br></br>
   
<apex:pageBlockSectionItem ><b> Are there other’s in your company who may need to rent furniture as well? </b> </apex:pageBlockSectionItem><p/>  
<apex:inputField value="{!Renter__c.Other_that_need_to_rent__c}" />  <p/>
<apex:inputField value="{!Renter__c.Other_Potential_Renters__c}" style="Width:80%;Height:80px" />  <p/>
<br></br><br></br>

<apex:pageBlockSectionItem ><b> Delivery Dates </b> </apex:pageBlockSectionItem><p/>
    <apex:inputField value="{!Renter__c.Delivery_Date__c}" />  
    <apex:inputField value="{!Renter__c.Alternate_Delivery_Date__c}" />

<apex:pageBlockSectionItem ><b> Delivery Address </b> </apex:pageBlockSectionItem><p/>    
    <apex:inputField value="{!Renter__c.Delivery_Street__c}" style="Width:50%;Height:40px" /> <p/> 
    <apex:inputField value="{!Renter__c.Delivery_City__c}"/><p/> 
    <apex:inputField value="{!Renter__c.Delivery_State__c}"/> <p/>  
    <apex:inputField value="{!Renter__c.Delivery_Zip__c}"/><p/> 
    <apex:inputField value="{!Renter__c.Showroom__c}" />  <p/> 
         

</apex:pageBlockSection>
</apex:pageBlock>

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




</apex:form>

</apex:page>

 And here is my extension:

public class NewRenterOpportunity {

    public Opportunity opp{get;set;}
    public Renter__c rentr{get;set;}
    public NewRenterOpportunity(ApexPages.StandardController controller)
    {
        rentr = (Renter__c)controller.getRecord();
        Id id = ApexPages.currentPage().getParameters().get('id');
     
    }
    public PageReference Save(){
     insert rentr;
        opp = new Opportunity();
        opp.Name =  rentr.Renter_s_First_Name__c + ' ' + rentr.Name;
        opp.Renters_Email__c = rentr.Renters_Email__c;
        opp.Renters_Phone__c = rentr.Renters_Phone__c;
        opp.StageName = 'Proposal/Price Quote';
        opp.CloseDate = System.today()+2;
        opp.Classification__c = rentr.Classification__c;
        opp.Lease_Term__c = rentr.Lease_Terms__c;
        opp.Residential_Opportunity_Source__c = rentr.Source__c;
        opp.Renter_s_Price_Range__c = rentr.Budget__c;
        opp.Need_Office_Furniture__c = rentr.Need_Office_Furniture__c;
        opp.Need_Housewares__c = rentr.Need_Housewares__c;
        opp.Need_Finishing_Touches__c = rentr.Need_Finishing_Touches__c;
        opp.Need_Electronics_Appliances__c = rentr.Need_Electronics_Appliances__c;
        opp.Other_Potential_Renters__c = rentr.Other_that_need_to_rent__c;
        opp.Pertainent_Notes__c = rentr.Why_the_need_to_rent_furniture__c; 
        opp.Potential_Renters__c = rentr.Other_Potential_Renters__c;
        opp.Delivery_Date__c = rentr.Delivery_Date__c;
        opp.Alternate_Delivery_Date__c = rentr.Alternate_Delivery_Date__c;
        opp.Delivery_Street__c = rentr.Delivery_Street__c;
        opp.Delivery_City__c = rentr.Delivery_City__c;
        opp.Delivery_State__c = rentr.Delivery_State__c;
        opp.Delivery_Zip__c = rentr.Delivery_Zip__c;
        opp.Showroom__c = rentr.Showroom__c;
 
        String AccountId;
        opp.Corporation__c = rentr.Company__c; 
        insert opp;
        PageReference ref = new PageReference('/'+opp.id);
        return ref;
    }
    public PageReference NewRenters(){
        return null;
    }
    public PageReference Cancel(){
        return null;
    }
}

 

  • September 27, 2011
  • Like
  • 0

I am new to web services and I would like to know where is a good jumping off point so that I don't get too confused. I have looked around and found the web services api developers guide and was wondering if there was anything user made that could help me. I tryed to read and understand the developer guide but with my limited exposer to web services I didn't really get anything I was reading. So if there was a user made guide out there that is a little more user friendly it would help me out alot. Thanks. 

I am trying to create a visualforce that will render as a pdf. I am recieving the following error: 

 

Error: Unknown property 'Funded_Program_Request__c.Funded_Request_Status__c' referenced in Approved_Funded_Program_Request

 

I am not sure why I am getting this error. Code is listed below.

 

<apex:page > standardController="Funded_Program_Request__c" standardStylesheets = "false" showHeader="false" renderAS="pdf" extension="ApprovedFundedProgramRequestPDF">
    <body>
        <apex:stylesheet value="{!URLFOR($Resource.styles, 'styles.css')}"/>
         <center><apex:image value="{!URLFOR($Resource.QLogicLogos,'ultimate_logo_horiz_blue_on_white_small.jpg')}"/></center>
        <center><u>
            <apex:outputText value="{!$Organization.Street}" style="font-size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.City}, {!$Organization.State} {!$Organization.PostalCode}" style="font-size:12px"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:outputText value="{!$Organization.Phone}" style="font-size:12px"/>  
        </u></center>   
        <br></br><br></br>
        <br></br><center><apex:outputText value="Approved Funded Program Request" style="font-weight:bold; font-size:30px" /></center><br></br>
        <b> Date: </b> <apex:outputText value=" {!NOW()}" /><br></br><br></br>
        <br></br><center><apex:outputText value="Program Summary" style="font-weight:bold; font-size:20px" /></center><br></br>
        <b> Funded Request status: </b> <apex:outputText value="{!Funded_Program_Request__c.Funded_Request_Status__c}" />
        <b> Funded Program Name: </b> <apex:outputText value="{!Funded_Program_Request__c.Name}" />
        <b> Funded Request status: </b> <apex:outputText value="{!Funded_Program_Request__c.Funded_Request_Status__c}" />
        <b> Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request__c.Source_Of_Funding__c}" />
        <b> Other Source of Funding: </b> <apex:outputText value="{!Funded_Program_Request__c.Other_Source_of_Funding__c" />
        <b> Theater: </b> <apex:outputText value="{!Funded_Program_Request__c.Theater__c}" />
        <b> Goal Alignment: </b> <apex:outputText value="{!Funded_Program_Request__c.Goal_Alignment__c}" />
        <b> Product Focus: </b> <apex:outputText value="{!Funded_Program_Request__c.Theater__c}" />
        <b> Other Product: </b> <apex:outputText value="{!Funded_Program_Request__c.Other_Product__c" /><br></br><center><apex:outputText value="Payment Information" style="font-weight:bold; font-size:20px" /></center><br></br><br></br>
    <b> Partner(Company Name): </b> <apex:outputText value="{!Funded_Program_Request__c.Partner__c}" />
        <br></br> <br></br><b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request__c.Street_Name__c}" />  
            <apex:outputText value="{!Funded_Program_Request__c.City__c}" />   
            <apex:outputText value="{!Funded_Program_Request__c.PostalCode__c}" />
        </apex:panelGrid></b>
        <apex:panelGrid columns="3" width="100%">
            <apex:outputText value="{!Funded_Program_Request__c.Partner_Contact__c}" />  
            <apex:outputText value="{!Funded_Program_Request__c.Contact_Email__c}" />   
            <apex:outputText value="{!Funded_Program_Request__c.Contact_Phone__c}" />
        </apex:panelGrid>
        <br></br><br></br>
        <br></br><br></br>
    </body>
</apex:page>

 

Please help!

 

Hi Guys,

 

Does anyone knows if there is anything available online where i can send my data from Salesforce using webservices? I am looking forward to do some newbie integration work for understanding..

 

 

Cheers

i have a schedule job which will run every day at 11.00 pm, i want to get all all records completed at that day. how can i do this, i dont want to miss any records.

Below is my code.

 

companyList = [
            Select a.Id,a.Name, a.Phone, a.Website, etc... From Account a
            Where a.RecordType.Name = 'Blah'
            ];
String csvString = '';
        for(Account company : companyList)
        {
            csvString += myUtil.formatCSVString(company.Id) + ','
                        + myUtil.formatCSVString(company.Name) + ','
                        + myUtil.formatCSVString(company.Phone) + ','
                        etc...
                        ;
                        
        }

 

How can I solve this error?

I am not doing any insert or update. I am just only select the data and want to do necessary thing.

 

this is where I cannot get coverage

private boolean updateSystems()
    {
        boolean result=true;
        if (null!=systems)
           {
           //from here           
List<System__c> updSys=new List<System__c>(); try { update systems; } catch (Exception e) { String msg=e.getMessage(); integer pos; // if its field validation, this will be added to the messages by default if (-1==(pos=msg.indexOf('FIELD_CUSTOM_VALIDATION_EXCEPTION, '))) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, msg)); } result=false; } } return result; }

 

  • July 04, 2013
  • Like
  • 0

I've been working on this trigger for days and I'm stuck.  

 

It's supposed to add the number of hours from a new budget to the hours that already exist on a project.  The first version worked, but testing was throwing Too many SOQL queries: 101 error.

 

So I tried to add the lists in and now I'm getting the following message and the trigger doesn't work.   

      System.DmlException: Insert failed. First exception on row 0; first error:      

      CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, SumChangeHours: execution of AfterInsert

      caused by: System.ListException: List index out of bounds: 0

      Trigger.SumChangeHours: line 49, column 1: []

 

Can someone help me, please?

 

Version 1

trigger SumChangeHours on pse__Budget__c (after insert, after update ,after delete) {
List<pse__Proj__c> listProjToUpdate = new List<pse__Proj__c>();
    Set<ID> setProjIds = new Set<ID>();
    List<Database.SaveResult> dmlResults;
    
if(trigger.isInsert || trigger.isUpdate){
        for(pse__Budget__c B : trigger.new){
            if(B.pse__Project__c != null) {
                setProjIds.add(B.pse__Project__c);
            }
        }
    }    

    if(trigger.isDelete){ 
        for(pse__Budget__c B : trigger.old){  
            if(B.pse__Project__c != null ){ 
                setProjIds.add(B.pse__Project__c);            
            }
        }
    }
    
System.debug('##########setProjIds:'+setProjIds);

   for(pse__Proj__c proj : [Select Id, Total_Installation_Hours_Sold__c, Total_CAD_Hours_Sold__c, Total_Commissioning_Hours_Sold__c, Total_Network_Engineer_Hours_Sold__c, Total_Programming_Hours_Sold__c, Total_Pro_Services_Hours_Sold__c, 
       (Select Id, pse__Project__c, CAD_Hours__c, Commissioning_Hours__c, Installation_Hours__c, Network_Engineer_Hours__c, Programming_Hours__c, Pro_Services_Hours__c From pse__Budgets__r) 
       From pse__Proj__c Where Id IN :setProjIds]){       

    proj.Total_CAD_Hours_Sold__c=0;
    proj.Total_Commissioning_Hours_Sold__c=0;
    proj.Total_Installation_Hours_Sold__c=0;
    proj.Total_Network_Engineer_Hours_Sold__c=0;
    proj.Total_Programming_Hours_Sold__c=0;
    proj.Total_Pro_Services_Hours_Sold__c=0;


    for(pse__Budget__c B : proj.pse__Budgets__r){

        if( B.CAD_Hours__c != null){
            proj.Total_CAD_Hours_Sold__c+= B.CAD_Hours__c;}
        
        if(B.Pro_Services_Hours__c != null){
            proj.Total_Pro_Services_Hours_Sold__c += B.Pro_Services_Hours__c;}

        if(B.Programming_Hours__c!= null){
             proj.Total_Programming_Hours_Sold__c += B.Programming_Hours__c;}
            
        if(B.Installation_Hours__c != null){
            proj.Total_Installation_Hours_Sold__c += B.Installation_Hours__c;}

        if(B.Network_Engineer_Hours__c != null){
            proj.Total_Network_Engineer_Hours_Sold__c += B.Network_Engineer_Hours__c;}    

      }
      listProjToUpdate.add(proj);
    }


//Update Project Records
  dmlResults = Database.update(listProjToUpdate,false);
  //Process the Update results.
  addErrorMsgs(dmlResults);
  
  public void addErrorMsgs(List<Database.SaveResult> results){
    for(Database.SaveResult result : results){
      if( !result.isSuccess() ){
        
        for(Database.Error DbError : result.getErrors()){
          // Check if the error is related to trival access level.
          // Access levels equal or more permissive than the object's default
          // access level are not allowed.
          // These sharing records are not required and thus an insert exception is acceptable.
          if(DbError.getStatusCode() == StatusCode.FIELD_INTEGRITY_EXCEPTION &&
          DbError.getMessage().contains('AccessLevel')){
          // Indicates success.
            continue;
          }else{
            System.debug('##Error:'+DbError.getMessage());
            
            if(trigger.isInsert || trigger.isUpdate)
              trigger.new[0].addError(DbError.getMessage());
            
            if(trigger.isDelete)
              trigger.old[0].addError(DbError.getMessage());
          }
        }
      }
    }
  }

}

 Version 2

trigger SumChangeHours on pse__Budget__c (after insert, after update ,after delete) {

List<pse__Proj__c> listProjToUpdate = new List<pse__Proj__c>();

    //set of ids for triggered budgets
    set<ID> setBudgetIds= new set<ID>();
    
    // set of project ids for triggered transaction line items. 
    set<ID> setProjectIds=new set<ID>(); 

    //Map from Project.Id to Project object
    map<ID,pse__Proj__c> mapProjIdToProject = new map<ID,pse__Proj__c>();

    //temp project for updating
    pse__Proj__c oTmpProject;

List<Database.SaveResult> dmlResults;

    //when budget is added or updated
    if(trigger.isInsert|| trigger.isUpdate){

        //adding budget ids from trigger.new
        for(pse__Budget__c OB : Trigger.new){
            setBudgetIds.add(OB.id);
            }
        }

    //when budget is deleted
    if(trigger.isDelete){
        //adding budget ids from trigger.old
        for(pse__Budget__c OB : Trigger.old){
            setBudgetIds.add(OB.id);
            }
        }

    //making map of projects for updating
    List<pse__Proj__c> proj = [Select Id, Total_Installation_Hours_Sold__c, Total_CAD_Hours_Sold__c, Total_Commissioning_Hours_Sold__c, Total_Network_Engineer_Hours_Sold__c, Total_Programming_Hours_Sold__c, Total_Pro_Services_Hours_Sold__c, 
       (Select Id, pse__Project__c, CAD_Hours__c, Commissioning_Hours__c, Installation_Hours__c, Network_Engineer_Hours__c, Programming_Hours__c, Pro_Services_Hours__c From pse__Budgets__r) 
       From pse__Proj__c Where Id IN :setProjectIds];{   

    //clearing out the older values for project's specific fields
    proj[0].Total_CAD_Hours_Sold__c=0;
    proj[0].Total_Commissioning_Hours_Sold__c=0;
    proj[0].Total_Installation_Hours_Sold__c=0;
    proj[0].Total_Network_Engineer_Hours_Sold__c=0;
    proj[0].Total_Programming_Hours_Sold__c=0;
    proj[0].Total_Pro_Services_Hours_Sold__c=0;
    
    //adding to map projects
    mapProjIdToProject.put(proj[0].Id, Proj[0]);
    
    //Making set of all related budget ids.
    for(pse__Budget__c OBH : Proj[0].pse__Budgets__r){
        setBudgetIds.add(OBH.id);
        }

    //updates project's fields to new value
    oTmpProject = mapProjIdToProject.get(proj[0].id);
    for(pse__Budget__c OB : proj[0].pse__Budgets__r){

        if(OB.CAD_Hours__c != null){
            oTmpProject.Total_CAD_Hours_Sold__c+= OB.CAD_Hours__c;}
        
        if(OB.Pro_Services_Hours__c != null){
            oTmpProject.Total_Pro_Services_Hours_Sold__c += OB.Pro_Services_Hours__c;}

        if(OB.Programming_Hours__c!= null){
             oTmpProject.Total_Programming_Hours_Sold__c += OB.Programming_Hours__c;}
            
        if(OB.Installation_Hours__c != null){
            oTmpProject.Total_Installation_Hours_Sold__c += OB.Installation_Hours__c;}

        if(OB.Network_Engineer_Hours__c != null){
            oTmpProject.Total_Network_Engineer_Hours_Sold__c += OB.Network_Engineer_Hours__c;} 

        }
        }

    //Update Project Records
    dmlResults = Database.update(mapProjIdToProject.values(),false);
    //Process the Update results.
    addErrorMsgs(dmlResults);

public void addErrorMsgs(List<Database.SaveResult> results){
    for(Database.SaveResult result : results){
      if( !result.isSuccess() ){
        
        for(Database.Error DbError : result.getErrors()){
          // Check if the error is related to trival access level.
          // Access levels equal or more permissive than the object's default
          // access level are not allowed.
          // These sharing records are not required and thus an insert exception is acceptable.
          if(DbError.getStatusCode() == StatusCode.FIELD_INTEGRITY_EXCEPTION &&
          DbError.getMessage().contains('AccessLevel')){
          // Indicates success.
            continue;
          }else{
            System.debug('##Error:'+DbError.getMessage());
            
            if(trigger.isInsert || trigger.isUpdate)
              trigger.new[0].addError(DbError.getMessage());
            
            if(trigger.isDelete)
              trigger.old[0].addError(DbError.getMessage());  
          }
        }
      }
    }
  }

  
}

 Thanks!

Hi,

 

I was just watching a an APEX webinar @ http://wiki.developerforce.com/page/Webinar:_Intro_to_Apex_Code_(2012-July)

 

There I came accross a code (@ time approx. 48min. of video)

 

 String query String = 'SELECT name, celebrity__c, celebrity_r.name, destination__c,city__c,status__c' + 
                                        'FROM reservation__c';
 
         if(reservationNum != null && reservationNum != ' '){
            reservationNum = string.escapeSingleQuotes(reservationNum); // To Avoid SOQL Injection
            reservationNum = reservationNum.startswith('%') ? reservationNum : '%' + reservationNum ;
            reservationNum = reservationNum.endswith('%') ? reservationNum : reservationNum +  '%' ;
            queryString += whereOrAndClause() + 'Name like\'' + reservationNum + \'';
         }
 
Here I couldn't understand what does whereOrAndClause()  do ? What would be its return type (I think it should be String) ?
Can anybody please suggest what should be written in this method?
 
Thanks in advance.:)
I am quite new to APEX programming.
  • December 31, 2013
  • Like
  • 0

I ahve one custom object which contains following fileds

 

Owner-id,

Owner-name

Property-id

Property-name

Propety value.

 

Now i want to insert  data into this object through CSV file..The csv file conatins same fileds and data..Please help me out guys...

 

Thanks in Advance...

Hi all,

 

     I wnat to create a custom button in case side bar.

 

    please help me to do that 

 

 Thanks 
situ

  

hello,
I want to create ".Zip" file by APEX which can include other files like .jpg,.txt etc...

 

THANXS..

  • August 22, 2012
  • Like
  • 0

Hi,

how to display pagenumber in vf tage

 

like  current pagenumber of total page numbers (ex pagenumber 1of 10)

 

 

 

Thank you.

how to check the user provided credentials(password and username) are correct or incorrect .

 

this is my page /////////////////////////////

<apex:page controller="Beaconlogin" sidebar="false" showHeader="false" id="page1">
<apex:form id="form1">

<table >
          <tr>
            <td><apex:outputText value="User id" style="color:Black;font-size:16px;font-weight:bold"/></td>
            <td><apex:inputField value="{!login.User_id__c}" id="Userid2" style="color:Black;font-size:16px;font-weight:bold" /></td>
          </tr>
          <tr>
            <td><apex:outputText value="Password" style="color:Black;font-size:16px;font-weight:bold"/></td>
            <td><apex:inputsecret value="{!login.User_password__c}" id="Password2" style="color:Black;font-size:16px;font-weight:bold" /></td>
          </tr>
          <tr><td colspan="2">&nbsp;</td></tr>
          <tr><td colspan="2">&nbsp;</td></tr>
          <tr>
            <td></td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <apex:commandButton value="Login" action="{!login_check}"  onclick="return logincheck()" id="Login"/></td>
          </tr>
        </table>

</apex:form>

</apex:page>

 

/////////////////////////////////controller ////////////////////////////////////

public with sharing class Beaconlogin {

 public PageReference login_check() {
   
      insert login;
       pagereference ref = new pagereference('https://c.ap1.visual.force.com/apex/ApplicationForm');
   ref.setredirect(true);
        return ref;
    }

 public Beacon_login__c login { get; set; }
    public Beaconlogin()
    {
    login= new Beacon_login__c();
    }

}

How do I send a POST request with paramters?

I want to send a username and password.

 

Also, how do you process/retrieve the parameters in another page?

Hi my sandbox is refreshed now i need to do both configuration and as well as coding can i do it on config only sand box

Hi,

 

The Partner or Enterprise SFDC WSDL failed when imported into soap ui client. Here is the error thrown by soap ui. Any help, please ?

 

Error loading [file:/C:/Documents%20and%20Settings/Bureau/SalesForce.wsdl]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Use of undefined namespace prefix: xsd

 

All the best,

 

Anzar,


Hello Dev Community,

 

I have a batch test class that is giving me some trouble. It is giving me the following error when I try and deploy the class:

 

Test failure, method: BatchUpdateContactPayments.testUpdateContactPayments -- Sy
stem.UnexpectedException: No more than one executeBatch can be called from withi
n a testmethod. Please make sure the iterable returned from your start method m
atches the batch size, resulting in one executeBatch invocation. stack External
entry point

 

Here is the test method I'm trying to deploy the class with:

 

public static testMethod void testUpdateContactPayments() {

Account[] accts = new Account[]{};
for (integer i=0;i<11;i++) {
accts.add(new Account(name='DAcct1a' + i, pymt_Payments_Made__c = 10));	
}
for (integer i=0;i<11;i++) {
accts.add(new Account(name='DAcct1b' + i));	
}
insert accts;

Account acct1 = new Account(name='DAcct1', pymt_Payments_Made__c = 10);
insert acct1;

Contact[] contacts = new Contact[]{};
//contacts with account and no total payment amount not changed
for (integer i=0;i<5;i++) {
contacts.add(new Contact (firstname = 'Joey',
lastname = 'ApexTest'+ i,
mailingstreet = '123 Oak',
mailingcity = 'Encinitas',
mailingpostalcode = '111111',
mailingcountry = 'US',
email = 'joeyapextest12354@test.com',
pymt_Payments_Made__c = 10,
accountid = acct1.id));
}
//contacts with account and total payment amount changed
for (integer i=0;i<5;i++) {
contacts.add(new Contact (firstname = 'Joey',
lastname = 'ApexTest'+ i,
mailingstreet = '123 Oak',
mailingcity = 'Encinitas',
mailingpostalcode = '111111',
mailingcountry = 'US',
pymt_Payments_Made__c = 0,
email = 'joeyapextest12354@test.com',
accountid = acct1.id));
}
//contacts with no account
for (integer i=0;i<11;i++) {
contacts.add(new Contact (firstname = 'Joey',
lastname = 'ApexTest'+ i,
mailingstreet = '123 Oak',
mailingcity = 'Encinitas',
mailingpostalcode = '111111',
mailingcountry = 'US',
email = 'joeyapextest12354@test.com'));
}
insert contacts;

String query = '';
    if (contacts.size()>0){
        String contactIdList = '';
        for (Contact c :contacts) {
            contactIdList += '\''+c.Id+'\',';
        }
        contactIdList = '('+contactIdList+')';
        contactIdList = contactIdList.replace(',)',')');  // remove trailing comma
        query  = 'Select id, pymt__Account__r.pymt_Payments_Made__c, pymt__Contact__r.pymt_Payments_Made__c, pymt__Contact__r.Account.pymt_Payments_Made__c, pymt__Account__c, pymt__Contact__c, pymt__Contact__r.AccountId, pymt__amount__c, pymt__status__c from pymt__PaymentX__c where (pymt__status__c like \'Completed\'  or pymt__Status__c like \'Charged\') and isDeleted = false and pymt__Amount__c <> null and (pymt__Account__r.Name like \'DAcct1%\' or pymt__contact__c in '+contactIdList+') limit 200';  

}
    

List<pymt__PaymentX__c> payments = new List<pymt__PaymentX__c>{};
List<pymt__PaymentX__c> LoneAcctpayments = new List<pymt__PaymentX__c>{};
for (Account a :accts) {
    for (Integer i=0; i<2; i++) {
    	
    LoneAcctpayments.add(new pymt__PaymentX__c(name = 'ApexTest Payment1: '+ a.name,
    pymt__status__c = 'Completed',
    pymt__amount__c = 20.00,
    pymt__account__c = a.id));
    }
	
}
insert LoneAcctpayments;

for (Contact c :contacts) {
        
    for (Integer i=0; i<2; i++) {
    payments.add(new pymt__PaymentX__c(name = i+ 'ApexTest Payment1: '+ c.lastname,
    pymt__status__c = 'Completed',
    pymt__amount__c = 5.00,
    pymt__contact__c = c.id));
    }
}


pymt__PaymentX__c payment2 = new pymt__PaymentX__c();
payment2.name = 'ApexTest Payment2: '+ acct1.name;
payment2.pymt__status__c = 'Completed';
payment2.pymt__amount__c = 5.00;
payment2.pymt__account__c = acct1.id;
payments.add(payment2);
insert payments;


Test.StartTest();
BatchUpdateContactPayments batchUpdate = new BatchUpdateContactPayments(query);
//apexTestMode = true; 
ID batchprocessid = Database.executeBatch(batchUpdate);
Test.StopTest();
//Contact cont = [Select id, pymt_payments_made__c from Contact where Id = :contacts[0].Id];
//System.debug('APEXDEBUG' + cont.pymt_payments_made__c);
//Account acc = [Select id, pymt_payments_made__c from Account where Id =: acct1.id];
//System.debug('APEXDEBUG' + acc.pymt_payments_made__c);


}

 

I've browsed the forums and haven't found an answer that I've been able to apply. I'm looking for any pointers or help to understand what I can do to fix this error. Any help is much appreciated.  Thanks all!

 

 

 

 

Good day, 

 

I trying to create a trigger which intend to update oppty field if contact role are inserted, and noticed that we can't create a trigger for OpportunityContactRole object, and worst, the opportunity trigger seem do not trigger on update when new contact role record are created, but noticed lastmodifiedDate is changed on opportunity.

 

I would appreciated if someone point out if i wrong in understanding this limitation and possible state any mistake of the trigger as well (I'm newbie of SFDC)

 

trigger MycontactRoleTrigger on Opportunity (before update) {
	
List<OpportunityContactRole> opptyContactRoleList= [SELECT contact.name, 
ContactId, Id, CreatedById, CreatedDate, IsDeleted, LastModifiedById, LastModifiedDate, 
OpportunityId, IsPrimary, Role, SystemModstamp FROM OpportunityContactRole 
WHERE OpportunityId IN :trigger.newmap.keyset() ];
									
System.debug('opptyContactRoleList list = '+opptyContactRoleList);									
	

if(trigger.isBefore){			
			for(Opportunity oppty : trigger.new){
				if(al.StringUtils.isBlank(oppty.contactPersonName__C) )){
					for(OpportunityContactRole ocr :opptyContactRoleList){
						if(al.StringUtils.equalsIgnoreCase(oppty.id,ocr.OpportunityId)){							
							oppty.contactPersonName__C 	 = ocr.contact.name;							
							break;
						}
					}
				}
			}
		}
	
	}

 

Hi,

 

I am sending some email notification to admin and owner on case attachment.

 

This is working fine when a standard user does case attachment,but when a portal user does case attachment the following exception is throws:

 

AttachmentNotifier: execution of AfterInsert

caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Portal user can't own an activity: []

 

I am not getting what i am missing.

 

Regards,

Chandra