MS CRM 2011 forms: "visible by default" Field Property checkbox is not working - dynamics-crm-2011

I recently migrated a crm 4 database to crm 2011. We are using the on premise version.
I am now adapting scripts and forms to crm 2011. With one of my forms I have the following issue: I am trying to hide the owner from the form.
To do this I have unchecked the "Visible by default" check box on the Field Properties form.
This works on most forms, but on one of the forms the owner is displayed no matter what I do. I've been able to move the field around in the form, remove the label etc. All this works, but changes to the visibility will not work.
Has anybody seen this? Why is it not working? Does anybody have an idea on how to fix the issue without writing custom javascript (this probably would work, but I'm interested in getting the "Visible by default" checkbox to work again.
Update
The custom entity only has a single form defined.
There is no custom javascript on this form but I checked for javascript errors anyway and there were none. Even more strange, if I look at the html code I see
the following code if the check box is NOT ticked (style visiblity set to visible!):
<td class="ms-crm-FieldLabel-LeftAlign ms-crm-Field-Required" id="ownerid_c" style="visibility: visible;">
whereas is the checkbox IS ticked I will get (no style attribute at all!):
<td class="ms-crm-FieldLabel-LeftAlign ms-crm-Field-Required" id="ownerid_c">
needless to say that I did publish my changes.
On a form where the check box is working as expected I see the following html (style attribute display set to none):
<td class="ms-crm-FieldLabel-LeftAlign ms-crm-Field-Required" id="ownerid_c" style="display: none;">
Update 2
This issue is happening in the update form of the entity (so the owner is not null).
I moved the owner to a section and tried hiding the section, but unfortunately the section
will not hide. *But if I move the owner out of the section, the section will hide. I wonder what this owner field has, that won't let me hide it.

This plagued me for ages until I realized what was going on. I was trying to make an update form completely readonly. The CRM form requires at least one readable field on an update form. When it doesn't find one, it leaves one visible and readable (normally the owner or name field or whatever happens to be the last field on the form). I found the following javascript code somewhere and it works well to disable all the fields on the form without showing the pesky owner field that you have set not visible by default. (Props to the author as I don't remember where I got it)
function DisableFormFields() {
Xrm.Page.ui.controls.forEach(function(control, index) {
if (doesControlHaveAttribute(control)) {
control.setDisabled(true);
}
});
}
function doesControlHaveAttribute(control) {
var controlType = control.getControlType();
return controlType != "iframe" && controlType != "webresource" && controlType != "subgrid";
}

Because this is such a basic part of forms in CRM, I'm going to guess that your true problem is something else that results in the field not getting hidden. If you push F12 in IE, and go to the script tab to debug, do you see any javascript errors?
Also ensure you're looking at the correct from. In CRM 2011, you can have different forms for different roles, so be sure to check the forms drop down on the upper left.
And don't forget to publish your customizations!
Edit
I do know that if a field is marked as required, it will display it anyway if you attempt to save the form and it is null. Is this happening on a create of the entity, or an update of the entity with the value already populated?
I'd try moving the field to it's own section, and making the whole section not visible. This is also a good practice because if you add additional fields to the form, the hidden ones will take up space in the form.

Are you using the RTM version of CRM 2011? there is a known bug that has been fixed with rollup 1
You cannot set field visibility to "true" through the Client API when the Visible by Default field is not selected.
maybe your problem is related/connected to this bug
you can read the changelog here:
Update Rollup 1 for Microsoft Dynamics CRM 2011 is available

Related

How to create a NotesRichtext item that is computed for display?

I know this is a common problem, and I tried a few solutions already, but the problem I have right now with my current code is that even though the attachments show in the computed for display field, I get the error "Note Item not Found" when I try to open them.
The form is built with two fields, in a programmable table that displays the editable one or the computed for display one.
The trick I found with Google's help was to delete the computed for display item in the queryopen event, so Notes regenerates the cfd item when opening the document. Visually, this works, as I see the text and attachments, but the attachments can't be opened.
Here is the code that removes the item in the QueryOpen of the form:
...
Set item = doc.GetFirstItem("dspDescription")
If Not item Is Nothing Then Call item.Remove()
...
Has anyone successfully achieved that functionality? Is there another way of doing this? I already tried with subforms, and because of the way the application is built, I need to be able to switch from editable to read only on the flick of a radio button, so subforms are out of the question as they can't be displayed dynamically.
Why don't you simple put the richtext item in a controlled access section and make that section editable / not editable with a computed for display formula. Select "always expand" and hide the section title, so that nobody can collapse it, et voila.
Regarding your comment: With this properties:
for this section in designer:
You get this result:
You see: No twisty, no "visible" section

In crm 2013 the AttributeInfo.GetValue returns wrong value

We are experiencing a strange issue, which can be reproduced by following below steps:
Open New Task (Or any other entity)
Enter text “Test Subject” in “Subject” field (or use any other field).
Use this Xrm.Page.getAttribute("subject").getValue(); statement to
get the value of subject’s field, it will return “Test Subject”.
Now clear the subject field.
Use this Xrm.Page.getAttribute("subject").getValue(); statement to
get the value of subject’s field, it will return “Test Subject”,
which is wrong value, the subject field is empty.
The Xrm.Page.getAttribute("subject").getValue() returns wrong value. We checked this issue in CRM 2011 and its ok the issue is specific to CRM 2013.
EDIT:
This code is fired from Custom Ribbon Button.
We tried to change the focus to another control and then we checked the value, it not works.
EDIT:
This issue occurs only if the field is a required field.
The logic of CRM page is that it changes data inside of the Xrm.Page.data object only if the edited field lost focus (this event tells CRM that the data entry is done), so it could be that after step 4 you don't lose focus to other field. This behavior is the same as in CRM 2011.
I think you have two problems here although they maybe cause by the same thing. This is unfortunately not an answer to these problems but an attempt to clarify the above.
Problem 1: JavaScript reads previous value when an empty value is entered.
I think this is the same as the original problem of this post.
This is also posted at: http://partnersupport.microsoft.com/en-us/mpndynamics/forum/mpndyncrm/javascript-reads-previous-value-when-an-empty/f7b8dffd-3a21-48ae-8dca-4c5467ea8272
On the Competitor form.
Enter “Oliver” in the name field.
Then read it in JavaScript as below.
function ClickHandler()
{
var nameValue = "";
nameValue = locationValue = parent.Xrm.Page.getAttribute("name").getValue();
var test1 = "";
}
You should get “Oliver” as expected.
Then go back to the Competitor form and manually delete the text with the backspace key.
Now read what is in the name field with JavaScript as was done earlier.
You would expect to get nothing but you get “Oliver”.
Now enter Mark in the name field.
Read the field with JavaScript and you get “Mark” as you should.
So it seems when an empty value is entered following a previous value the JavaScript reads the previous value.
To put it a different way. It seems that there is a problem if the Name field had a value and the text then gets manually deleted. The Xrm.Page object will not update to the empty string. The Xrm.Page object will however update to a non-empty value.
Problem 2: Javascript cannot read the value in the text field if the field has not lost focus.
This is also posted at http://partnersupport.microsoft.com/en-us/mpndynamics/forum/mpndyncrm/javascript-cannot-read-the-value-in-the-text-field/ecc2c9e0-fba0-44f2-93cd-320d042896f0?tm=1389885238744
Javascript cannot read the value in the text field if the field has not lost focus.
On the "Recurring Appointment" form I have an IFRAME that runs Javascript. It reads the value in the location field when a button is pressed. If I change the value in the location field to say "Brunswick Street" and press the button I get nothing read (i.e. in the code below locationValue is null).
However if I change the value in the location field to say "Brunswick Street". I then then click away to somewhere on the form other than the IFRAME so the location field has lost its focus (this can also be achieved by pressing enter/tab after entering the text in the location field). If I then press the button on the IFRAME the Javascript will read the text in the location field correctly.
I gather that this is because parent.Xrm.Page is only updated when focus is lost in a field.
function ClickHandler()
{
var locationValue = parent.Xrm.Page.getAttribute("location").getValue();
}
I tried changing the focus in the JavaScript by setting it to requiredattendees field. But this did not work.
parent.Xrm.Page.getControl("requiredattendees").setFocus();
I used to use parent.document.forms[0].namedItem(srcDataFlds[fld]).value; to get the value in CRM 4 and 2011 but this does not work in CRM 2013. So as the SDK suggested I changed the code to use parent.Xrm.Page however it seems to give the problem above.
The questions are why is the focus not lost when I click the button on the IFRAME? If I click on any field in the form the focus changes so why not the IFRAME.
Also how can I get the JavaScript to read the value in the location field without having to click away from the location field. (Hopefully read the value in a supported way)?
I just want the user to be able to enter the value in the location field and click the button in the IFRAME.
I also noticed that when you click the IFRAME the On Change Event is not fired for the location field.
So far the only way round this is to click on another field (or pressing enter/tab) before clicking on the button that fires the Javascript.
Both these problems have been recognized by Microsoft and have been fixed in “Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1”

Hide CRM form left hand side navigation item

I have my account entity linked to a custom entity called inspections, I only want these inspections to be created for accounts of a certain type. So when it isn't that type I want the left hand navigation to this entity to be hidden away. I've seen some code that says will hide it away, as long as you have the navID of the item.
I've had a crack at hiding it using what i thought could be the ID but it hasn't worked, so I'm wondering if anyone knows how to get this ID, or if there is another way to do this?
The code I'm using to hide the navigation is below:
var navitem = Xrm.Page.ui.navigation.items.get("nav_ts_inspection");
if (navitem != null)
{
navitem.setVisible(false);
}
Load the form
Press F12 to show IE Developer's Toolbar
From here you can use CTRL+F to search for the display name of the item you'd like to hide. This will give you a link that is generated. The Id of this element is what you need to use to show/hide the link.
As an example, you can see results of searching for 'Sub Accounts' on the Account screen for an installation I am working on at the moment. The Id can be seen and is 'navSubAct'
Changes by traversing DOM and manually hide an area is not officially supported.
Luckily if you are on CRM 2011, you can go to
Settings > Customization Or open the solution.
Select the entity > Forms. Inside the Form editor window, open the Form Properties of the entity.
Go to Display Tab and untick "Show navigation items" checkbox.
Finally do not forget to Publish your changes.
Use the relationshipname to hide folder in navigation like this:
If you have folder with the relationship name: ts_inspection
Use this for ID: navts_inspection
So otherwise the same as above, but lose the extra underscore (_) between nav and ts.
var navitem = Xrm.Page.ui.navigation.items.get("navts_inspection");
If you want to hide particular navigation section from the FORM then remove all the links from that section and publish it. That section will not be visible anymore.
If you want to just remove Navigation Pane from FORM, then go to 'Display' tab of form and mark as 'Do Not Show' and then publish it.

Custom SharePoint SPUserField does not show up in InfoPath in Browser

I have create a custom field that inherits from SPFieldUser. Everything works fine on the site and the value displays fine in InfoPath as long as I am either in preview mode or select Edit In InfoPath. As soon as I view the form in the browser the field's value no longer displays. Has anyone seen anything like this before?
Thanks,
I might be wrong but that kinda makes sense to me, If editing a publishing page in SharePoint, the owner field for example is metadata on the page and can be filled in edit mode but when in display mode this metadata is not shown unless I explicitly show it. The fields shown in edit mode and display mode are different for pages and I am assuming the same for InfoPath forms.

The WebPart menu doesn't work in SharePoint 2010

I created a WebPart,and it works in SharePoint 2007,I can edit or delete it.But the menu of this WebPart does't work in SharePoint 2010,when I click the menu,it shows nothing.I can't delete or edit it.
The error message is "The value of the property 'UpdateWebPartMenuFocus' is null or undefined, not a Function object",which points to:
UpdateWebPartMenuFocus(this, 'ms-wpselectlinkfocus', 'ms-WPEditTextVisible')
So I want to know the probable reasons for this problem,or any mistake I may have made with my codes.
Thanks!
The method UpdateWebPartMenuainFocus is defined in Core.js.
You need a reference to Core.js, either from your page or from a master page that your page uses.

Resources