• ekm
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 14
    Replies
Hi,

I would like to be able to load picklist values into a Flex List control. I'm able to load picklist values into a ComboBox and was hoping I'd be able to load the values into the List control in the same way. However, it doesn't seem to be working. I didn't see anything about this in the documentation or any other examples, so if anyone has done this, I'd appreciate any feedback or help you could provide.

Regards,

Errol

This doesn't work--
<mx:List id="cmbType2" dataProvider="{picklistValues}"/>

This works---   
<mx:ComboBox id="cmbType1" dataProvider="{picklistValues}" />
  • January 14, 2009
  • Like
  • 0
Hello,

I'm attempting to retrieve data from 2 picklists (Account table, Industry field; and Event table, ShowAs table) from the salesforce data and display in a flex application.
I'm able to retrieve data from one picklist and display in a combo box without any problem. The problem I'm having occurs when I attempt to retrieve data from another picklist and display in a 2nd combo box.

I'd really appreciate it if someone were to let me know if I'm approaching this the wrong way, and/or I'm missing something.

Thanks in advance for any help you have to offer.

Regards,

Errol

    [Bindable]
    public var picklistValues:Array = new Array();
   
    [Bindable]
    public var picklistValues2:Array = new Array();
       
    [Bindable]
     public var pickListEventType:PickListEntry;
     
    [Bindable]
     public var pickListEventType2:PickListEntry;
     
//functions calling picklist data  
 
    public function describeEventTypeSObjects():void {
 
     var myPicklistValues:ArrayCollection = new ArrayCollection(); 
     apex.describeSObjects(["Account"], 
        new AsyncResponder(function (result:Object):void 
     { 
         myPicklistValues = result[0].fields.Industry.picklistValues; 
         for (var p:int=0;p<myPicklistValues.length;p++) 
         { 
             if (myPicklistValues[p].active) 
             { 
                 var pickListEventType:PickListEntry = myPicklistValues[p].label;
                 picklistValues.push(pickListEventType);
             } 
     }  
  
     }, genericFault));

    }
   
    public function describeEventTypeSObjects2():void {
     
     var myPicklistValues2:ArrayCollection = new ArrayCollection(); 
     apex.describeSObjects(["Event"], 
        new AsyncResponder(function (result:Object):void 
     { 
         myPicklistValues2 = result[0].fields.ShowAs.picklistValues2; 
         for (var p:int=0;p<myPicklistValues2.length;p++) 
         { 
             if (myPicklistValues2[p].active) 
             { 
                 var pickListEventType2:PickListEntry = myPicklistValues2[p].label;
                 picklistValues2.push(pickListEventType2);
             } 
     }  
  
     }, genericFault));

    }

//combo boxes where I'm wanting to display the data

<mx:ComboBox id="cmbType1" dataProvider="{picklistValues}"
        ></mx:ComboBox>
<mx:ComboBox id="cmbType2" dataProvider="{picklistValues2}"
        ></mx:ComboBox>

  • January 14, 2009
  • Like
  • 0
Hello,

I'm working with salesforce using an app developed using Flex and ran into an issue that I'm attempting to troubleshoot. Everything was working fine and then in the security settings (set up - administration setup - security control - session settings), we checked 'Require Secure Connections (https)' checkbox. Now the data I have loaded in Salesforce does not display in my Flex app when running from another server either outside or inside our firewall (this setting is a general setting for all who will log into our application).

I'm using the login code found in the samples I downloded from Salesforce (see below).

Does anyone have any suggetions for why my login no longer works?

Thanks in advance for any suggestions one might have.

Regards,

Errol


<salesforce:Connection id="apex"
    serverUrl="https://test.salesforce.com/services/Soap/u/14.0"
    />   


private function login():void {
        var lr:LoginRequest = new LoginRequest(    {    
            server_url : Application.application.parameters.server_url,   
            session_id : Application.application.parameters.session_id,
            username : 'username',
            password : 'password',
            callback : new AsyncResponder(function (result:Object):void
                {
                                  } )
            } );
           
        Util.debug(this, 'apex.login ( ' +ObjectUtil.toString(lr) +'\n);' );   
        apex.protocol = "http";
        apex.login(lr);        
    }

  • January 07, 2009
  • Like
  • 0
Hi,

I'm attempting to pull values from several picklists into corresponding combo boxes in Flex. I'm able to pull picklist values into 1 combobox with no problem. Where I'm running into a snag is when I want to pull separate picklist values into 2 different combo boxes. Since property picklistValues is part of the salesforce api, do I need to modify my local salesforce api (SF_Picklist.as) by creating variable picklistValues2?

Thanks,
  • October 21, 2008
  • Like
  • 0
Hi,

I'm attempting to populate a combobox from a picklist (Type) from the Event table using the describeSObject based on the salesforce.mxml example. I'm getting the values no problem, but am getting the good ole [object Object] in the combo box. I'm attempting to put the describeSObject into an arrayCollection (myPickList) and use the arraycollection as a dataprovider for the combobox.

Any suggestion for what I'm missing a better way to do this would be greatly appreciated.

Thanks,

private function describeSObjects():void {
         apex.describeSObjects(
         ["Event"],
           new AsyncResponder(describeSObjects_Test, genericFault));
    }
   
    private function describeSObjects_Test(result:Object):void
    {
         if (result != null)
         {
              var describeSObjectResult:DescribeSObjectResult = result[0] as DescribeSObjectResult;
             ta.text = 'describeSObjects_Test describeSObjectResult fields = \n';
              for (var fld_name:String in describeSObjectResult.fields )
              {
                var fieldName:String = describeSObjectResult.fields[fld_name].name;
                //ta.text += 'field = ' + fieldName + '\n';
                var fieldType:String = describeSObjectResult.fields[fld_name].type;
                if (fieldName == 'Type')
                {               
                if (fieldType == 'picklist')
                {
                      ta.text += '  Picklist values:' + '\n';
                      for (var j:int = 0;j<describeSObjectResult.fields[fld_name].picklistValues.length;j++)
                      {
                         ta.text += "    " + describeSObjectResult.fields[fld_name].picklistValues[j].value + "\n";
                  
                   
                         myPickList.addItem( {Type:describeSObjectResult.fields[fld_name].picklistValues[j].value } );
                         //cmbType[i] = [item.label];
                      }         
                }
                }
              
              }
         }
    }

<mx:ComboBox  id="cmbType"
            dataProvider="{myPickList}" rowCount="10"
            labelField="@Type"/>

  • August 15, 2008
  • Like
  • 0
Hi,

I've been attempting to query SalesForce data based on a range of ActivityDates.

Here's an example where I force the dates and everything shows up fine for this forced date range.

Within my apex.query, I have the following:
("Select field1, ActivityDate From Event where ActivityDate >= 2008-08-01 and ActivityDate <= 2008-09-30;

Now what I'd like to do is capture dates from a start and end dateField base my query off of those dates.

What is the approach I should take? Cast the Flex date I capture into Salesforce as a string or date? I've tried capturing the dateFields on a change event and setting the value to a string.
I've also tried converting the string to a Date (i.e., var dStartSearchBroker:Date = DateField.stringToDate(wholeStartDate, "YYYY-MM-DD") ) where wholeStartDate is the string value that I've originally set on the change event. Still no luck.

Any help that someone could provide would be greatly appreciated.

Regards,

EKM
  • August 14, 2008
  • Like
  • 0
Hi, all,

I'm attempting to create a new event and pass a string variable as an activity date from a dateField.

When I force the date, a new event is created, but when I try to save the selected date into a variable and then try to create the new event, the new event does not get created. Should I be sending a Date object instead of a string object? Is my String variable (myDateString) not formatted correctly?

If I've missed an example of this here on the threads, please point me in right direction. Otherwise, any assistance would be greatly appreciated.

Regards,

EKM


My related actionScript

// function for creating the Event
private function createEvent():void
{
 //other code for function here

// this doesn't work
//evt.ActivityDateTime = new Date(myDateString, startTimePassHour, startTimePassMinute, 0); // this doesn't work

//this does work
evt.ActivityDateTime = new Date(2008, 08, 01, startTimePassHour, startTimePassMinute, 0); // this does allow me to create new Events
       
//....code for apex.create([evt],.... goes here

}


public var myDateString:String;
  //function for saving dateMeetingAdd.text to string variable        
private function myDateToString():void
{
    myDateString = dateMeetingDateAdd.text;
    //Alert.show(myDateString);
}


//function for formatting the date
private function formatDate(date:Date):String {
                return DateDisplayApex.format(date);
            }



// Date Formatter to format the year, month, and date
<mx:DateFormatter id="DateDisplayApex"
        formatString="YYYY, MM, DD"/>

//the datefield I'm using to select a date for the event I'm creating
//calls myDateToString to save dateMeetingDateAdd to string
<mx:DateField showToday="true" id="dateMeetingDateAdd"
    labelFunction="formatDate" parseFunction="null"
    text="July 28, 2008" change="myDateToString()"/>

  • July 29, 2008
  • Like
  • 0
Hi,

I can create a new record from 2 text fields using the following:

private function createContactManager():void
    {

        var contact:SObject = new SObject('Contact');  
      
        contact.FirstName = firstName.text;  //firstname text field
        contact.LastName = lastName.text; // lastname text field

        apex.create([contact],
            new AsyncResponder( function (result:Object):void
            {
                
                }, genericFault
                            )
                        )
        }

But what about when I have contacts from a datagrid and I want to create new records for each contact within the datragid.
For instance, if I was using the following:
datagrid="dgContacts"
dataprovider="contactList"
arraycollection = acMyContacts

I'd appreciate any help provided or even if someone could point me to an example of this or where it's referred in the documentation. I have so far been unable to find anything.

Thanks.
  • June 23, 2008
  • Like
  • 0
Hi,

I'm creating an event and then wanting to pass the ID of that newly created event into another table (Event_Attendee__c). I save the ID to a variable (lastEventId).  I'm able to retrieve the newly created event ID, but have so far not been able to pass the ID into the function where I am creating a new event_attendee record. I'm getting Null in my trace statement in the createEventAttendee function for lastEventId.
Anyone have any thoughts as to how solve this?

Regards,

public var lastEventId:String;

private function create():void
        {
            createEvent();
            createEventAttendee();
        }

private function createEvent():void
      {
                     
        var evt:SObject = new SObject('Event');   
       
        evt.RecordTypeId = '01230000000DkER';
        evt.OwnerId = '005300000017Tz4AAE';
        evt.WhatId = '00130000008TiPdAAK';
        evt.ffCompany_Name1__c =  txtCustomerName.text;
        evt.ffCompany_Name2__c = txtCID.text;
        evt.Type = conferenceCallCheckBox;      
        evt.ActivityDateTime = new Date(2008, 5, 30, startTimePassHour, startTimePassMinute, 0);
        evt.DurationInMinutes = meetingTime;    
        evt.Travel_Time__c = cmbTravelTime.selectedLabel;   
        evt.Method__c = cmbMeetingType.selectedLabel;
        evt.Purchaser_Delivered__c = purDelivered;
        evt.Purchaser_Delivered_Quantity__c = txtPurDeliveredAddQty.text;    //Purchaser Delivered Quantity
        evt.PIH_Delivered__c = pihDelivered;
        evt.PIH_Delivered_Quantity__c = txtPihDeliveredAddQty.text;
        evt.Healthworks_Reviewed__c = healthworksReviewed;
        evt.Healthworks_Approved__c = healthworksApproved;
        evt.Facility_Tour__c = facilityTour;
        evt.Subject = subjectSelected;
        evt.Objectives__c = objectiveSelected; //Key Objectives
        evt.Actual_Outcome__c = txtOtherCommentsAdd.text;                //Other Comments;
       

          apex.create([evt],
          new AsyncResponder( function (result:Object):void
              {
                  trace( 'new event id: '+(result[0] as SaveResult).id );
                 
                  lastEventId = (result[0] as SaveResult).id;
                  trace('last event id: '+ lastEventId);
                 
             }, genericFault
         ) );   
       
      }

private function createEventAttendee():void
    {
        //using customized table Event_Attendee__c
        var eventAttendee:SObject = new SObject('Event_Attendee__c');
       
        //forcing this value for now   
        eventAttendee.Contact__c = '101010101';
        eventAttendee.Event_ID__c = lastEventId;
        trace("create Event lastEventId: " + lastEventId);
        eventAttendee.Status__c = 'Accepted';    //pass 'Accepted' string

        apex.create([eventAttendee],
        new AsyncResponder( function (result:Object):void
            {
               
            }, genericFault
        ) );
       
    }
  • June 17, 2008
  • Like
  • 0
Hi all,

I'm attempting to query a table (Events) based on a range of dates and another field (in this example, it's ffCompany_Name1__c within the Events table I'm using). The id of the dateField I'm using is dateStartDateMainEditMeeting.

I'm receiving a 1009 error with the code below.

Anyone have any suggestions what I can do query a table based on an ActivityDate? Thanks in advance for anyone's help.

public var dSource:String = dateStartDateMainEditMeeting.text;
public var dStartEdit:Date = Util.stringToDate(dSource);
            
        private function displayEditMeetingSearchResults():void
      {
        currentState="editMeetingSearchResults";
        var acc:SObject = new SObject('Event');
        apex.query("Select Id, " +
                "ffCompany_Name1__c, " +
                "ffCompany_Name2__c, " +
                "ActivityDate, " +
                "ActivityDateTime, " +
                "Method__c, " +
                "ActivityEndTime__c, " +
                "Type, " +
                "Objectives__c, " +
                "Subject, " +
                "Actual_Outcome__c, " +
                "Travel_Time__c From Event where ffCompany_Name1__c like '%Bank%' and ActivityDate >= '" + dateStartDateMainEditMeeting.text + "'",
            new AsyncResponder(function (qr:QueryResult):void
              {
                for (var j:int=0;j<qr.records.length;j++)
                    {
                    events.addItem( {ffCompany_Name1__c:qr.records[j].ffCompany_Name1__c, ffCompany_Name2__c:qr.records[j].ffCompany_Name2__c, Type:qr.records[j].Type, ActivityDate:qr.records[j].ActivityDate, ActivityDateTime:qr.records[j].ActivityDateTime, Objectives__c:qr.records[j].Objectives__c } );
                  
             
                }
      
                }
               ) // closes new AsyncResponder(function (qr:QueryResult):void
        ); //closes 1st apex query
    }
  • June 16, 2008
  • Like
  • 0
Hi,
I'm attempting to run a query and a subsequent subquery based off the original query and then display the results in a datagrid. I'm having difficulty with the subquery and would appreciate any help or guidance as to what I need to do. Below is the portion of code that I'm working with. As I said, the Role field from the 1st query populates fine, but how do I get the results from the 2nd query.

Thanks,

[Bindable]
public var ar2:ArrayCollection = new ArrayCollection();
   
    [Bindable]
    public var ar:ArrayCollection = new ArrayCollection();
   
    private function queryAccountManagerEdit1():void
      {
        currentState="searchAccountManagerEdit";
        var acc:SObject = new SObject('AccountContactRole');
        apex.query("Select ContactId, Role From AccountContactRole where Role = 'Decision-maker'",  
            new AsyncResponder(function (qr:QueryResult):void
              {
                for (var j:int=0;j<qr.records.length;j++)
                    {
                    ar.addItem(  { ContactId:qr.records[j].ContactId, Role:qr.records[j].Role } );
                    //ar.addItem(  { Role:qr.records[j].Role } );
                    apex.query("Select Id, Name From Contact where Id = ContactId:qr.records[j].ContactId",
                    new AsyncResponder(function (qr2:QueryResult):void
                        {
                            for (var k:int=0;k<qr2.records.length;k++)
                            {
                                ar2.addItem( {Name:qr2.records[k].Name});
                            }
                            //dgSearchAccountManagerEdit.columns = [ new DataGridColumn('Name'), new DataGridColumn('Role') ];
                            //dgSearchAccountManagerEdit.dataProvider = ar2;
                        }
                    )                    
                    )
                }
                // create the columns and specify the order
                dgSearchAccountManagerEdit.columns = [ new DataGridColumn('Name'), new DataGridColumn('Role') ];
                dgSearchAccountManagerEdit.dataProvider = ar;    //assign the array as the data provider
                }
               ) // closes new AsyncResponder(function (qr:QueryResult):void
        ); //closes 1st apex query
    }  
  • May 29, 2008
  • Like
  • 0
Hi,

I am attempting to query data from the Accounts table as well as several child fields from the Events table. I can successfully query from each  individually but am not having success in combining them into one dataprovider which populates a datagrid.
I haven't seen an example of this, so if someone could point me in the right direction, I would great appreciate it. FYI, both tmp and eventNameDateTime are bindable arrayCollections.

Thanks,

Errol

private function displayEditMeetingSearchResults():void {
                             
                apex.query("Select Id, AccountNumber, Name, (Select Event.AccountId, Event.ActivityDate, Event.Id, Event.Type From Account.Events) from Account", new AsyncResponder
                (
                    function(qr:QueryResult):void
                    {
                        if (qr.size > 0)
                        {
                            tmp = qr.records;
                            //eventNameDateTime = qr.records;
                            eventNameDateTime = tmp.getItemAt(0).Events.records;
           
                        }
                    },
                    handleFault)
                );
            }
  • May 23, 2008
  • Like
  • 0
The flex toolkit appears to be broken in flash player 10. I've got a control that works fine in Flash 9 but not Flash 10. Now that Flash 10 is publicly available, this is a big problem.

The log output when making a login call is the following - notice the error on the last line:
Code:
[DEBUG] com.salesforce.Connection App Domain = salesforce.com
[DEBUG] com.salesforce.Connection Api Server name = na3.salesforce.com
[DEBUG] com.salesforce.Connection _internalServerUrl = https://na3.salesforce.com/services/Soap/u/13.0/471700D500000006lQW
[DEBUG] com.salesforce.Connection loading the policy file: https://na3.salesforce.com/services/Soap/cross-domain.xml
[INFO] com.salesforce.Connection Your application must be running on a https server in order to use https to communicate with salesforce.com!
[DEBUG] com.salesforce.Connection invoke getUserInfo
[DEBUG] com.salesforce.Connection intServerUrl is null
[DEBUG] com.salesforce.Connection intServerUrl = https://na3.salesforce.com/services/Soap/u/13.0/471700D500000006lQW
[DEBUG] com.salesforce.Connection _invoke getUserInfo
[INFO] mx.messaging.Producer '87CD1CD3-FFAD-680D-6681-2AC02C6366BD' producer set destination to 'DefaultHTTPS'.
[DEBUG] com.salesforce.Transport object format set
[DEBUG] com.salesforce.events.SendEvent Method name is: getUserInfo
[INFO] mx.messaging.Producer '87CD1CD3-FFAD-680D-6681-2AC02C6366BD' producer sending message '4DA901AD-8C84-8587-37D7-2AC02C68D691'
[DEBUG] mx.messaging.Channel 'direct_http_channel' channel sending message:
(mx.messaging.messages::HTTPRequestMessage)#0
body = "<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="urn:partner.soap.sforce.com"><sfns:SessionHeader><sessionId>471700D500000006lQW!AQYAQLSyqIEqp.DYDyQydZmx8C1y_CQ8_WgDZpb8S.Cv6zq0sIW5ny4C61NcVSfuIE8QjKgaXv1RpkC8S9m.tcLSv_rQ0ezf</sessionId></sfns:SessionHeader><sfns:CallOptions><client>Appirio/CloudStorage/</client></sfns:CallOptions></se:Header><se:Body><getUserInfo xmlns="urn:partner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com"/></se:Body></se:Envelope>"
clientId = (null)
contentType = "text/xml; charset=UTF-8"
destination = "DefaultHTTPS"
headers = (Object)#1
httpHeaders = (Object)#2
Accept = "text/xml"
SOAPAction = """"
X-Salesforce-No-500-SC = "true"
messageId = "4DA901AD-8C84-8587-37D7-2AC02C68D691"
method = "POST"
recordHeaders = false
timestamp = 0
timeToLive = 0
url = "https://na3.salesforce.com/services/Soap/u/13.0/471700D500000006lQW"
[INFO] mx.messaging.Producer '87CD1CD3-FFAD-680D-6681-2AC02C6366BD' producer connected.
[DEBUG] com.salesforce.events.SendEvent Method name is: getUserInfo
[INFO] mx.messaging.Producer '87CD1CD3-FFAD-680D-6681-2AC02C6366BD' producer acknowledge of '4DA901AD-8C84-8587-37D7-2AC02C68D691'.
[ERROR] mx.messaging.Producer '87CD1CD3-FFAD-680D-6681-2AC02C6366BD' producer fault for '4DA901AD-8C84-8587-37D7-2AC02C68D691'.

 Is there a plan to fix this or does anyone have any work around?

Hi,

I'm attempting to populate a combobox from a picklist (Type) from the Event table using the describeSObject based on the salesforce.mxml example. I'm getting the values no problem, but am getting the good ole [object Object] in the combo box. I'm attempting to put the describeSObject into an arrayCollection (myPickList) and use the arraycollection as a dataprovider for the combobox.

Any suggestion for what I'm missing a better way to do this would be greatly appreciated.

Thanks,

private function describeSObjects():void {
         apex.describeSObjects(
         ["Event"],
           new AsyncResponder(describeSObjects_Test, genericFault));
    }
   
    private function describeSObjects_Test(result:Object):void
    {
         if (result != null)
         {
              var describeSObjectResult:DescribeSObjectResult = result[0] as DescribeSObjectResult;
             ta.text = 'describeSObjects_Test describeSObjectResult fields = \n';
              for (var fld_name:String in describeSObjectResult.fields )
              {
                var fieldName:String = describeSObjectResult.fields[fld_name].name;
                //ta.text += 'field = ' + fieldName + '\n';
                var fieldType:String = describeSObjectResult.fields[fld_name].type;
                if (fieldName == 'Type')
                {               
                if (fieldType == 'picklist')
                {
                      ta.text += '  Picklist values:' + '\n';
                      for (var j:int = 0;j<describeSObjectResult.fields[fld_name].picklistValues.length;j++)
                      {
                         ta.text += "    " + describeSObjectResult.fields[fld_name].picklistValues[j].value + "\n";
                  
                   
                         myPickList.addItem( {Type:describeSObjectResult.fields[fld_name].picklistValues[j].value } );
                         //cmbType[i] = [item.label];
                      }         
                }
                }
              
              }
         }
    }

<mx:ComboBox  id="cmbType"
            dataProvider="{myPickList}" rowCount="10"
            labelField="@Type"/>

  • August 15, 2008
  • Like
  • 0
Hi,

I've been attempting to query SalesForce data based on a range of ActivityDates.

Here's an example where I force the dates and everything shows up fine for this forced date range.

Within my apex.query, I have the following:
("Select field1, ActivityDate From Event where ActivityDate >= 2008-08-01 and ActivityDate <= 2008-09-30;

Now what I'd like to do is capture dates from a start and end dateField base my query off of those dates.

What is the approach I should take? Cast the Flex date I capture into Salesforce as a string or date? I've tried capturing the dateFields on a change event and setting the value to a string.
I've also tried converting the string to a Date (i.e., var dStartSearchBroker:Date = DateField.stringToDate(wholeStartDate, "YYYY-MM-DD") ) where wholeStartDate is the string value that I've originally set on the change event. Still no luck.

Any help that someone could provide would be greatly appreciated.

Regards,

EKM
  • August 14, 2008
  • Like
  • 0
Hi, all,

I'm attempting to create a new event and pass a string variable as an activity date from a dateField.

When I force the date, a new event is created, but when I try to save the selected date into a variable and then try to create the new event, the new event does not get created. Should I be sending a Date object instead of a string object? Is my String variable (myDateString) not formatted correctly?

If I've missed an example of this here on the threads, please point me in right direction. Otherwise, any assistance would be greatly appreciated.

Regards,

EKM


My related actionScript

// function for creating the Event
private function createEvent():void
{
 //other code for function here

// this doesn't work
//evt.ActivityDateTime = new Date(myDateString, startTimePassHour, startTimePassMinute, 0); // this doesn't work

//this does work
evt.ActivityDateTime = new Date(2008, 08, 01, startTimePassHour, startTimePassMinute, 0); // this does allow me to create new Events
       
//....code for apex.create([evt],.... goes here

}


public var myDateString:String;
  //function for saving dateMeetingAdd.text to string variable        
private function myDateToString():void
{
    myDateString = dateMeetingDateAdd.text;
    //Alert.show(myDateString);
}


//function for formatting the date
private function formatDate(date:Date):String {
                return DateDisplayApex.format(date);
            }



// Date Formatter to format the year, month, and date
<mx:DateFormatter id="DateDisplayApex"
        formatString="YYYY, MM, DD"/>

//the datefield I'm using to select a date for the event I'm creating
//calls myDateToString to save dateMeetingDateAdd to string
<mx:DateField showToday="true" id="dateMeetingDateAdd"
    labelFunction="formatDate" parseFunction="null"
    text="July 28, 2008" change="myDateToString()"/>

  • July 29, 2008
  • Like
  • 0
Hi,

I can create a new record from 2 text fields using the following:

private function createContactManager():void
    {

        var contact:SObject = new SObject('Contact');  
      
        contact.FirstName = firstName.text;  //firstname text field
        contact.LastName = lastName.text; // lastname text field

        apex.create([contact],
            new AsyncResponder( function (result:Object):void
            {
                
                }, genericFault
                            )
                        )
        }

But what about when I have contacts from a datagrid and I want to create new records for each contact within the datragid.
For instance, if I was using the following:
datagrid="dgContacts"
dataprovider="contactList"
arraycollection = acMyContacts

I'd appreciate any help provided or even if someone could point me to an example of this or where it's referred in the documentation. I have so far been unable to find anything.

Thanks.
  • June 23, 2008
  • Like
  • 0
Hi,

I'm creating an event and then wanting to pass the ID of that newly created event into another table (Event_Attendee__c). I save the ID to a variable (lastEventId).  I'm able to retrieve the newly created event ID, but have so far not been able to pass the ID into the function where I am creating a new event_attendee record. I'm getting Null in my trace statement in the createEventAttendee function for lastEventId.
Anyone have any thoughts as to how solve this?

Regards,

public var lastEventId:String;

private function create():void
        {
            createEvent();
            createEventAttendee();
        }

private function createEvent():void
      {
                     
        var evt:SObject = new SObject('Event');   
       
        evt.RecordTypeId = '01230000000DkER';
        evt.OwnerId = '005300000017Tz4AAE';
        evt.WhatId = '00130000008TiPdAAK';
        evt.ffCompany_Name1__c =  txtCustomerName.text;
        evt.ffCompany_Name2__c = txtCID.text;
        evt.Type = conferenceCallCheckBox;      
        evt.ActivityDateTime = new Date(2008, 5, 30, startTimePassHour, startTimePassMinute, 0);
        evt.DurationInMinutes = meetingTime;    
        evt.Travel_Time__c = cmbTravelTime.selectedLabel;   
        evt.Method__c = cmbMeetingType.selectedLabel;
        evt.Purchaser_Delivered__c = purDelivered;
        evt.Purchaser_Delivered_Quantity__c = txtPurDeliveredAddQty.text;    //Purchaser Delivered Quantity
        evt.PIH_Delivered__c = pihDelivered;
        evt.PIH_Delivered_Quantity__c = txtPihDeliveredAddQty.text;
        evt.Healthworks_Reviewed__c = healthworksReviewed;
        evt.Healthworks_Approved__c = healthworksApproved;
        evt.Facility_Tour__c = facilityTour;
        evt.Subject = subjectSelected;
        evt.Objectives__c = objectiveSelected; //Key Objectives
        evt.Actual_Outcome__c = txtOtherCommentsAdd.text;                //Other Comments;
       

          apex.create([evt],
          new AsyncResponder( function (result:Object):void
              {
                  trace( 'new event id: '+(result[0] as SaveResult).id );
                 
                  lastEventId = (result[0] as SaveResult).id;
                  trace('last event id: '+ lastEventId);
                 
             }, genericFault
         ) );   
       
      }

private function createEventAttendee():void
    {
        //using customized table Event_Attendee__c
        var eventAttendee:SObject = new SObject('Event_Attendee__c');
       
        //forcing this value for now   
        eventAttendee.Contact__c = '101010101';
        eventAttendee.Event_ID__c = lastEventId;
        trace("create Event lastEventId: " + lastEventId);
        eventAttendee.Status__c = 'Accepted';    //pass 'Accepted' string

        apex.create([eventAttendee],
        new AsyncResponder( function (result:Object):void
            {
               
            }, genericFault
        ) );
       
    }
  • June 17, 2008
  • Like
  • 0
Hi all,

I'm attempting to query a table (Events) based on a range of dates and another field (in this example, it's ffCompany_Name1__c within the Events table I'm using). The id of the dateField I'm using is dateStartDateMainEditMeeting.

I'm receiving a 1009 error with the code below.

Anyone have any suggestions what I can do query a table based on an ActivityDate? Thanks in advance for anyone's help.

public var dSource:String = dateStartDateMainEditMeeting.text;
public var dStartEdit:Date = Util.stringToDate(dSource);
            
        private function displayEditMeetingSearchResults():void
      {
        currentState="editMeetingSearchResults";
        var acc:SObject = new SObject('Event');
        apex.query("Select Id, " +
                "ffCompany_Name1__c, " +
                "ffCompany_Name2__c, " +
                "ActivityDate, " +
                "ActivityDateTime, " +
                "Method__c, " +
                "ActivityEndTime__c, " +
                "Type, " +
                "Objectives__c, " +
                "Subject, " +
                "Actual_Outcome__c, " +
                "Travel_Time__c From Event where ffCompany_Name1__c like '%Bank%' and ActivityDate >= '" + dateStartDateMainEditMeeting.text + "'",
            new AsyncResponder(function (qr:QueryResult):void
              {
                for (var j:int=0;j<qr.records.length;j++)
                    {
                    events.addItem( {ffCompany_Name1__c:qr.records[j].ffCompany_Name1__c, ffCompany_Name2__c:qr.records[j].ffCompany_Name2__c, Type:qr.records[j].Type, ActivityDate:qr.records[j].ActivityDate, ActivityDateTime:qr.records[j].ActivityDateTime, Objectives__c:qr.records[j].Objectives__c } );
                  
             
                }
      
                }
               ) // closes new AsyncResponder(function (qr:QueryResult):void
        ); //closes 1st apex query
    }
  • June 16, 2008
  • Like
  • 0
Hi,
I'm attempting to run a query and a subsequent subquery based off the original query and then display the results in a datagrid. I'm having difficulty with the subquery and would appreciate any help or guidance as to what I need to do. Below is the portion of code that I'm working with. As I said, the Role field from the 1st query populates fine, but how do I get the results from the 2nd query.

Thanks,

[Bindable]
public var ar2:ArrayCollection = new ArrayCollection();
   
    [Bindable]
    public var ar:ArrayCollection = new ArrayCollection();
   
    private function queryAccountManagerEdit1():void
      {
        currentState="searchAccountManagerEdit";
        var acc:SObject = new SObject('AccountContactRole');
        apex.query("Select ContactId, Role From AccountContactRole where Role = 'Decision-maker'",  
            new AsyncResponder(function (qr:QueryResult):void
              {
                for (var j:int=0;j<qr.records.length;j++)
                    {
                    ar.addItem(  { ContactId:qr.records[j].ContactId, Role:qr.records[j].Role } );
                    //ar.addItem(  { Role:qr.records[j].Role } );
                    apex.query("Select Id, Name From Contact where Id = ContactId:qr.records[j].ContactId",
                    new AsyncResponder(function (qr2:QueryResult):void
                        {
                            for (var k:int=0;k<qr2.records.length;k++)
                            {
                                ar2.addItem( {Name:qr2.records[k].Name});
                            }
                            //dgSearchAccountManagerEdit.columns = [ new DataGridColumn('Name'), new DataGridColumn('Role') ];
                            //dgSearchAccountManagerEdit.dataProvider = ar2;
                        }
                    )                    
                    )
                }
                // create the columns and specify the order
                dgSearchAccountManagerEdit.columns = [ new DataGridColumn('Name'), new DataGridColumn('Role') ];
                dgSearchAccountManagerEdit.dataProvider = ar;    //assign the array as the data provider
                }
               ) // closes new AsyncResponder(function (qr:QueryResult):void
        ); //closes 1st apex query
    }  
  • May 29, 2008
  • Like
  • 0
Hi,

I am attempting to query data from the Accounts table as well as several child fields from the Events table. I can successfully query from each  individually but am not having success in combining them into one dataprovider which populates a datagrid.
I haven't seen an example of this, so if someone could point me in the right direction, I would great appreciate it. FYI, both tmp and eventNameDateTime are bindable arrayCollections.

Thanks,

Errol

private function displayEditMeetingSearchResults():void {
                             
                apex.query("Select Id, AccountNumber, Name, (Select Event.AccountId, Event.ActivityDate, Event.Id, Event.Type From Account.Events) from Account", new AsyncResponder
                (
                    function(qr:QueryResult):void
                    {
                        if (qr.size > 0)
                        {
                            tmp = qr.records;
                            //eventNameDateTime = qr.records;
                            eventNameDateTime = tmp.getItemAt(0).Events.records;
           
                        }
                    },
                    handleFault)
                );
            }
  • May 23, 2008
  • Like
  • 0