Forum Discussion

lsittler's avatar
lsittler
Brass Contributor
Jun 01, 2020
Solved

MC211640: Conditionally show or hide columns in a SharePoint list or library form

After several attempts to operate a conditional field on item form, the formula still invalid.

The use case is the following one:

  • 1 column Provider, type Choice with 2 values
  • 2 other columns msProducts and pnpProducts, type Choice
  • When the provider is equals to Microsoft, the column msProducts should appear
  • From the default SP form, click on Edit form > Edit columns > (Ellipsis on msPorducts) > Edit conditional formula
  • The tested formulas with invalid condition are:
    1. =if([$Provider]=='Microsoft', 'true', 'false') : formula suggested by the official documentation https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-conditional-show-hide
    2. =if([Provider]=='Microsoft', 'true', 'false')
    3. =if(Provider=='Microsoft', 'true', 'false')
The same tests are performed by replacing '==' by '=' and by removing the simple quote around true & false
  • This formula is valid but does not work
    1. =if(@Provider=='Microsoft', 'true', 'false')

The conditional formula is not functional currently or something is wrong?

  • lsittler As far I have tested this function only works in the display form not in Edit or New Form. Even they don't allow to save the formula as real time evaluation of fields are not happening.

    See the below screen shots: 1. New Form:

    2. In Display form It works:

    3.Finally Display Form formula:

    But you can use power-apps that will give you this feature.  If I could help to find the solution, please like or mark the answer as solution.

     

    Thanks

    Vik

     

  • lsittlerVikram_Samal : The formula works, This is not work on click event you need to save the form completed in order to work this formula.

    For example, Region selection, I want to show/hide Finished Goods Notification column

    1) Condition: if Region = US, hide Finished Goods Notification else show

    2) Click on edit item, change the region to US.

    3) Then click save in save form.

    4) Open the form and Display mode, see below screenshot Finished Goods gets hidden.

    5) then open the form in Edit mode, here also Finished Goods Notification column is hidden.

    6) I wrote the formula on Finished Goods Notification column as below:

     

    • Vikram_Samal's avatar
      Vikram_Samal
      Steel Contributor
      Ashis when I was referring that you can’t use it in new form and edit form, I am referring to click event. As hide and show solution does not suffice all the aspects of a solution rather a partial one so that’s the challenge. On the other hand power apps being the better complete solution. Finally when you use the formula while you are in edit form and new form also it do not allow you to save giving me the error where as in display form it allows. Do you experience it differently.

      Thanks
      Vik
      • Ashish_Kohale's avatar
        Ashish_Kohale
        Iron Contributor

        Vikram_Samal : Its working for me on Edit and Display form as per the steps mentioned by me in earlier screenshots.

         

        As per the microsoft standard step mentioned in the link also given by the lsittler ----> https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/list-form-conditional-show-hide

         

        Note: Check the second step, it says Open an item to view the item details in the display form.

        So in order to imbibe the formula you have to follow as per given standard steps.

         

        To show or hide a column in a list or library form:

        1. Go to the list or library for which you want to show or hide columns in the form.

        2. If you are in a list:

          • Open an item to view the item details in the display form.
        3. If you are in a document library:

          • Select a file.
          • In the Information Pane:
            • Locate the Properties section.
            • Click Edit all.
        4. At the top of the form, select Edit Form > Edit columns.

        5. In the Edit columns pane, check (to show) or uncheck (to hide) the box for the column or columns as needed.

         

        Note: PowerApps is the best solution to implement this functionality, this way you can show/hide fields on click/change of dropdown values.

         

  • Vikram_Samal's avatar
    Vikram_Samal
    Steel Contributor

    lsittler As far I have tested this function only works in the display form not in Edit or New Form. Even they don't allow to save the formula as real time evaluation of fields are not happening.

    See the below screen shots: 1. New Form:

    2. In Display form It works:

    3.Finally Display Form formula:

    But you can use power-apps that will give you this feature.  If I could help to find the solution, please like or mark the answer as solution.

     

    Thanks

    Vik

     

    • lsittler's avatar
      lsittler
      Brass Contributor

      Hi Vikram_Samal, thank you for your answer.
      I understand that Power Apps is the solution to create custom form but I had hope that SharePoint could have a simple feature like this because the formula is available for the edit mode too.

      It is complicate to explain to the final users that, yes you have a conditional formula but no it does not work like that.

      Create a Power Apps for a simple use case like this one is pretty huge (potentially with authorizations, licences and external sharing).
      Anyway, it is noted. That you for your time 🙂

Resources