本文介绍了的Adobe Salesforce的问题,改变的ID以名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,从客户对象转换例如的AccountId字段联系人的帐户名称。

I am having a problem converting for example the AccountId field in Contacts to the Account Name from the Account Object.

我曾尝试以下查询:

选择名称, Account.Name 从联系

但是,当我看到控制台当我调试我看到,这已被转换到应用程序

But when I look at the Console when I debug the application I see that this has been converted to

选择称呼,名字,姓氏,的AccountId 从Entity_Contact

所以结果是,仅仅帐户ID显示,这我可以从摆在首位的联系人记录了。

So the result is that just the Account Id is shown, which I could have got from the Contact record in the first place.

有没有什么办法让帐户名,这样我可以在DataGrid中显示出来。

Is there any way to get the Account Name so that I can display it in a DataGrid.

感谢

罗伊

推荐答案

您的语法是正确的。为Force.com的DesktopWrapper类Flashbuilder的直接与本地数据存储,这反过来处理同步到Force.com相互作用。不幸的是,在当前版本中,关系查询不支持,并从本地存储。这就是为什么你看到查询扁平化。

Your syntax is correct. The DesktopWrapper class of Flashbuilder for Force.com interacts with the local data store directly, which in turns handles the syncing to Force.com. Unfortunately, in the current release, relationship queries are not supported to and from the local store. That's why you see your query "flattened".

在控制台窗口中,什么是记录的是翻译的SOQL到SQL通知。该SQLl是什么是执行对本地存储。

Notice in the console window that what is logged is the translation from SOQL to SQL. The SQLl is what is executed against the local store.

如果您需要将离线数据有,那么你就需要通过app.wrapper类客户端上执行两个查询和关联,或加入数据。由于ActionScript是动态的,你可以附加帐户数据的联系人数据与相应的帐户ID。

If you need to have the data offline, then you will need execute two queries via the app.wrapper class and correlate, or join the data on the client. Since ActionScript is dynamic, you can just attach the Account data to the contact data with the corresponding Account Id.

下面是一个刺在什么可能是这样的:

Here is a stab at what that might look like:

            [Bindable]
        protected var myData:ArrayCollection = new ArrayCollection();

        protected function loginCompleteHandler( event : LoginResultEvent ) : void {
            CursorManager.removeBusyCursor();
            // When the login is complete the main state should be shown.
            currentState = "main";
            //Execute the contact Query
            app.wrapper.query("Select Id, FirstName, LastName, AccountId From Contact",
                new AsyncResponder(contactQueryHandler, faultHandler, myData)
            );
        }

        // This function will iterate over the results creating a string value for the
        // "in" clause of the embedded Account query. It also creates a field on the
        // Contact dynamic entity so that our data binding works after initially setting
        // the data provider variable.
        protected function contactQueryHandler(qr:ArrayCollection, token:Object):void {
            var acctIdss:String = "";

            for each(var contact:DynamicEntity in qr) {
                if (contact.AccountId != null && acctIdss.indexOf(contact.AccountId) == -1) {
                    acctIdss += "'" + contact.AccountId + "',";
                }
                contact.AccountName = "";  // Add field to contact for account name
                myData.addItem(contact);   // Add contact to grid data data provider
            }
            acctIdss = acctIdss.substr(0, acctIdss.length - 1);
            // Query for the accounts based on the account ids found in the contact list
            app.wrapper.query("Select Id, Name From Account Where Id in (" + acctIdss + ")",
                new AsyncResponder(accountQueryHandler, faultHandler));
        }

        // This function simply iterates over the results and then iterates over the data grid
        // data provider to set the Account name for the correct contact.  Since data binding has
        // already occurred, the account name will be automatically displayed in the grid.
        protected function accountQueryHandler(accounts:ArrayCollection, token:Object):void {
            for each (var account:DynamicEntity in accounts) {
                for each(var contact:DynamicEntity in myData) {
                    if (contact.AccountId == account.Id) {
                        contact.AccountName = account.Name;
                    }
                }
            }
        }


    <s:Group includeIn="main"
         enabled="{!app.loginPending}"
         width="100%"
         height="100%">
    <s:layout>
        <s:BasicLayout/>
    </s:layout>
    <s:VGroup paddingTop="10"
              paddingLeft="10"
              paddingRight="10"
              paddingBottom="10" width="100%" height="100%">
        <mx:DataGrid id="dGrid" dataProvider="{myData}" width="100%" height="100%">
        </mx:DataGrid>
    </s:VGroup>
    <flexforforce:StatusBar left="0"
                            bottom="0"/>
</s:Group>

如果您不需要具备离线功能,你可以使用你原来的查询与app.connection对象。

If you don't need to have offline capability, you can use your original query with the app.connection object.

这篇关于的Adobe Salesforce的问题,改变的ID以名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 06:54