How to Use an Apex-Defined Object with the Datatable Flow Component

How to Use an Apex-Defined Object with the Datatable Flow Component

Updated 1/23/21 to reference the v3 version of the Datatable that utilizes a Custom Property Editor.

I’ve updated my Datatable Lightning Web Component for Flow Screens to support a User Defined (also know as an Apex-Defined) object.

See my Flow and Process Builder List View with Batch Delete App for an example.

To work with an Apex-Defined object in your Flow, you need to create an Apex Descriptor Class for the object.

SampleClassDescriptor.cls

// Apex-Defined Variable Sample Descriptor Class
public with sharing class SampleClassDescriptor {

    // @AuraEnabled annotation exposes the methods to Lightning Components and Flows
    @AuraEnabled
    public String field1;

    @AuraEnabled
    public String field2;

    @AuraEnabled
    public Boolean field3;

    @AuraEnabled
    public Integer field4;    

    // Define the structure of the Apex-Defined Variable
    public SampleClassDescriptor(
            String field1,
            String field2,
            Boolean field3,
            Integer field4
    ) {
        this.field1 = field1;
        this.field2 = field2;
        this.field3 = field3;
        this.field4 = field4;
    }

    // Required no-argument constructor
    public SampleClassDescriptor() {}
}

In your Flow, you can create and use Apex-Defined record and record collection variables by referencing your Apex Class.

All of the fields in your variable will be available to use in the Flow.

In this sample Flow, I am setting field values in individual records as seen above.

I then add each record to the Apex-Defined record collection variable.

The Datatable component expects a serialized string of the object’s records and fields like the text seen here.

[{"field1":"StringRec1Value1","field2":"StringRec1Value2","field3":false,"field4":10},
{"field1":"StringRec2Value1","field2":"StringRec2Value2","field3":true,"field4":20},
{"field1":"StringRec3Value1","field2":"StringRec3Value2","field3":true,"field4":30}]

Since you can create Apex Flow Actions to work with your Apex-Defined object, I created an action that converts an Apex-Defined record collection to a serialized string that can be passed to the Datatable component. The action will also convert a serialized string back to a record collection. This can be useful in a Flow where you want to act on a collection of selected or edited records that get passed back to the Flow by the Datatable component.

Special Note: Even without an Apex-Defined Class, you can build a String in your Flow formatted as above and use that to populate a datatable.

You can use this code as a template for your own Apex actions designed to work with a Flow.

TranslateApexDefinedRecords.cls

/** 
 * 
 *  Sample Apex Class Template to get data from a Flow, 
 *  Process the data, and Send data back to the Flow
 * 
 *  This example translates an Apex-Defined Variable 
 *  between a Collection of Object Records and a Seraialized String
 * 
 *  Eric Smith - May 2020
 * 
 * 
**/ 

public with sharing class TranslateApexDefinedRecords {         // *** Apex Class Name ***

    // Attributes passed in from the Flow
    public class Requests {
    
        @InvocableVariable(label='Input Record String')
        public String inputString;

        @InvocableVariable(label='Input Record Collection')
        public List<SampleClassDescriptor> inputCollection;     // *** Apex-Defined Class Descriptor Name ***

    }

    // Attributes passed back to the Flow
    public class Results {

        @InvocableVariable
        public String outputString;

        @InvocableVariable
        public List<SampleClassDescriptor> outputCollection;    // *** Apex-Defined Class Descriptor Name ***
    }

    // Expose this Action to the Flow
    @InvocableMethod
    public static List<Results> translateADR(List<Requests> requestList) {

        // Instantiate the record collection
        List<SampleClassDescriptor> tcdList = new List<SampleClassDescriptor>();    // *** Apex-Defined Class Descriptor Name ***

        // Prepare the response to send back to the Flow
        Results response = new Results();
        List<Results> responseWrapper = new List<Results>();

        // Bulkify proccessing of multiple requests
        for (Requests req : requestList) {

            // Get Input Value(s)
            String inputString = req.inputString;
            tcdList = req.inputCollection;


// BEGIN APEX ACTION PROCESSING LOGIC

            // Convert Serialized String to Record Collection
            List<SampleClassDescriptor> collectionOutput = new List<SampleClassDescriptor>();   // *** Apex-Defined Class Descriptor Name ***
            if (inputString != null && inputString.length() > 0) {
                collectionOutput = (List<SampleClassDescriptor>)System.JSON.deserialize(inputString, List<SampleClassDescriptor>.class);    // *** Apex-Defined Class Descriptor Name ***
            }

            // Convert Record Collection to Serialized String
            String stringOutput = JSON.serialize(tcdList);

// END APEX ACTION PROCESSING LOGIC


            // Set Output Values
            response.outputString = stringOutput;
            response.outputCollection = collectionOutput;
            responseWrapper.add(response);

        }
        // Return values back to the Flow
        return responseWrapper;
    }
}

TranslateApexDefinedRecordsTest.cls

@isTest
public with sharing class TranslateApexDefinedRecordsTest {

    static testMethod void test() {

        List<SampleClassDescriptor> inputList = new List<SampleClassDescriptor>();

        TranslateApexDefinedRecords.Requests testRequest = new TranslateApexDefinedRecords.Requests();

        testRequest.inputString = '[{"field1":"value1","field2":"value2"},{"field1":"value31","field2":"value4"}]';
        testRequest.inputCollection = inputList;

        List<TranslateApexDefinedRecords.Requests> testRequestList = new List<TranslateApexDefinedRecords.Requests>();
        testRequestList.add(testRequest);

        List<TranslateApexDefinedRecords.Results> testResponseList = TranslateApexDefinedRecords.translateADR(testRequestList);
        system.debug('RESPONSE - '+testResponseList);
        system.assertEquals(testResponseList[0].outputCollection.size(), 2);
    }

}

When you configure the attributes for the Datatable in your Flow, you need to be aware of these settings:

  1. Start by checking Input data is Apex-Defined in the Advanced section
  2. In the Data Source section, enter your Datatable Record String
  3. Also in the Data Source section, enter a Datatable Record String for any Pre-Selected Rows
  4. There is no Column Wizard so you will have to list your Column Field names and other attributes manually.
  5. For Currency, Number and Percent fields the Column Scales attribute lets you specify the number of places to display after the decimal point. The default is 0.
  6. When you are using an SObject collection, the Datatable component gets information about all of the fields from the system. For a User Defined object, you need to specify the Column Type of data for each field. This can be left blank if all of the columns are text fields.
  7. You are required to provide the name of the datatable’s Key Field. All of the values in this field need to be unique in order for the datatable to function correctly.

There are separate output parameters for Selected and Edited User Defined objects as well.

The (User Defined) outputs will be serialized record strings rather than SObject collections. Be sure to reference the correct ones based on how you assigned the True or False value for the Input data is Apex-Defined attribute.


Get the Sample Flow and Source Code here:

https://github.com/ericrsmith35/Apex-Defined-Example

42 thoughts on “How to Use an Apex-Defined Object with the Datatable Flow Component

  1. Thank you for this. In attempting to implement this idea, I see that the format of the collection of my Apex-Defined Object (ADO) looks exactly like your example above of the serialized string that the Datatable component requires. So I am confused as to why we must go through all the trouble of “translating” our collection of ADOs.

    Specifically, I created a simple ADO with two fields: one String and one Integer. (I copied and pasted your ‘SampleClassDescriptor.cls’ code, and changed the names to protect the innocent.) I created a simple Flow which has two Assignment components in a loop and creates two of my ADO records and saves them in a Record Collection variable. Next in the Flow is a Screen component with a Display Text element with just the ADO Record Collection variable shown.

    When I debug the Flow, here is what is output in my browser:

    [{
    “versionSelected” : 99,
    “assetFamily” : “CADMOB”
    },{
    “versionSelected” : 99,
    “assetFamily” : “NMMCOR”
    }]

    As I originally stated, this displayed result looks to be the exact serialized string format you show above. Yet if I have a Datatable element in the Screen component, and select “Input data is Apex-Defined”, the ‘Datatable Record String’ does not show my ADO record collection variable as selectable. (I wish I could add screenshots here, as that might make it a bit clearer.)

    Could you please elaborate on/explain why the Datatable does not directly accept the seemingly-correctly formatted ADO record collection, and therefore we need to “translate” these ADO collections to a format usable by the Datatable?

    Like

    1. The Flow Builder processes collection variables differently than string variables. Even though your collection variable looks like it is formatted the same, it is not. Because the Datatable component is expecting a String as input, your collection variable has to be converted to a String by looping through your collection.

      I’ve fully described a sample flow that handles this conversion. You can download the explanation here: https://1drv.ms/b/s!Akbs_lceUmo-hqpr5kuX9U5u0FlHJg?e=9TJ5bQ

      Like

      1. Thank you for the sample. I was not asking for, nor expecting, that personalized of a response – wow!

        I guess my mind was just not thinking that how an ADO record collection is displayed is not necessarily how it looks “under the hood”. My eyes were playing tricks on me, in a way.

        Forgive me if it is too bold of me to ask, but: Is it on the roadmap to add functionality to the Datatable so that it can directly take an ADO record collection as input?

        Like

  2. Me again….

    I copied and slightly modified (to use my ADO) your ‘TranslateApexDefinedRecords’ class, and was having an issue:

    I have a Screen component with a Datatable element, which is placed (like in your Flow above) immediately after my translate Action component. After I check ‘Input data is Apex-Defined’, when I go to select the ‘Datatable Record String’ my translate Action output is not showing up as selectable.

    In your explanation above, you did not explicitly state whether we needed to manually assign the translate Action output to a variable, so I downloaded your Apex-Defined-Example from GitHub and deployed it untouched.

    In your Screen Component, I see that the second of your two Datatable elements takes “{!Translate_Apex_Defined_Records.outputString}” as the ‘Datatable Record String’. In other words, you did not manually assign the output of the translate Apex Action.

    So does it seem to you that I am doing something wrong in my Flow since my Datatable element is not seeing my translate Action output? From the info I have given, can you tell what I might be missing?

    Like

    1. Before doing that, I took your sample Flow, deleted the Screen component, added a new Screen component, and added a Datatable element to it. On the Datatable I checked ‘Input data is Apex-Defined’.

      When I click in the ‘Datatable Record String’ field, the only choices I have are:

      —————
      VARIABLES
      aApexDefinedRecord
      Apex

      vInputRecordString
      String
      —————

      I do not have the “{!Translate_Apex_Defined_Records.outputString}” option like is in your original Screen > Datatable.

      Like

      1. UPDATE

        In my Flow, I added a String variable to populate it with the output of my version of the translate ADO Apex. In my Datatable element I was able to see and select that String variable as my ‘Datatable Record String’. I tried filling in other Datatable CPE items that seemed to be required – even to the point of making sure that I had a value in every one that your sample “ApexDefinedDatatable2” element has. No matter what I do or try, i get 1 error in the Screen component that tells me that my Datatable element is and “Invalid Component”. There are no other indications – either in the Screen component or anywhere in the Datatable CPE – that indicate what that error is and/or what makes it invalid.

        So I went back to your sample Flow, added a new Screen component to which I added a Datatable element, and manually, meticulously, recreated your “ApexDefinedDatatable2”. I still could not see, when I clicked in the ‘Datatable Record String’ field, the Translate_Apex_Defined_Records output to be able to select it. So I manually entered “{!Translate_Apex_Defined_Records.outputString}”. I entered the same values in all the rest of the fields as in your “OOB” sample. I ended up again with 1 vague “Invalid Component” error and could not save the Screen component without removing the Datatable element.

        Although I have built one fairly complex Flow which has made it safely into Production, I am not a Flow expert. Even though this very well could be a BCAK/ID10T error, I do not know where to begin diagnosing this issue. And since I need to move forward with my larger task at hand, I do not have the time now to try to figure it out. I guess I will need to discuss with my team about creating a new custom Salesforce object instead of an ADO so that we can still use the Datatable.

        Like

    1. Huh. That worked.

      I had discovered your recent “new fsc_flowCheckbox” pull request into the Lightning Flow Components repository. I cannot see the draft writeup, but I could see your Quip document in which I read, “Checkbox values used in a CPE will not retain a checked status unless they are checked, unchecked then checked again.”

      With that info in hand, before typing out my UPDATE comment above, I had already tried unchecking the Apex-Defined option and then rechecking it (and re-unchecking and re-rechecking it). But I did not add in the interim step of selecting an Object.

      Thank you!

      Like

  3. Me again….

    – I have my Apex-Defined Object (ADO) and my modified version of your TranslateApexDefinedRecords (TADR) class.

    – I have an Action step in my Flow that calls the TADR to convert my ADO record collection to a serialized string. My Action step is called “Convert_ADO_Data_to_Serialized_String”.

    – My next step is a Screen step with the Datatable. I have ‘Input data is Apex-defined’ checked, and my ‘Datatable Record String’ is “{!Convert_ADO_Data_to_Serialized_String.outputString}”.

    [ An aside: This outputString did not appear in this box for me to select – I had to manually add “{!Convert_ADO_Data_to_Serialized_String.outputString}”. After manually addidng, I get thie “This Flow doesn’t have a defined resource with that name. If you’re trying to enter a literal value, don’t use {!}” error/warning appear below this field. Yet I am able to click ‘Done’ on the Screen component and save and run the Flow and see the expected data in the Datatable. ]

    – – I have 4 ‘Column Fields’ listed: partNumber,assetFamily,versions,versionSelected

    – – I have tried the following two entries into the ‘Column Edits’ field:
    > partNumber:false,assetFamily:false,versions:false,versionSelected:true
    > versionSelected:true

    But whenever I debug my Flow, the versionSelected column is not editable

    ———-

    Other notes:

    – All fields are ‘String’ in the ADO, and therefore would be ‘text’ in the Datatable, so my ‘Column Types’ is empty.

    – I do have ‘Column Labels’ for all four columns, and they appear correctly.

    – I do have explicit ‘Column Widths’, and that appears correctly.

    – I have tried having “Disallow row selection” unchecked and checked.

    ———-

    I know when I first was testing this after I installed it, that one of the first things I did was to create a simple ADO and test whether I could edit one of its columns in the Datatable. I was able to, but I don’t recall anything special that I did to make that happen. It was an ‘Integer’ column, so I don’t know if that makes a difference.

    Reading through the Datatable documentation on UnofficialSF, some of your blog posts, and the Issues tagged ‘component:Datatable’ did not reveal anything to me to either indicate that this should not work or that I have it configured wrongly.

    Can you please help?

    Like

      1. That is a very generous offer. This is a sandbox cloned from something very close to Production, so I cannot give you access to this org. It will take some finagling to set up a new org with some of this same code. I will try to do that, and if successful, will shoot you an email.

        Like

  4. When trying to do the finagling I mentioned in my previous reply, I figured I should start with a simple Flow creating one Apex-Defined Object (ADO) record which has one String field value, display that in the Datatable, and see if I could replicate the issue. If so, I was going to spin up a Trailhead “Hands-On Org” and see about giving you access.

    I was able to replicate the issue in that simple sample Flow.

    Being frustrated, I said to myself, “Self, how did you get it to work (be editable) on the first sample you made way back when?” That’s when I realized that when I did that first post-install test, the column I was testing for editability was an Integer – which means that I had to explicitly indicate it in the ‘Column Types’.

    So “on a hunch” I explicitly set my column to “text”, and it worked – the column became editable.

    I went back to my original Flow and explicitly set to “text” the one column which I want to be editable, and it worked, there, too.

    Therefore it seems that there is a bug (I hope that this is not a feature!) so that even though the default Column Type is text, you have to explicitly declare any text columns that you want to be editable. At least with an ADO – I didn’t test it with a Salesforce Object.

    Like the checkbox issue, this could be a problem with the CPE and not Datatable, but I don’t know how (nor do I currently have the time) to determine or isolate that.

    Would you like me to enter this as an issue on the LightningFlowComponents GitHub?

    Like

  5. I hate to keep bothering you, but…

    …Once I got past that hurdle, I immediately came upon another: In both the simple sample Flow I created, and in my “actual” original Flow, when I edit data in that column and click ‘Save’ (the ‘Save’ button that appears once I edit a column and it gets highlighted in yellow), the edit immediately disappears and the column value reverts back to what it was when the Datatable was originally populated.

    I again looked in USF documentation, GitHub documentation and a couple of your blog posts, and I didn’t see anything that said you had to do anything special in order for edits to persist in the UI. Did I miss something?

    Like

  6. I did a good bit of meticulous testing, and was going to post many of the details here. But there is a lot.
    “Let me ‘splain…No, there is too much – let me sum up.”

    There seem to be two major/key issues that I am having:

    1) Edits to an ADO (I have not tested a “regular” Salesforce Object) do not persist in the UI when ‘Hide Cancel/Save buttons’ is unchecked, and – worse yet – do not seem to be saved in the ‘.outputEditedRowsString’ variable regardless of whether that checkbox is checked.

    2) Even with FlowScreenComponentsBasePack Version 2.1.6 installed, I am still having Datatable CPE checkbox issues.

    The second issue is frustrating, but “overcomeable”. The first one is (obviously) a deal-breaker for us to be able to use the Datatable as we need to.

    I am happy to share details (including animated .gif screen captures) of the testing that I did. Just let me know.

    Like

    1. Well don’t I feel silly. Turns out it was an ID10T error!

      No, I never specified a Key Id field. In all the examples that I had seen – even using ADOs – I only ever saw “Id” as the value in that CPE field, so I overlooked it for every permutation of my testing.

      As soon as I changed it to my “partNumber”, the edits were saved in the ‘.outputEditedRowsString’ variable.

      Sorry to have bothered you.

      Thanks again!

      Like

  7. In Datatable 3.0.10, did you change something that you know of which would affect the use of Apex-Defined Objects (ADO)?

    Quickest overview I can give, yet still let you see the pertinent things I have done:
    – Got the Flow I was working on (previous comments/posts) to a working state with Datatable 3.0.9.
    – Created a new sandbox and installed:
    – – FlowActionsBasePack 2.12
    – – FlowScreenComponentsBasePack 2.1.6
    – – Datatable 3.0.10
    – Assigned myself the new ‘USF Flow Screen Component – Datatable’ Permission Set.
    – Deployed the Flow (and a few new Apex classes) to the new sandbox.

    * My first Screen component that has a Datatable element uses a standard object (Asset) and works fine.
    * My second Screen component that has a Datatable element uses an ADO, and it is not displaying any data nor is it displaying any column labels.

    – Deleted my Flow
    – Unassigned the Permission Set
    – Uninstalled Datatable 3.0.10
    – Installed Datatable 3.0.9
    – Deployed my Flow

    Everything works.

    —————–
    It appears that it either has something to do with the Permission Set or something “under the hood” that may have changed regarding ADOs. The Perm Set seems to me to be less likely since the Datatable works with the standard Salesforce object.

    Please let me know if it is, again, a problem between keyboard and chair. Otherwise, I’m happy to give more details, screenshots, animated .gifs, video, or whatever you might want or need.

    Like

    1. I don’t know why I don’t think of doing some more things before giving you details of a perceived issue….

      I deployed your GitHub ‘Apex-Defined-Example’ code into a sandbox that has Datatable 3.0.10, and when I ran the Sample Flow it seemed to work correctly and show everything.

      —-
      One other detail on what I earlier tried with my own Flow:

      Like you did in your Sample Flow, in the same Screen Component as my Datatable I added a “Display Text” element that shows the outputString of my Apex Action call which does the translation/conversion of my ADO collection. It looks correct. Just the Datatable is not showing anything. So it does not initially appear to be a data issue.

      —-
      So now I’m leaning toward something with the specific setup/configuration that I have for my Datatable. In the near future I will compare your sample Datatable setup and mine – as well as your translated outputString format and mine.

      Like

      1. Hi Moonpie, I have same 2 issues with you
        1.) When select Apex defined Object, the Datatable Record String I can’t select Translate_Apex_Defined_Records.outputString, I need to manually enter it, and after I do that, there’s an error show below: “This Flow doesn’t have a defined resource with that name. If you’re trying to enter a literal value, don’t use {!}” error/warning appear below this field. But I still can ignore it and save my screen flow. I use Datatable 3.0.10 and I tried something you mentioned in this tread, uncheck Apex defined Object option and select Account and check Apex defined Object option again. Still same error there.
        2.) I use Datatable 3.0.10 but like Moonpie mentioned, all edited value not saved into outputEditedRowsString, it return [], I ‘ve set key field in my datatable.

        Do you have any idea?

        Liked by 1 person

  8. @Wayne Chung:
    1) That still happens to me. I just ignore it now.
    2) I have an idea – see below. Do any of your fields have an array for their value?

    ==========
    @Eric:
    I finished my Flow using 3.0.9, and although it needs some aesthetic tweaks and it would really be great if I could use a picklist for the column the users need to edit – it works well.

    When I went to deploy everything I’d been working on (not just this my Flow) into a fresh sandbox in order to test the targeted deployment of everything, I installed the latest version of the USF Base Packs and of Datatable. The issue of not seeing columns or data in my second use of the Datatable reared its head again.

    After making sure I had permissions for all needed Apex classes, and checking other settings, I settled in again on Datatable 3.0.9 vs 3.0.10.

    Again I deployed your ‘Apex-Defined-Example’ freshly into both sandboxes, and it works fine in both.

    Since I had a little more time and impetus to dig, I did so. When debuggin the Flow I could see data being output from my previous Apex Action step of converting ADO data to an string, so I wondered if it was some sort of rendering issue. Looking in browser console I found something interesting. I wish I could paste a screenshot; instead I’ll copy the error:

    “Uncaught (in promise) Error: Error during LWC component connect phase: [Cannot set property ‘edit’ of undefined]
    at Object.handleNavigationError (flowRuntimeV2.js:21)
    at eval (flowRuntimeV2.js:2)
    at eval (runtimeLib.js:1)”

    Again, looking in the browser console, everything looks exactly the same from “datatable VERSION_NUMBER 3.0.X” all the way down to where this an output that looks like “mydata: >Proxy” – the entries and values when I expand “Proxy” look different.

    Then after “mydata: >Proxy”, both have an entry that says “Processing updateColumns”. That is where the above error occurs in v.3.0.10; but in v3.0.9 the next entry is not an error, but is instead “this.cols >Array(4)”.

    ———-
    When I was able to focus in on exactly when the error is occurring, and knowing that the data is the same that I am using for both versions, I starting thinking that something might have changed on how it handles the data….

    The value for one of my fields is an array. I have to show the user the asset versions they can select from, and different assets have different numbers of available versions (and some have none). Whether I have an empty array, an array with one value, or an array with mutliple values, this is displaying just find in v3.0.9.

    Did something change in v3.0.10 that would make the datatable component not handle a field that has array values the same way it did in v3.0.9?

    Like

    1. What are you defining as the Field Type for the “array” field? Are you able to Share your ADO code along with some sample data with me so I can run some tests?

      Like

      1. [Saw your reply after I posted the update below.]

        I didn’t have that datatable field explicitly defined as it was a List in the Apex-Defined Object (ADO). After changing it to String in the ADO, I still haven’t explicitly defined it in the datatable.

        But as my below update indicates, it does not appear that the (only?) issue is that it was a List or array.

        Yes, I can share the code and sample data, but it will need to be later today.

        Like

  9. Well, that [handling field values that are arrays] does not appear to be the issue.

    I went back into my code and modified it to where that Apex-Defined Object’s field is now just a ‘String’ rather than a List. Then I modified other code so that it takes the original List data, and puts into one comma-separated String value.

    I did that first in v3.0.9, and verified that it is working and still displaying.

    When I put the same code into the sandbox that has v3.0.10, the exact same thing happened: no columns or data displayed, and the exact same error noted in my previous comment.

    And just to cover more bases, I usually use Chromium-based Vivaldi as my browser, so I connected to my sandbox with both Chrome and Edge and the same thing happened.

    Now I have to figure out where to start looking. I guess I need to more closely compare your ‘Apex-Defined-Example’ datatable setup to my datatable setup.

    Like

  10. Good gravy, that was so frustrating!

    I discovered two things, but let me give some background….

    My ADO has 4 fields:
    – partNumber
    – assetFamily
    – versions
    – versionSelected

    At this point they are all String.

    ‘partNumber’ is both the first column I have listed, and it is explicitly set as my key in the CPE “Key Field” field.

    The only field I want to be editable is ‘versionSelected’. So in the “Column Edits” field in the CPE I had ‘versionSelected:true’.
    > In 3.0.9 this worked
    > In 3.0.10 it throws the aforementioned error

    ———-
    For debugging purposes:
    – I cleared out the “Column Edits” field.
    RESULT: The datatable rendered with column headings and data. (The field I ultimately want to be editable was obviously not editable, but I was just trying to find the issue.)

    – I put only ‘versionSelected:true’ back in.
    RESULT: The original issue resurfaced: datatable did not render, and I got the error.

    – I put in ‘partNumber:false,assetFamily:false,versions:false,versionSelected:true’.
    RESULT: rendered properly, no error

    – For grins & giggles I put only ‘partNumber:false,versionSelected:true’
    RESULT: rendered properly, no error

    ** So my best guess is that your Key Field has to be included in the “Column Edits” field – even if you don’t need to explicitly set it – along with any other fields that you do want to explicitly set. **

    ===================
    The second interesting thing that I discovered is that it seems that 3.0.10 also actually does not properly handle arrays/Lists. I did all of the above experimentation *after* I had already done the work to change my ADO List field to just .

    So for more grins & giggles, after getting the datatable to work with the above ‘Key Field in the “Column Edits” fix’, I tried using my original ADO that has a List for the ‘versions’ field.

    RESULT: The datatable did render, and I did not receive the error; HOWEVER, the data – which I verified is there in the serialized string – did not appear in the datatable. My ‘versions’ column was empty.

    ———-
    So I tried playing around by adding ‘versionSelected’ to the “Column Edits” field and to the “Columns Type” field where I explicitly indicated that it was “text”, and different combinations and permutations of such. Nothing I tried would let the values be visible in the datatable.

    ====================
    So it seems that we can use 3.0.10 now, but not with an array/List.

    Like

      1. (I told you this in the email I just sent you, but to possibly help any future blog visitors with the same issue I’m stating it here as well.)

        Explicitly setting the Column Type for my List Apex-Defined Object field to be ‘richtext’ worked for datatable v3.0.10 – the values properly displayed.

        Thanks!

        Like

  11. @Wayne Chung:
    #2 I’m not able to reproduce this. Make sure you are manually assigning your Output variables and that you are not trying to edit your Key Field

    Like

    1. @Eric, I’ve manually assigned output edit var and not set key field editable but still can’t see output edit var stored my edited data successfully, may I have a call with you(based on your time zone) or how can I show you my ADD apex and flow datatable configuration? Your help will be necessary, Thanks a loot.

      Like

  12. Let me preface this by saying that I appreciate your hard work and dedication to this project – to creating and fixing and updating – and for offering it at no cost. But at this point, since the Datatable is somewhat mature, I think that better, more thorough, or just some testing needs to be done – whatever the case may be – before releasing an update.

    I feel like I’m playing Whack-A-Mole here….

    My Apex-Defined Object (ADO) List field – essentially an array of Strings – worked (i.e., was displayed in the UI) in 3.0.9 in a text column in the datatable.

    With no changes on my part, the same ADO field would NOT display in 3.0.10. (Not only did that field not display, but no column headers/labels and zero records would display.) I was told to change my datatable column Type to textarea. I did, and my records and field data displayed.

    With no changes on my part, the same ADO field will NOT display in 3.1.1. (Again, no column headers/labels and zero records are being displayed.)

    —–
    I verified this by taking a fresh sandbox, installing FlowActionsBasePack 2.17, FlowScreenComponentsBasePack 2.2.1 and Datatable 3.0.10, and deploying my Flow and its dependencies. My records displayed as designed.

    Then I upgraded Datatable to 3.1.1. My records will not display.

    —–
    I know many other changes were made in 3.1.1, so it might not directly be anything to do with text or textarea Type. I also had other issues with my ADO when going from 3.0.9 to 3.0.10 [see previous comments and replies] – such as having to explicitly set my key field to ‘false’ for Edits so that I could edit the field that I wanted.

    However, if upgrades are going to change things such that it could break current usage, please give better notification/indication of this. If you are not of aware of what it could break, please do deeper/better/longer testing even if that means longer spans between update releases.

    I intend to methodically go through my Datatable configuration and change one thing at a time in order to see if I can narrow down what does or does not seem to be causing this issue. I am happy to share my findings. In the meantime, if you know or have a good idea what I should focus on, please let me know.

    Like

    1. Let me start by saying that if you change the column type for your array field to ‘richtext’ it will display correctly.

      I have built out a fairly large collection of test flows that I run through before any new release and I use these to try and catch any changes that would cause obvious issues. I take great care in trying to make sure that any new attributes or attribute changes should not affect any existing flows.

      I am humbled by the popularity and the amazing variety of use cases this component has enjoyed. When I first added the ability to support Apex Defined Objects, I hadn’t forseen the need to embed objects and collections within individual fields. My hope is that the ‘richtext’ column attribute available in the current release will support those various options.

      BTW – I have created a new Test Flow (Test Datatable Apex Defined Moonpie) that will display a datatable with the sample data you had shared with me.

      Like

      1. Eric,

        I apologize that in my frustration I insinuated that you do not test. I was quite sure that you do test. It’s just that I feel like pulling my hair when so far each time that there has been a datatable update that seems to include something which would be beneficial to our use case, that installing it also breaks what I’ve already done.

        I’m glad that you are using the sample data I shared, and find it quite amusing that you have included ‘Moonpie’ in the test Flow name. 😀

        More apologies – this time for mistyping in my post. That field was already ‘richtext’, NOT ‘textarea’. I was using my memory (which I guess I should refrain more and more from doing now) when typing that.

        I just looked in my other sandbox where I was doing the dev work and verified that it is, indeed ‘richtext’. I made it ‘richtext’ in 3.0.10 and it displayed, but when I upgraded to 3.1.1 – without making any changes to anything else other than upgrading datatable – it is no longer displaying. I will email you an .mp4 screen capture (if it is not too big and my email will send it and yours will accept it).

        So maybe if my test data is showing correctly in your 3.1.1 datatable, it might be a different setting or configuration that is causing this issue.

        I still haven’t gotten around to changing the datatable configuration one-item-at-a-time (I have a day job that for some reason I am being asked to do) and noting the results, but when I do I will get that information to you as well.

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s