• iBr0ther
  • NEWBIE
  • 310 Points
  • Member since 2007

  • Chatter
    Feed
  • 12
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 73
    Replies

Hi,

 

Is it possible to copy the value inputed by the user from inputfield A to inputfield B dynamically by just ticking a checkbox.?

 

Thanks,

Del

 

 

 

 

hi every one i have bloew  class ,i need a test class in order to deploy this as i create the test class but it cover only 74% i dont know which line is not coverd

 

Class

 

public with sharing class TestFlighRequestPage {
Test_Flight_Request__c fr;
public List<Opportunity> listOpp;
public String Id {get; set;}
private string result;

public TestFlighRequestPage(ApexPages.StandardController stdController)
{
fr = (Test_Flight_Request__c)stdController.getRecord();

if(fr.Id == null)
Id = ApexPages.currentPage().getParameters().get('opp');
else
Id = fr.Opportunity__c;

listOpp = [SELECT id ,Name, Departure_Date__c,Number_of_Passengers__c,Destination_Zone__c,Return_Date__c,
Origin_City__c,Destination_City__c,Flexibility_From__c,Flexibility_To__c
FROM Opportunity WHERE Id = :Id];

if(listOpp.size() >0)
{
if(fr.Opportunity__c == null)
{
fr.Opportunity__c = listOpp[0].Id;
}
if (fr.From__c == null)
{
fr.From__c = listOpp[0].Origin_City__c;
}

}
}




public void SendItineryEmail()
{
Test_Flight_Request__c FRdata = [SELECT Email_To__c, Subject__c,Email_Content__c
FROM Test_Flight_Request__c WHERE Id = :fr.Id];

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(' ');
req.setMethod('GET');

HttpResponse res = h.send(req);
result = res.getBody();
String[] toaddress = new String[]{};
toaddress.add(FRdata.Subject__c);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(toaddress);
mail.setSubject(FRdata.Subject__c);
string Emailbodydata = FRdata.Email_Content__c +'<br>'+ result;
mail.setHtmlBody(Emailbodydata);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}
}

 

 

 

TestClass

 

@isTest
private class TestFlighRequestPageTestCase {

static testMethod void myUnitTest() {
String message= '';
boolean flag= true;
String Id='';
double passengers = 0;

Contact con = new Contact();
con.FirstName = 'Anil';
con.LastName = 'Dutt';
con.Email = 'anil@swiftsetup.com';

Opportunity opp = new Opportunity();
opp.Name = 'Test Opp';
opp.StageName = 'Ticketing';
opp.p1_First_Name__c ='';
opp.p1_Last_Name__c ='';
opp.p1_Gender__c = '';
opp.p1_First_Name__c ='';
opp.p1_Last_Name__c ='';
opp.p1_Gender__c = '';
opp.DOB_Main_Passenger__c = System.now().date();
opp.Number_of_Passengers__c = 4;
opp.CloseDate = System.now().date();
opp.Departure_Date__c = System.now().date();
opp.Origin_City__c = 'DEL';
opp.Destination_City__c= 'MUI';
opp.Return_Date__c = System.now().date();
insert opp;

string oppID = opp.Id;

Test_Flight_Request__c fr = new Test_Flight_Request__c();
fr.Budget__c = '23';
fr.Publish_Fare__c = '35';
fr.Email_To__c ='anil@swiftsetup.com';
fr.Subject__c ='Test Mail';
fr.Email_Content__c ='Email Content';

List<Opportunity> listOpp = [SELECT id ,Name, Departure_Date__c,Number_of_Passengers__c,Destination_Zone__c,Return_Date__c,
Origin_City__c,Destination_City__c,Flexibility_From__c,Flexibility_To__c
FROM Opportunity WHERE Id = :opp.Id];

if(listOpp.size() > 0 )
{
if(fr.Opportunity__c == null)
{
fr.Opportunity__c = listOpp[0].Id;
}
if (fr.From__c == null)
{
fr.From__c = listOpp[0].Origin_City__c;
}

}

insert fr;
update fr;

Test_Flight_Request__c FRdata = [SELECT Email_To__c, Subject__c,Email_Content__c
FROM Test_Flight_Request__c WHERE Id = :fr.Id];

FRdata.Email_To__c = fr.Email_To__c;
FRdata.Subject__c = fr.Subject__c;
FRdata.Email_Content__c = fr.Email_Content__c;


try
{


ApexPages.StandardController sc = new ApexPages.StandardController(fr);
TestFlighRequestPage sc1 = new TestFlighRequestPage(sc);

sc1.SendItineryEmail();

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(' ');
req.setMethod('GET');

HttpResponse res = h.send(req);
String result = res.getBody();
String[] toaddress = new String[]{};
toaddress.add(FRdata.Email_To__c);
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(toaddress);
mail.setSubject(FRdata.Subject__c);
string Emailbodydata = FRdata.Email_Content__c +'<br>'+ result;
mail.setHtmlBody(Emailbodydata);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}
catch(System.CalloutException e)
{
message = e.getMessage();
}
}
}


Hello,
I have a big problem with apex scheduler. I've always get this error message, when I try to execute the scheduler: "Global type must be contained inside of a global class"
Can anyone give me a hint on this? Below is part of my code:
global class updateData implements Schedulable {
  global void execute (SchedulableContext SC) {
     DataContact dContact = new DataContact();
     dContact.UpdateContact();
  }
}
Thanks!

 

Global search is not returning records that are saved few mins back. Anyone have idea on this...

The User who created the record is able to see but other Users are not able to.

 

I am new in salesforce so i don't know about how to use vlookup? i want to insert contact records using data loader and i ma not able for attach  account id into contact sheet so please tell me is there any tool in which i wil write the account name into contact sheet and don't use account id and my contact records will be insert into contact objects?

Can the display of fields in the lookup window can be customized?

Instead of showing object name field  I want to show some other custom field

Hi,

 

I am trying to retrieve the list of users grouping by their role names:

The output should be something like:

 

Role A

   User A

   User B

Role B

   User C

   User D

 

I used the following query:

list<AggregateResult> listAr  = [select  UserRole.Name,name from User where  IsActive =true group by UserRole.Name];

 

but it is showing the duplicate alias: Name error.

 

How can I achieve this?

 

Thanks in advance!!

 

 

Is there a way to validate my check box field , in order to keep only one of all objectes should have the field ticked?

I have a javascript button called "sort products" related to an opportunity based on a custom field. We have related list hoverlinks enacted. If I click "sort products" at the top of the page in the related list, the page is refreshed within the  hover window. Conversely if I scroll to the bottom of the page to where products related list and click "sort products" button, nothing happens.

 

Why wiould the button work as intended the if it is clicked in the related hoverlist, but not at the bottom of the page. Why this problem? How can I solve it?

 

Thank you

Hi,

 

We have a custom button on Standard Account page. On click of that button we are showing user a visualforce page in a pop-up window. We have a javascript code written in that vf page which will close the popup window and refreshes the parent window. This is working fine on firefox but in IE8 instead of refreshing the parent window it is opening a new window.

 

function refresh(accID)
{
   var parent= window.opener;
   parent.location.href='/'+accID;
   window.close();
   return true;
}

 

accID-> is the accountid  selected by the user in popup window.

 

Any suggestions.

I have a trigger that, before insert, base on a value selected from a picklist on the Lead form, it will auto-populate another value to another field.  In order to do this, we maintain a mapping table where we select the mapping value from.

 

The issue I have is to write a test case.  When I do the System.assertEquals, becasue the Global_Lead_Subtype_New__c never formulated/populated from the lead object, it throws error when I try to compare two values: one inserted against one from lead object. 

 

I don't think I need to populate Lead_Subtype_New__c when formulate a lead in my test.  Would that defeat the purpose of the trigger?

 

Here are my codes.  What's the trick for doing this?

 

Trigger class:

 

trigger ETO_SourceDetail_LeadSubType on Lead (before insert) {
    // get current Lead.RecordTypeId   
    
    String strRecordTypeId = '';
    List<Id> recordTypeId = NEW List<Id>();
    List<Source_Detail__c> leadSubtype = NEW List<Source_Detail__c>();
    List<Integer> count = NEW List<Integer>();
    Integer i = 0;
    
    
    try {
        FOR (Lead l : TRIGGER.NEW) {
            try {    
                recordTypeId.add(l.recordTypeId);                      
                strRecordTypeId = recordTypeId.get(0);
                strRecordTypeId = strRecordTypeId.substring(0, 15);
                
                count.add([SELECT count() FROM Source_Detail__c WHERE Lead_Record_Type_Id__c = :strRecordTypeId AND Value_del__c = :l.Source_Details_New__c]);
                
                if (count.get(i) > 0) {
                    leadSubtype.add([SELECT Lead_Subtype__c FROM Source_Detail__c WHERE Lead_Record_Type_Id__c = :strRecordTypeId AND Value_del__c = :l.Source_Details_New__c LIMIT 1]);
                    l.Global_Lead_Subtype_New__c = leadSubtype.get(0).Lead_Subtype__c;
                }
                else {
                    l.Global_Lead_Subtype_New__c = 'Unknown';
                }
                
                System.debug('recordTypeId: ' + l.recordTypeId + ' - ' + 'Value_del__c: ' + l.Source_Details_New__c + ' - ' + 'strRecordTypeId: ' + strRecordTypeId );
                System.debug('Global_Lead_Subtype_New__c: ' + l.Global_Lead_Subtype_New__c);
                         
                i++;                                    
            } catch (Exception e) {
                l.addError('Error with Source Detail to Lead Subtype mapping. Please contact your administrator: ' + e);
            }
        } //for
    } catch(Exception e) {
        for(Lead l : Trigger.New){
            l.addError('Error with Source Detail to Lead Subtype mapping. Please contact your administrator: ' + e);
        }
    } //try        
        
    
} //class

Test method:

 

@isTest
private class testTrigger_ETO_SourceDetail_LeadSubType {
    static testMethod void myTestMethod() {
        Lead l = new Lead();
        
        l.recordTypeId = '01280000000Pxz2AAC';
        l.company = 'Test by Brian';
        l.firstName = 'Brian';
        l.lastName = 'Do';
        l.phone = '4087773456';
        l.email = 'briando@email.com';
        l.city = 'Chicago';
        l.state = 'IL';
        l.country = 'US';
        l.status = 'Open';
        l.Percent_to_Close__c = '0%';
        l.CurrencyIsoCode = 'USD';
        l.Sales_Rep_TMJ__c = 'Aaron Marks';
        l.OwnerId = '00580000003GON5';
        l.Source_Details_New__c = 'Austin eDM';       
        
        insert(l);
        
        Lead insertedLead = [SELECT Id, Global_Lead_Subtype_New__c FROM Lead WHERE Id = :l.Id LIMIT 1];
        
        
        System.assertEquals(insertedLead.Global_Lead_Subtype_New__c, l.Global_Lead_Subtype_New__c);
    }
} //end class



Thank you in advance.

 

Brian

Please Suggest.

 

Hi ,

 

I am getting an System.QueryException of  : Non-selective query against large object type' when I Query on Task.  

 

FATAL_ERROR|System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.

 

Here is the Query on Task - 

 

 List<Task> ObjTaskLst = [Select t.OnStateClient__Call_ID__c,t.Call_Start_Time__cFrom Task t WHERE t.OnStateClient__Call_ID__c IN :ActivityIdDateTimeMap.keyset() LIMIT 1];

 

Here the field 'OnStateClient__Call_ID__c'  on the Task and is a part of the Package installed in the system.Hence can not modify this field.

 

 

Please Suggest.

 

 

 

Hello friends,

 

Is it possible to call Batch class form another batch class? If possible then how.? and if not possible then pleaes explain it with proper reason

 

Thank You

Raumil Setalwad

Hi Everyone,

I'm trying to use Salesforce metadata API with flex toolkit, not sure if the metadata API is fully supported and tested with flex toolkit (drop dated Feb 22, 2008)?  First off, the compiled as3Salesforce.swc library does not contain required metadata classes like CustomObject, CustomField, etc.  I figured this might be a linking problem in sample Salesforce.mxml file, as it contains no examples for metadata API.  To work around this problem, I've included the source files under toolkit/sdk/src into my flex project.  When I try to create a custom object using Connection.createObject(customObjectArray, asyncResponder) I get the following runtime error:
(com.salesforce.results::Fault)#0
  context = (null)
  detail = (null)
  faultcode = "soapenv:Client"
  faultstring = "Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element"
My flex code looks like this:
var cf:CustomField = null;
var co:CustomObject = new CustomObject();
co.fullName = DashboardMdl.OBJECT_NAME;
co.label = DashboardMdl.OBJECT_LABEL;
co.pluralLabel = DashboardMdl.OBJECT_LABEL + "s";
co.description = "Custom object for storing SfDash dashboards.";
co.deploymentStatus = DeploymentStatus.Deployed;
co.enableActivities = true;
co.sharingModel = SharingModel.ReadWrite;

cf = new CustomField();
cf.label = "Name";
cf.type = FieldType.Text;
co.nameField = cf;

var coArray:Array = new Array();
coArray.push(co);

sfConn.createObject(coArray,
  new AsyncResponder(function (result:Object):void {
    trace("something created, perhaps Custom object!!!.");
  }, sfFault)
);
Has anyone tried using metadata API with flex toolkit?  Any suggestions?

Thanks in advance,
Baldeep Hira
http://www.bhira.net