• iBr0ther
  • NEWBIE
  • 310 Points
  • Member since 2007

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

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

  • January 30, 2012
  • Like
  • 0

I have a class

public with sharing class A {
   
     public String str         {get; set;}
    public cobj__c co   {get; set;}

    public A(String st)
    {
        str= st;
        co= null;
    }

}

 i also have a list of this class

list<A> LstA = new list<A>();

 How do i add values into this list?

 

 

 

  • September 21, 2011
  • Like
  • 0

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

  • September 20, 2011
  • Like
  • 0

I have a trigger on contact and a trigger on Account. The trigger on Account update the contacts and hence ends up firing the contact trigger.


The contact trigger has addError - I double checked, it is on the record included in the trigger.

 

If I am updating an Account from UI,  and the contact addError fires, I get the "SObject row does not allow errors".


If I am updating a contact, how do I know what fired the contact trigger?

 

 

 



I am able to get all the Id's problem is it has more than 10 Id and I need to do a callout for each and every Id

I need to go for BulkCallout but bulk is supporting only 1 callout ,is there any way that i can do a callout outside and get all the Id's and pass those id's to Bulk class

 

@Future(callout=true) 

public static void updateAccount() {
    //construct an HTTP request    HttpRequest req = new HttpRequest();    req.setEndpoint('https://api.yourmembership.com'); 

  req.setMethod('GET'); 

  req.setBody('<?xml version="1.0" encoding="utf-8" ?><YourMembership><Version>1.70</Version><ApiKey>XXXXXXXXXXXXXXX</ApiKey><CallID>1</CallID><SaPasscode>XXXXXXX</SaPasscode><Call Method="Sa.NonMembers.All.GetIDs"></Call></YourMembership>'); 

      Http http = new Http();    HttpResponse res = http.send(req);   

Dom.Document doc = res.getBodyDocument();   

Set<string> st = new Set<string>();   

for(dom.XmlNode node : doc.getRootElement().getChildElements()) {    if(node.getName()=='Sa.NonMembers.All.GetIDs') {  for(dom.XmlNode node2 :node.getChildElements())  {  if(node2.getName()=='NonMembers'){  for(dom.XmlNode node3 :node2.getChildElements()){    st.add(node3.getText());  }    }   }      }}

 

this is the other callout..

HttpRequest reqP = new HttpRequest();    reqP.setMethod('GET');    reqP.setEndpoint('https://api.yourmembership.com');   

reqP.setBody('<?xml version="1.0" encoding="utf-8" ?><YourMembership><Version>1.70</Version><ApiKey>xxxxxxx</ApiKey><CallID>'+CallId+'</CallID>

<SaPasscode>xxxxxx</SaPasscode>

<Call Method="Sa.People.Profile.Get">

<ID>'+listStrings[i]+'</ID>

</Call></YourMembership>'); 

  Http httpP = new Http();   

HttpResponse resP = httpP.send(reqP);   

Dom.Document docP = resP.getBodyDocument();    

 

I have a custom link on a custom object Customer, which is an on click Javascript.

 

This link redirects to a new record page of another object MM Account based on some condition, and it pre-populates Customer.name in a field on the redirected page. 

Following is the code for the button:

 

if( (({!Customer__c.MMAccountHolder__c}) == false) )
{
	var str = '{!Customer__c.Name}';
	str.replace("\"", "\\\"");
	window.location="/a0B/e?retURL={!Customer__c.Id}&00NA0000006AZ4u={!Customer__c.Customer_Number__c}&CF00NA0000006AZ4p="+str+"";
}
else
{
             window.location="/{!Customer__c.MMid__c}";
}

 It works fine when usually, but whenever there is a single quote in the customer name, it gives a javascript error, "expected ; "

 

I have in past, handled double quote, but cant seem to handle the single quote.

 

Can anyone please look into this.

 

Thanks for any help.

 

~Sumit

  • September 19, 2011
  • Like
  • 0

I am fairly new to Apex classes and triggers, but I am finding my feet with the code I have recently written.

 

Having written and tested the code I am now trying to deploy it in the main org, but I get an error when I try to validate it.

 

The most frustrating thing is that the validation error is being triggered by some code previously written by a developer - it seems that some validation rules, introduced since the developer wrote his code, are causing the problem.

 

What I don't understand is that I seem to have fixed the problem but am still getting the error message.

 

Here is the error:

	Failure Message: "System.DmlException: Update failed. First exception on row 0 with id 0062000000JZehyAAD; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please enter an email address on the contact page before closing deal.: []", Failure Stack Trace: "Class.TestTriggers.Test_AllTriggers: line 82, column 9 External entry point"

 And here is the test class that seems to be causing the issue:

@IsTest private class TestTriggers {

     static testMethod void Test_AllTriggers(){
    
    //Create an SRT for user 2020 mgt in Aug
        SRT__c srt = New SRT__c(Name='Test SRT',User__c='00520000001BboG',Date__c=System.Today(),New_Business_Target__c=10000,Online_Target__c=1000);
        insert srt;
        
        //Integer lastMonth = Date.month(srt.Date__c)-1;
        Date d = srt.Date__c;//Date.newInstance(Date.year(srt.Date__c), , pInteger)
        d  = d.AddMonths(-1);
        SRT__c srtLastMonth = New SRT__c(Name='Test SRT',User__c='00520000001BboG',Date__c=d,New_Business_Target__c=10000,Online_Target__c=1000);
        insert srtLastMonth;
        
        srt.Last_Month_s_SRT__c=srtLastMonth.id;
        update srt;
        SRT__c srtTest = [Select OwnerId,User__c from SRT__c where Id = :srt.id];
        
                
        //Add an account
        User u = [select id from user where lastname = 'burns' and isactive=true limit 1];
        Account acc = New Account(Name='Adam test',OwnerId=u.id,Billingstreet='asa',BillingPostalCode='test',Billingcity='test',billingcountry='United Kingdom');
        
        Insert acc;
        //Get delegate record type Id
        List<Schema.RecordTypeInfo> contactRecordTypeInfos = Contact.SobjectType.getDescribe().getRecordTypeInfos();
        RecordType rt;
        
        for(Schema.RecordTypeInfo item : contactRecordTypeInfos){
            
            if(item.getName()=='Delegate'){
                rt = New RecordType(id=item.getRecordTypeId()) ;    
            }
        }
        
        //Add a contact
        Contact con = New Contact(AccountID= acc.Id,RecordTYpeId=rt.id,Lastname='Tester',Email='test@test.com');
        insert con;
        String conOwnerId = [select ownerid from contact where id = :con.id].ownerid;
        
        System.debug('Account Owner ID' + acc.OwnerId);
        System.debug('Contact Owner ID' + conOwnerId);
        System.assert(acc.Ownerid <> conOwnerId);
        
        //Add an opportunity
        List<Opportunity> oppArray = New List<Opportunity>();
        oppArray.add(New Opportunity(AccountId=acc.Id,Name='Opp Test',CloseDate=System.today(),Stagename='No ANswer'));
        oppArray.add(New Opportunity(AccountId=acc.Id,Name='Opp Test',CloseDate=System.today(),Stagename='No ANswer'));
        //Opportunity opp = New Opportunity(AccountId=acc.Id,Name='Opp Test',CloseDate=System.today(),Stagename='No ANswer');
        Opportunity opp = New Opportunity(AccountId=acc.Id,Name='Opp Test',CloseDate=System.today(),Stagename='No ANswer');
        insert opp;
        //insert oppArray;
        list<id> oppId = New list<id>();
        
        for(integer i = 0;i<oppArray.size();i++){
            oppId.add(oppArray[i].id);
        }
       System.debug('|||||' + oppId);
        Opportunity oppTest = [select name,deal_ref__c from opportunity where id = :opp.Id];
        //oppTest[0].CDSOpportunity__c =true;
        //oppTest[1].CDSOpportunity__c =true;
        //update oppTest;
        System.debug('@@@@@@' + oppTest);
        System.assert(oppTest.Name == oppTest.Deal_Ref__c);
        
        // Add an item
        
        //create an event/Issue
        Issue_Year__c ei = New Issue_Year__c(Name='Test',Description__c = 'Test Desc',Product__c='CFO',Date__c=System.today(),Mag_or_Event__c='Mag',Online__c='No', Copy_Deadline__c=System.today());
        insert ei;
        List<Schema.RecordTypeInfo> itemRecordTypeInfos = Item__c.SobjectType.getDescribe().getRecordTypeInfos();
        
        for(Schema.RecordTypeInfo item : itemRecordTypeInfos){
            
            if(item.getName()=='Delegate'){
                rt = New RecordType(id=item.getRecordTypeId()) ;    
            }
        }
        opp.StageName = 'Closed - Awaiting Approval';
        opp.Invoice_Address__c = 'Company';
        opp.Address_Invoice_to_contact_above__c = 'yes';
        update opp;
        Item__c item = New Item__c(Payment_terms__c='7 days',Probability__c=100,RecordTYpeId = rt.Id,Attendee__c=con.id,Name='Item Test',Opportunity__c=opp.id,Item_Sold__c='delegate',Event_Issue__c=ei.id);
        insert item;
        
        Item__c itemTest = [Select Line_Number__c from Item__c where id = :item.id];
        System.assert(itemTest.Line_Number__c == 1);
        Integer contactAttendanceCounter = [select count() from ContactAttendance__c where Contact__c = :con.id];
        System.Assert(contactAttendanceCounter==1);
        
        //Change the opportunity to be closed won
        opp.StageName = 'Closed test';
        //opp.Probability = 100;
        Update opp;
        
        opp.StageName = 'Closed Won';      
        Update opp;
        
       item.Overide_Deal_Date__c = d.addYears(2);
       
       update item;
        
        //opp.CDSOpportunity__c = true;
        //update opp;
        opp.StageName = 'Closed test';
        update opp;
        delete item;
        delete opp;
        
        
    }
}

 As you can see, I have set the email address on the contact page here:

        //Add a contact
        Contact con = New Contact(AccountID= acc.Id,RecordTYpeId=rt.id,Lastname='Tester',Email='test@test.com');
        insert con;

So what am I doing wrong?

 

Thanks for your help.

Hey Guys,

 

I'm trying to work out how I can return an array of a class in a webservice, I know I can do lists / arrays of sobjects and standard types, but if I have a class such as:

 

 

	global class CObject
	{
		string	ObjectName;
		double	Value;
	}

And I try and return a class which includes a list/array of those:

 

 

	global class GetObjectResult
	{
		webservice integer					NumResults;
		webservice boolean					Error;
		webservice string					ErrorMessage;
		webservice list<CObject>			        Objects;
		
		global GetObjectResult()
		{
			NumResults = 0;
			Error = false;
			ErrorMessage = '';
			Objects = new list<CObject>();
		}
	}

 

The web service method being:

 

	webservice static GetObjectResult GetObject(GetObjectRequest req)
	{
		GetObjectResult res = new GetObjectResult();
		
		
		if(req == null)
		{
			res.ErrorMessage = 'Invalid request.';
			res.Error = true;
			return res;
		}
		
		if(req.ObjectName == null)
		{
			res.ErrorMessage = 'ObjectName can not be null.';
			res.Error = true;
			return res;
		}
		
		string strNameMatch = '%' + req.ObjectName + '%';
		
		for(Basic_Object__c sObj : [select	Id, Name__c, Value__c
						from	Basic_Object__c
						where	Name__c like : strNameMatch
						limit	100])
		{
			CObject obj = new CObject();
			obj.ObjectName = sObj.Name__c;
			obj.Value = sObj.Value__c;
			res.Objects.add(obj);
		}

		res.NumResults = res.Objects.size();
		
		return res;
	}

 

 

Then I only get the name of the array / list member variable repeated n times:

 

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/IPhoneWebServices">
   <soapenv:Body>
      <GetObjectResponse>
         <result>
            <Error>false</Error>
            <ErrorMessage/>
            <NumResults>3</NumResults>
            <Objects/>
            <Objects/>
            <Objects/>
         </result>
      </GetObjectResponse>
   </soapenv:Body>
</soapenv:Envelope>

 

Anyone know of a way to actually show my fields and values?

 

Cheers :)

 

plz provide some illustration on the Record Type New to salesforce.

Thanks

 

  • April 28, 2010
  • Like
  • 0

Hello all,

 

I am trying to create a trigger that sets a Currency Field in the Object, to the result of what a formula was.  The issue is that when i do this, it says 

 

Error:Apex trigger UpdatePriceValue caused an unexpected exception, contact your administrator: UpdatePriceValue: execution of AfterUpdate caused by: System.Exception: Record is read-only: Trigger.UpdatePriceValue: line 4, column 3

 

Any way around this?  I have the code below:

 

 

trigger UpdatePriceValue on Services_Selection__c (after insert, after update)

{

for (Services_Selection__c SS : Trigger.new)

{

SS.Price_Value__c = SS.Price_Formula__c;

}

}

 

Thanks in advance, to anyone who can help resolve this small issue.

  • April 27, 2010
  • Like
  • 0

Hello,

 

I found a overly detailed link at SFDC on a test script for controllers and controller extensions; however, I cannot make sense of it all.

 

I have the following code and I created a very basic VF page that I dropped on the Opportunity page.  It displays to the user that they have to enter a Partner record if a partner record is not found for the current opportunity.

 

How can I create a test script to test this and get me passed the limits so I can move it to production?

Do I execute the test script in production before it can be used? I am not sure how this stuff works.

public class OppPartnerExtension {
    private boolean hasPartners = false;    

    public OppPartnerExtension(ApexPages.StandardController controller) {
       if([select count() from OpportunityPartner where opportunityId = :controller.getRecord().id] > 0){
           hasPartners = true;
       }
    }
    
    public boolean getHasPartners(){
        return hasPartners;
    }
}

 

 

 The VF page looks like this:

 

<apex:page standardController="Opportunity" extensions="OppPartnerExtension">

  <apex:outputText style="Color:#FF3300; background-color:yellow; font-style:bold"                    
                   value="Remember to enter partner(s)"
                   rendered="{!NOT(hasPartners)}">
                   <!--
                   value="{!hasPartners}">
                   -->
                   
      <!-- This routine jumps us to the partner screen if a partner
           record does not exists      
           
      <script>
          parent.location.href = '/opp/partneredit.jsp?id={!Opportunity.Id}&fid={!Opportunity.AccountId}&retURL=%2F{!Opportunity.Id}';
      </script>

      -->  
  </apex:outputText>

</apex:page>

 

 

 

 

 

I have written a trigger and try to change the trigger to bulk trigger version. Can anyone help me, i feel confused about bulk trigger. You can just make some change in one recordTypeId and post back as a reply. Thank you very much in advance. Here is my whole trigger looks like.

 

trigger TimeSheetTrigger on Timesheet__c (after delete, after insert,after update)
{
double sumTotalHours = 0.0;

Campaign[] sheetsToUpdateCampaign = new Campaign[]{};
Case[] sheetsToUpdateCase = new Case[]{};
Contract[] sheetsToUpdateContract = new Contract[]{};
Job__c[] sheetsToUpdateJob = new Job__c[]{};
Opportunity[] sheetsToUpdateOpportunity = new Opportunity[]{};
Project__c [] sheetsToUpdateProject = new Project__c[]{};


//***********************************************
//Code for updating existing records and new records
//***********************************************

if(Trigger.isInsert)
{
Timesheet__c [] teNew = trigger.new;

for(Timesheet__c te : teNew)
{
//The selected RecordType is Campaign
if(te.RecordTypeId == '012200000001Xyp')
{
for (Campaign timesheet : [select Id,Name, Hours__c from Campaign ])
{
//Sum all the timesheet entries
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Campaign__c = :timesheet.Id ])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

//add timesheet to list to be updated outside of the loop
sheetsToUpdateCampaign.add(timesheet);
update sheetsToUpdateCampaign;
}
}

//The selected RecordType is Case
if(te.RecordTypeId == '012200000001X36')
{
for (Case timesheet : [select Id, Hours__c from Case ])
{

//Sum all the timesheet entries
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Case__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

//add timesheet to list to be updated outside of the loop
sheetsToUpdateCase.add(timesheet);
update sheetsToUpdateCase;
}
}
//The selected RecordType is Contract
if(te.RecordTypeId == '012200000001Xyk')
{
for (Contract timesheet : [select Id,Name, Total_Contract_Hours__c from Contract ])
{

//Sum all the timesheet entries
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Contract__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Total_Contract_Hours__c = sumTotalHours;

//add timesheet to list to be updated outside of the loop
sheetsToUpdateContract.add(timesheet);
update sheetsToUpdateContract;
}
}
//The selected RecordType is Job
if(te.RecordTypeId == '012200000001X3B')
{
for (Job__c timesheet : [select Id,Name, Hours__c from Job__c ])
{

//Sum all the timesheet entries
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Job__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

//add timesheet to list to be updated outside of the loop
sheetsToUpdateJob.add(timesheet);
update sheetsToUpdateJob;
}
}

//The selected RecordType is Opportunity
if(te.RecordTypeId == '012200000001YBG')
{
for (Opportunity timesheet : [select Id,Name, Hours__c from Opportunity ])
{

//Sum all the timesheet entries
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Opportunity__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

//add timesheet to list to be updated outside of the loop
sheetsToUpdateOpportunity.add(timesheet);
update sheetsToUpdateOpportunity;
}
}

//The selected RecordType is Project
if(te.RecordTypeId == '012200000001X31')
{
for (Project__c timesheet : [select Id,Name, Hours__c from Project__c ])
{

//Sum all the timesheet entries
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Project__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

//add timesheet to list to be updated outside of the loop
sheetsToUpdateProject.add(timesheet);
update sheetsToUpdateProject;
}
}
}


}

//***********************************************
//Code for updating when a record is updated
//***********************************************

else if(Trigger.isUpdate)
{
//sum total both old and new
Timesheet__c [] oldTime = Trigger.old;
Timesheet__c [] newTime = Trigger.new;
Double newSum = 0.0;
Double oldSum = 0.0;

for(Timesheet__c newTe: newTime)
{
for(Timesheet__c oldTe : oldTime)
{

//Selected RecordType is Campaign
if(newTe.RecordTypeId == '012200000001Xyp')
{
Campaign oldTimesheet = [Select Id, Name, Hours__c from Campaign where id = :oldTe.Campaign__c];
Campaign newTimesheet = [Select Id, Name, Hours__c from Campaign where id = :newTe.Campaign__c];

Timesheet__c [] oldSumHours = [Select Id,Name, Hours__c from Timesheet__c where Campaign__c = :oldTimesheet.Id];
Timesheet__c [] newSumHours = [Select Id, Name, Hours__c  from Timesheet__c where Campaign__c = :newTimesheet.Id];

//sum premiums from child objects
for(Timesheet__c oldSumHour : oldSumHours)
{
oldSum += oldSumHour.Hours__c;
}

for(Timesheet__c newSumHour : newSumHours)
{
newSum += newSumHour.Hours__c;

}
oldTimesheet.Hours__c= oldSum;
newTimesheet.Hours__c = newSum;

sheetsToUpdateCampaign.add(newTimesheet);
if(newTimesheet.Id != oldTimesheet.Id)
{
sheetsToUpdateCampaign.add(oldTimesheet);
}
}

//Selected RecordType is Case
if(newTe.RecordTypeId == '012200000001X36')
{
Case oldTimesheet = [Select Id, Hours__c from Case where id = :oldTe.Case__c];
Case newTimesheet = [Select Id, Hours__c from Case where id = :newTe.Case__c];

Timesheet__c [] oldSumHours = [Select Id,Name, Hours__c from Timesheet__c where Case__c = :oldTimesheet.Id];
Timesheet__c [] newSumHours = [Select Id, Name, Hours__c  from Timesheet__c where Case__c = :newTimesheet.Id];

//sum premiums from child objects
for(Timesheet__c oldSumHour : oldSumHours)
{
oldSum += oldSumHour.Hours__c;
}

for(Timesheet__c newSumHour : newSumHours)
{
newSum += newSumHour.Hours__c;
}
oldTimesheet.Hours__c= oldSum;
newTimesheet.Hours__c = newSum;

sheetsToUpdateCase.add(newTimesheet);
if(newTimesheet.Id != oldTimesheet.Id)
{
sheetsToUpdateCase.add(oldTimesheet);
}
}

//Selected RecordType is Contract
if(newTe.RecordTypeId == '012200000001Xyk')
{
Contract oldTimesheet = [Select Id, Name, Total_Contract_Hours__c from Contract where id = :oldTe.Contract__c];
Contract newTimesheet = [Select Id, Name, Total_Contract_Hours__c from Contract where id = :newTe.Contract__c];

Timesheet__c [] oldSumHours = [Select Id,Name, Hours__c from Timesheet__c where Contract__c = :oldTimesheet.Id];
Timesheet__c [] newSumHours = [Select Id, Name, Hours__c  from Timesheet__c where Contract__c = :newTimesheet.Id];

//sum premiums from child objects
for(Timesheet__c oldSumHour : oldSumHours)
{
oldSum += oldSumHour.Hours__c;
}

for(Timesheet__c newSumHour : newSumHours)
{
newSum += newSumHour.Hours__c;

}
oldTimesheet.Total_Contract_Hours__c= oldSum;
newTimesheet.Total_Contract_Hours__c = newSum;

sheetsToUpdateContract.add(newTimesheet);
if(newTimesheet.Id != oldTimesheet.Id)
{
sheetsToUpdateContract.add(oldTimesheet);
}
}

//Selected RecordType is Job
if(newTe.RecordTypeId == '012200000001X3B')
{
Job__c oldTimesheet = [Select Id, Name, Hours__c from Job__c where id = :oldTe.Job__c];
Job__c newTimesheet = [Select Id, Name, Hours__c from Job__c where id = :newTe.Job__c];

Timesheet__c [] oldSumHours = [Select Id,Name, Hours__c from Timesheet__c where Job__c = :oldTimesheet.Id];
Timesheet__c [] newSumHours = [Select Id, Name, Hours__c  from Timesheet__c where Job__c = :newTimesheet.Id];

//sum premiums from child objects
for(Timesheet__c oldSumHour : oldSumHours)
{
oldSum += oldSumHour.Hours__c;
}

for(Timesheet__c newSumHour : newSumHours)
{
newSum += newSumHour.Hours__c;

}
oldTimesheet.Hours__c= oldSum;
newTimesheet.Hours__c = newSum;

sheetsToUpdateJob.add(newTimesheet);
if(newTimesheet.Id != oldTimesheet.Id)
{
sheetsToUpdateJob.add(oldTimesheet);
}
}
//Selected RecordType is Opportunity
if(newTe.RecordTypeId == '012200000001YBG')
{
Opportunity oldTimesheet = [Select Id, Name, Hours__c from Opportunity where id = :oldTe.Opportunity__c];
Opportunity newTimesheet = [Select Id, Name, Hours__c from Opportunity where id = :newTe.Opportunity__c];

Timesheet__c [] oldSumHours = [Select Id,Name, Hours__c from Timesheet__c where Opportunity__c = :oldTimesheet.Id];
Timesheet__c [] newSumHours = [Select Id, Name, Hours__c  from Timesheet__c where Opportunity__c =

:newTimesheet.Id];

//sum premiums from child objects
for(Timesheet__c oldSumHour : oldSumHours)
{
oldSum += oldSumHour.Hours__c;
}

for(Timesheet__c newSumHour : newSumHours)
{
newSum += newSumHour.Hours__c;

}
oldTimesheet.Hours__c= oldSum;
newTimesheet.Hours__c = newSum;

sheetsToUpdateOpportunity.add(newTimesheet);
if(newTimesheet.Id != oldTimesheet.Id)
{
sheetsToUpdateOpportunity.add(oldTimesheet);
}
}

//Selected RecordType is Project
if(newTe.RecordTypeId == '012200000001X31')
{
Project__c oldTimesheet = [Select Id, Name, Hours__c from Project__c where id = :oldTe.Project__c];
Project__c newTimesheet = [Select Id, Name, Hours__c from Project__c where id = :newTe.Project__c];

Timesheet__c [] oldSumHours = [Select Id,Name, Hours__c from Timesheet__c where Project__c = :oldTimesheet.Id];
Timesheet__c [] newSumHours = [Select Id, Name, Hours__c  from Timesheet__c where Project__c = :newTimesheet.Id];

//sum premiums from child objects
for(Timesheet__c oldSumHour : oldSumHours)
{
oldSum += oldSumHour.Hours__c;
}

for(Timesheet__c newSumHour : newSumHours)
{
newSum += newSumHour.Hours__c;

}
oldTimesheet.Hours__c= oldSum;
newTimesheet.Hours__c = newSum;

sheetsToUpdateProject.add(newTimesheet);
if(newTimesheet.Id != oldTimesheet.Id)
{
sheetsToUpdateProject.add(oldTimesheet);
}
}

}
}

//commit the changes to Salesforce
if(newTime[0].RecordTypeId == '012200000001Xyp')
update sheetsToUpdateCampaign;
if(newTime[0].RecordTypeId == '012200000001X36')
update sheetsToUpdateCase;
if(newTime[0].RecordTypeId == '012200000001Xyk')
update sheetsToUpdateContract;
if(newTime[0].RecordTypeId == '012200000001X3B')
update sheetsToUpdateJob;
if(newTime[0].RecordTypeId == '012200000001YBG')
update sheetsToUpdateOpportunity;
if(newTime[0].RecordTypeId == '012200000001X31')
update sheetsToUpdateProject;
}

//***********************************************
//Code for updating when a record is deleted
//***********************************************

else if(Trigger.isDelete)
{

Timesheet__c [] teOld = trigger.old;

for(Timesheet__c te: teOld)
{
if(te.RecordTypeId == '012200000001Xyp')
{
for (Campaign timesheet: [select Id, Name, Hours__c from Campaign])
{
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Campaign__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

sheetsToUpdateCampaign.add(timesheet);
}
}

if(te.RecordTypeId == '012200000001X36')
{
for (Case timesheet: [select Id, Hours__c from Case])
{
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Case__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

sheetsToUpdateCase.add(timesheet);
}
}

if(te.RecordTypeId == '012200000001Xyk')
{
for (Contract timesheet: [select Id, Name, Total_Contract_Hours__c from Contract])
{
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Contract__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Total_Contract_Hours__c = sumTotalHours;

sheetsToUpdateContract.add(timesheet);
}
}

if(te.RecordTypeId == '012200000001X3B')
{
for (Job__c timesheet: [select Id, Name, Hours__c from Job__c])
{
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Job__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

sheetsToUpdateJob.add(timesheet);
}
}

if(te.RecordTypeId == '012200000001YBG')
{
for (Opportunity timesheet: [select Id, Name, Hours__c from Opportunity])
{
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Opportunity__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

sheetsToUpdateOpportunity.add(timesheet);
}
}

if(te.RecordTypeId == '012200000001X31')
{
for (Project__c timesheet: [select Id, Name, Hours__c from Project__c])
{
for (Timesheet__c timeEntries: [select Id, Hours__c from Timesheet__c where Project__c = :timesheet.Id])
{
sumTotalHours += timeEntries.Hours__c;
}

timesheet.Hours__c = sumTotalHours;

sheetsToUpdateProject.add(timesheet);
}
}

}

//commit the changes to Salesforce
if(teOld[0].RecordTypeId == '012200000001Xyp')
update sheetsToUpdateCampaign;
if(teOld[0].RecordTypeId == '012200000001X36')
update sheetsToUpdateCase;
if(teOld[0].RecordTypeId == '012200000001Xyk')
update sheetsToUpdateContract;
if(teOld[0].RecordTypeId == '012200000001X3B')
update sheetsToUpdateJob;
if(teOld[0].RecordTypeId == '012200000001YBG')
update sheetsToUpdateOpportunity;
if(teOld[0].RecordTypeId == '012200000001X31')
update sheetsToUpdateProject;
}     
}

Hello there,

 

Since summer11, I just got the strange error: exceptionCode:'INVALID_TYPE', exceptionMessage:'sObject type 'ForecastShare' is not supported.'

 

The error from soql: Select UserRoleId from ForecastShare where UserOrGroupId = ''xxx'. This user is shared by manager by not allowed forecasting. It used to work, but not anymore.

 

Anybody helps me!!!

 

Thanks in advance.

Regards,

Dear all expertises,

 

I'm currently stuck with building a table in pdf page. What I want is to show table header on every page.

 

Anybody help? 

 

 

 

Thx 

Hi all,

 

I'm currently stuck with batch Apex. My soql in batch apex doesn't return the formula fields value (rumber formula field.) It always return 0 for each number formula field. But the other fields except formula field are returned the value correctly.

 

 

Does any one have problem like me?

 

Any help is greatly appreciated.

  

Hi all, 

 

Any example how to translate picklist value using METADATA API 14.0

 

 

Thx 

Hi there,

 

I was wondering howto know that batch apex is enabled in one organization? 

 

Thx 

Dear all developers!
I am a newbie in saleforce. I am about to create a page with ExtJS but I don't know how to include the Ext Library.
Does any one experiance with this, pls pay attention to help me.

Thanks in advance.
PoorMan.
Good day every one. i am the newest of saleforce. i've got a problem that cant be resolved and need help from all of you. my problem is:
when i try to excecute query for queryresult i got the following msg:
"Invalid element in com.sforce.soap.enterprise.sobject.SObject - type"
how may i  resovle this error.!
pls.....help me.:mansad:

PoorMan.
good day every one. i am the newest of saleforce. i've got a problem that cant be resolved and need help from all of you. my problem is:
when i try to excecute query for queryresult i got the following msg:
"Invalid element in com.sforce.soap.enterprise.sobject.SObject - type"
how may i  resovle this error.!
pls.....help me.

PoorMan.
good day every one. i am the newest of saleforce. i've got a problem that cant be resolved and need help from all of you. my problem is:
when i try to excecute query for queryresult i got the following msg:
"Invalid element in com.sforce.soap.enterprise.sobject.SObject - type"
how may i  resovle this error.!
pls.....help me.

PoorMan.


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.

 

  • June 14, 2012
  • Like
  • 0

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

  • January 30, 2012
  • Like
  • 0

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!!

 

 

  • January 19, 2012
  • Like
  • 0

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

  • September 22, 2011
  • Like
  • 0

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

  • September 22, 2011
  • Like
  • 0

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.

  • September 20, 2011
  • Like
  • 0

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

  • September 20, 2011
  • Like
  • 0

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