Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Query DataSource directly? (Pro/EE version)

    Hi all,

    I have a DynamicForm with a SelectItem that has a foreign key (OptionDataSource is set on the SelectItem). Elsewhere in the code, I am manipulating the Record of the DynamicForm, but I don't have direct access to the "DisplayField" value that was displayed in the form.

    Is there a way to get a record from the foreign-key DataSource without going back to the foreign-key Record from the SelectItem? I'd love something like:

    Code:
    // pseudo-code (these methods don't likely exist)
    Record primaryRec = dynamicForm.getValuesAsRecord(); // form references fkID in SelectItem
    Record foreignKeyRec = foreignKeyDataSource.getRecord("fkID");
    String name = foreignKeyRec.getAttribute("fkName");
    Or maybe something using a RecordList as an intermediary.

    Thanks very much.
    Last edited by pmac; 18 Apr 2010, 07:46. Reason: to indicate a question in the title

    #2
    There's SelectItem.getSelectedRecord(), which gives you the related record. There's also the general purpose DataSource.fetchData(), that allows fetching any record via criteria, hence can fetch a single record by primary key.

    Comment


      #3
      Thanks very much. I kept looking for a "Record" as the return type of one of the methods to get a record from the DS that was already loaded. I forgot that DSCallback would give me the info in the async reply.

      I've been using the method to get the record from the item, but in some code that didn't have direct access to the UI, I didn't want to make a UI dependency just for the record. I get it now.

      Thanks again.

      Comment

      Working...
      X