Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

New "File" data type - How to show in a grid?

  • 1.  New "File" data type - How to show in a grid?

    Posted Jul 02, 2020 08:38 AM
    I created a new custom entity which contains a field having the new "File" data type.

    I was able to place this field on the Main form, however when I am creating a View, this field does not appear in the list of selectable fields.

    Does anyone know how I can have a sub-grid which shows a "file" field?  I tried creating a separate "Single Line of Text" field, hoping I could use a Business Rule or Calculated Field to copy the name of the uploaded File, but both of those methods also don't show the "File" field as selectable.


    Thank you for any suggestions.

    ------------------------------
    Using Dynamics Online
    Dave Storey
    Ocean Pearl Consulting
    Nepean ON
    ------------------------------
    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 2.  RE: New "File" data type - How to show in a grid?

    SILVER CONTRIBUTOR
    Posted Jul 03, 2020 11:48 AM

    A few of us at FIS were pondering the very same thing earlier this week.

    The file datatype while now available for adding to the forms isn't yet available (nor it is unknown if planned) for it to be available for use in a view or advanced find.  If you are using tools such as XRMToolbox you can see the filename stored by executing a fetchxml similar to the following:
    <fetch>
      <entity name="opportunity" >
        <attribute name="XXX_dealvaluation_name" />
        <attribute name="XXX_profsvcsaudit_name" />
        <filter type="and" >
          <condition attribute="opportunityid" operator="eq" value="00000000-000-e911-a971-000d3ab98e59" />
        </filter>
      </entity>
    </fetch>

    Where XXX prefix is your org prefix and then the name that follows has the _name added to it by the system.  In the above example there are 2 that we have Deal Valuation and Prof SVCS Audit that both have the field type of file.

    You can use a tool like the View Designer in the XRMToolbox to customize an existing system or user view to add the attributes of the new file type field(s) you have created - it is important to note that the column header in the view will not be presented however after you save and publish it into the system (you can't use the OOB customization tools to add these to a view).   While this might be sufficient to add to a view the name of the file, it isn't very friendly for end users should they want to create their own views.

    NOT EXACTLY FRIENDLY WITHOUT A COLUMN HEADING IS IT?

    A more friendly approach can be taken and create an additional text field to hold the filename that has been uploaded, and a datetime field to hold the date when it was uploaded. You populate these new fields using a Power Automate approach that will trigger when the entity you are working on is updated.  Here is an example that will update fields on the opportunity record if a file is uploaded - note that the guid of the opportunity is looked up against the _objected_value in the fileattachments entity.

    Shows first 2 steps of PowerAutomate

    In the steps below we will do a conditional test to see if the list record returned contains the fieldname that we are looking for and if so then it will perform the update of the opportunity record. The first condition on the left is "Regardingfieldname" from the fileattachments entity - and the right condition is the name of the field  "XXX_dealvaluation"  which is manually typed.   The second condition on the left is File Name from the fileattachments entity and the condition on the right is XXX_dealvaluation field from the opportunity entity.  What we are doing is checking to see if the record returned in this list item is for the correct fieldname (checking for XXX_dealvaluation field name) and that the value in the opportunity field XXX_dealvaluation doesn't match the filename that is present in the fileattachments filename.

    And finally if the condition is true we take the path to update the opportunity newly created text field and datetime field so that we make it EASY for the end users to consume in a view, report, or advanced find the filename and the date/time that it was uploaded.  The files highlighted "File Name" and "Created On" are from the FileAttachments entity list record while the "Opportunity" record identifier is from the very first step.

    Enjoy

    ------------------------------
    William Suycott
    FIS
    Brown Deer WI
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 3.  RE: New "File" data type - How to show in a grid?

    Posted Jul 03, 2020 12:38 PM
    Thank you very much for the info.  I was able to add a Single Line  of Text field, and use JavaScript to populate it with the Uploaded Filename from the File field's OnChange event.  Took me a while to get the JS correct, but it is working.  When I have more time, I will definitely look into updating it with your method as it is definitely more elegant.  :)

    value = control.getAttribute().getValue();
    if (value != null) {
    var result_text = Object.values(value);
    let arr = [];
    for (item in result_text) {
    arr.push(result_text[item]);
    }
    return arr[3]; // Filename is the 4th element
    } else {
    return ""
    };

    ------------------------------
    Dave Storey
    Ocean Pearl Consulting
    Nepean ON
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


If you've found this thread useful, dive deeper into User Group community content by role