locked
CRM 2011 hide field values RRS feed

  • Question

  • In CRM 4.0 we used jscript to hide data values while leaving the label visible.  Very useful for creating "column headers" when you want 4 columns of data.

    crmForm.all.new_duedateheader_d.style.visibility = 'hidden';

    We cannot use field security since the data portion of the field is still visible.

    Any suggestions?


    Ken Compter

    Monday, January 14, 2013 4:39 PM

Answers

  • you can use normal javascript, with the field "new_duedateheader" the code will be:

    document.getElementById('new_duedateheader_d').style.visibility = 'hidden';

    note: unsupported customization



    • Proposed as answer by Guido PreiteMVP Wednesday, January 16, 2013 12:31 AM
    • Marked as answer by kcompter Wednesday, January 16, 2013 1:02 AM
    • Edited by Guido PreiteMVP Thursday, June 13, 2013 8:09 AM
    Monday, January 14, 2013 8:48 PM

All replies

  • Ken,

    Within the Form Editor, double click on the field you want to hide, notice there is a checkbox for the visibility of that field within the form and should be checked by default.

    Uncheck the checkbox, save and publish.

    Monday, January 14, 2013 4:42 PM
  • Gus thank you for your reply.  The issue is that also hides the label, which we want visible as the "column header".  The 4.0 code still works, but at some point, support for the 4.0 code will go away, probably without any notice from Microsoft, and at the most inopportune time.  So we are trying to get out in front of it.

    Ken Compter

    Monday, January 14, 2013 7:40 PM
  • Instead of using fields for the "column names" can you use sections instead?

    Sections add the label and no fields to be found.

    Monday, January 14, 2013 7:59 PM
  • you can use normal javascript, with the field "new_duedateheader" the code will be:

    document.getElementById('new_duedateheader_d').style.visibility = 'hidden';

    note: unsupported customization



    • Proposed as answer by Guido PreiteMVP Wednesday, January 16, 2013 12:31 AM
    • Marked as answer by kcompter Wednesday, January 16, 2013 1:02 AM
    • Edited by Guido PreiteMVP Thursday, June 13, 2013 8:09 AM
    Monday, January 14, 2013 8:48 PM
  • Guido, that worked!  Thanks so much.

    Ken


    Ken Compter

    Wednesday, January 16, 2013 1:02 AM
  • Expect this too to fail once you upgrade to UR12.

    All methods which rely on the DOM, such as document.getElementById are unsupported (and always have been) and likely to start breaking in the new cross-browser environment.

    Sections would seem to be the most natural way to achieve this. Do you have a screenshot of your current form as it looks now?


    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    Wednesday, January 16, 2013 4:06 PM
  • Here is an example.  As you can see, each "row" relates to the left column.  Tabs can only have 2 sections.  While Sections can have 4 columns, there is only 1 label.


    Ken Compter

    Wednesday, January 16, 2013 5:01 PM
  • Aha! So, a couple of techniques might achieve this:

    1) With CRM 2011 you can add a 2-column Tab. You can adjust the relative widths of the two columns to give the left hand one 40% (say) and include only a single-column section for the left hand fields. In the right hand tab area add a three column section for the other three fields. By giving the left tab more space this way you might avoid the word-wrapping which is causing uneven spacing.

    For the single column section on the left, include a label for "Task". Possibly don't include an underline - see how the alignment comes out. Format the section to keep labels on the left - you might want to right align them so they are closer to the check boxes.

    For the right hand tab three column section include the first row of real fields in it (not your 'fake' ones). Format the section to show field labels ABOVE the field rather than next to them. (customise the labels to match your headings). (this is why we need a two-column tab so that you can format this section like this, otherwise a four column section would show "Review new file" above the first field of the left column)

    For all other rows of fields, format each field to not show the label by default (no need for any javascript to do this).

    Your alignment may not be quite spot on doing it this way, do a quick mock up to see it.

    2) Alternative way to include column headings like that would probably be a web resource shown on the form to display a (static) HTML page with the headings in, and using a matching background colour to blend into the form (use an eyedropper tool to get the colour, or look it up in the SDK). You could use divs to make it adapt to different form widths if you want to get clever. If you want to use the two-column Tab to get more space for your left column than your right, just include two web resources, one in the left Tab area, one in the right. This approach also means you can choose an appropriate text style such as making the headings bolder than normal field labels.


    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    Wednesday, January 16, 2013 5:41 PM