Change the name when Customizing CRM 2011 - dynamics-crm-2011

I customize the campaign form and i face the some problem
1.How to customize the name "GENERAL".i need the name instead of GENERAL .Where to change?or which property should i change?
2.cant delete Lock symbol fields if we try , its saying "It is allowed only for business units".How to unlock and How to delete this?

As Guido suggests, double you can edit the name of the tab by opening up the form in the form editor, double clicking on the tab, and changing the label.
As far as the locked field, you'll have to mark the field as not required, in the entity customization, publish your changes, then you can delete the field from the form.

The label for any tab can be changed by the form editor, if you want a dynamic value you can set using supported customization as this example:
var firstTab = Xrm.Page.ui.tabs.get(0);
firstTab.setLabel("new tab name");
If a field is locked, it means that is business required (in your case is the name of the campaign that must be filled), you can always hide the field and pre-fill the value using javascript code inside onload, onchange or onsave events.

Perhaps someone else can suggest a better (i.e. supported) solution but until then - why not find out the id of those elements and edit them directly from JS in onload? Let me repeat, though, that such an operation is unsupported.

Related

Read only appears like disable control in CRM

I am new to CRM, and I have run into a requirement where I have to show some controls (textbox, option set, etc) and custom entities (sub - grid) as readonly. But, when I made them readonly, they appears like disabled and are getting grayed out. Is there any way to make them only read only not look like disabled?
Please suggest.
Thanks,
Ashfaq.
in CRM read-only means fields are greyed out but still they are readable.
If you want to make the fields visible as normal but don't want them to be editable by the user, you need to write JavaScipt for that.
Take the following steps.
1. Make the fields editable.
2. On form's OnSave Event, call the following method to prevent the attributes to be saved.
function PreventSave()
{
Xrm.Page.getAttribute(“CRMFieldName”).setSubmitMode(“never”);
}
It will not grey out the fields and still prevent the user to change their values.
I hope it will help you.
For text fields, there is one type of text field that when set to readonly does not look like it is disabled. Off the top of my head I can't remember which type. For the other field types I have not found a way to not have them look disabled when made readonly.
Other option is not to use form fields but show the data you need to be readonly (and not grayed out) in a web resource (HTML/SL/etc). Be aware tho that if your users are using outlook with crm addin, there are limitations here when the record is viewed in the outlook reading pane.
Only other option I can think of is to not set the fields as readonly but control any field data changes with javascript.
In short, I haven't found a good way to do what you need.

Defaulting parent entity of custom activity

This should be a simple thing, but as I am quickly finding out with CRM 2011, simple things almost never are...
Anyway, I have a custom activity type, a "Trip". A Trip represents a single visit by a service technician to a client's site. Trips are always created in connection with a Case (Incident) and never with any other entity type, so the entity exists as a custom activity that does not "Display In Activity Menus". That allows me to drop a subgrid of Trips into the primary Case view, making it the only place these things can be created.
The problem is that when I try to create a new Trip from the Case form (by clicking the subgrid and choosing "Add New Trip" from the ribbon), the "Regarding" field isn't populated with the Case that I was on when I clicked "Add". Any of the "built-in" activity types will default their corresponding field with no problem, so it would seem to me that I can do the same here. The field's supposed to be read-only once this defaulting works, but just so I can set up the reference when creating new Trips, I've made it editable, and of course when you pop up the lookup, you can assign this Trip to anything (which is why I want the field read-only in the first place).
I need the form to default the parent Case when the Trip form loads. It has to be there when it's first created, because if it isn't there on the first save, then some plugin code that sets other default values (namely data relating to other Trips that may or may not exist for the same Case) won't work properly.
I read about relationship field mapping, where you can default the values of various fields based on fields of the parent entity, but the relationship between the Incident and my Trip is not listed as mappable from either side and I can't figure out how to make it mappable. I also know it's possible to set default values using JavaScript, but if there's a less "custom" way to set this particular behavior up I would love to know how.
As an epitaph based on Mike's comment, it does indeed seem that Microsoft doesn't want this done. But, it's still possible to do it. The basic steps are:
Download the Ribbon Workbench solution and import it into CRM.
Create a new solution containing the entity or entities you want to be able to customize.
Create a JavaScript file containing functions that will open the form you want and pass the information you need as a parameter. There are two ways to specify the parameters; you can define custom parameters on the form, or you can use Microsoft's undocumented parameters for the Regarding field:
function OpenNewTripFromCase()
{
var entityId = Xrm.Page.data.entity.getId();
var entityTypeCode= Xrm.Page.context.getQueryStringParameters().etc;
var entityDisplayName = Xrm.Page.getAttribute("title").getValue();
var params = {};
params["pId"] = entityId;
params["pType"] = entityTypeCode;
params["pName"] = entityDisplayName;
Xrm.Utility.openEntityForm("cst_trip", null, params);
}
Import this JavaScript file as a Web Resource, and add it to the Solution so it will be available to Ribbon Workbench.
Open up Ribbon Workbench and open the solution you created with your entity and resources. Click the Solution Elements tab, and find the "Commands" item. Right-click and select "Add New". Now expand the list, find and click on your new command. In the Properties pane, change the name of the command to be more descriptive (it's recommended you only change the third "Command#" term), then click the magnifying glass button to the right of the Actions field.
In the window that pops up, click "Add", then choose "JavaScript Function Action". A new item will be added to the action list. Click it, then in the properties pane to the right, find the library containing your function, then type in the function name. I didn't get any sort of IntelliSense here, so be careful typing in the function name. Add parameters if you need to (you shouldn't need to with the code above), then click OK
Now click the custom activity entity in the Entities list of Ribbon Workbench, then in the dropdown to the upper right of the ribbon layout, select the SubGrid ribbon. Create a button in this Ribbon, give it the icon and text you want, and in the Properties pane, set the Command to the command you just created.
Publish the customized Solution, and you should, if you did everything correctly, have a new button that will do the same thing as the "Add New" button when you've selected a sub-grid, but will additionally populate the Regarding field.

Remove note's autosave functionality by adding other entity's notes on form in CRM 2011

In CRM 2011, notes get automatically created and attached to main record on lost focus event. Requirement is to remove this auto save functionality. Only till main form is open user should be able to edit notes. And newly added notes should only get saved once main form is saved. For example, if user add one note and closes the browser or do not save the main form, then that note should not get attached to main record, new note should get discarded.
I was thinking following solution:
create new custom entity TempNotesHolder
Create 1:N relationship with the entity where we want this functionality, for example Case entity
Make actual case's note section read only(it is requirement, user don't want to edit/delete functionality for notes once note get created)
Write plugin for create event of Case and create one Record for TempNotesHolder and associate it with case(RegardingId field in TempNotesHolder = incidentId) This will ensure one Case will always have only one associated TempNotesHolder record. There is no way in CRM 2011 to ensure One entity record will have only one record in associated entity i.e. 1:1 relationship. At least I don't know the way. Let me know if any one are aware about it.
On Case form, add one IFrame below Case's note section
on case form load event, get TempNotesHolderId associated with case using fetchXml.(There is no actual field in Case entity that refer to associated TempNotesHolder, hence need to use fetchXml. Some how we can add associated TempNotesHolderId to Case entity, and place that field on Case form, make it hidden, to avoid fetchXml)
Prepare url to display only notes of TempNotesHolder record.(/_controls/notes/notesdata.aspx?EnableInlineEdit=false&EnableInsert=true&id=&ParentEntity=
Set this url to newly added IFrame, so notes of associated TempNotesHolder get displayed in IFrame. It will also have link "Add New Note".
User can add note to TempNotesHolder which are not directly added to Case record.
Next develop plugin on pre save event of Case and check if there are any notes added to TempNoteHolder, if yes move those notes to Case record, and delete notes for TempNoteHolderId. This way notes will get saved to main record only on main form save.
To handle browser close event after adding few notes to TempNotesHolder, write plugin on Case pre Retrieve event, check if any notes present for associated TempNotesHolderId, if present then delete those notes. (As notes are present on TempNotesHolderId, that means due to some reason these notes are not moved to actual case record and we no longer need them, so delete them. This will ensure on case load, TempNotesHolder note section always be blank)
The above solution was fine till step 8. When I tried to add notes in TempNotesHolder, it gave me error, "Record with does not exists in TempNotesHolder". Then I checked that GUID, I disappointed to know CRM is taking IncidentId when I create note for TempNotesHolder. Then I tracked down the actual code for create notes to find why it is taking IncidentId instead of TempNotesHolderId. I found following code in "_static/_controls/notes/notes.htc" function name "UpdateNote"
xml="0"+CrmEncodeDecode.CrmXmlEncode(value)+""+_parentCrmFormSubmit.crmFormSubmitId.value+""+this.parentEntityType+""+CrmEncodeDecode.CrmXmlEncode(currentTitle)+""+this.userId+""
CRM is taking _parentCrmFormSubmit.crmFormSubmitId.value as objectid while creating note.
Now I stuck with this problem. Any thoughts to overcome this show stopper issue are appreciated. Also any other alternate solution to main requirement are also welcome.
Pravin Pujari (Microsoft Dynamics CRM 2011 Developer)
I would suggest simplifying the solution as follows:
Add a field to Case called new_notetext.
Create a Plugin against the Pre-Create and Pre-Update messages on the Case entity.
In the plugin, take anything entered into new_notetext and add a note to the Case entity using that text. Then clear the field new_notetext so nothing is saved with the record.
Should work just fine and is much simpler to implement.

SharePoint 2010 - How to make a field Read-Only AFTER it loads

I have a field that contains a number that is "system generated" when I open the Newform1.aspx form (I made this the default new item form). If I make the "Requisition Number" field read only, it doesn't allow the system to write to it with the new number. I would like the system to be able to write the new number to the field "as the form loads" and then make the field Read-Only after the number is generated and written to the field. Is there a way to make this happen? When I just changed the ControlMode to "Display" it makes the field read only, but displays the Requisition Number from the first item in the list.
Not sure how exactly you are adding this field.
If you have added the field using code or manifest, you can set field.ShowInEditForm = false;
If you are adding it using UI directly then there is no easy way to update ShowInEditForm property but there is one codeplex project which can help u
http://www.greggalipeau.com/2008/03/10/column-permissions-in-sharepoint-list/
tx,Sandeep
Are you using an event handler? You can use ItemAdding to update the field then set it to read only after the field is added.

SharePoint 2010 - Customizing the rendering and behavior of a List field

In my SharePoint List, I have an "Employee" column that is a User type field. I would like to add some custom Business Logic to the processing of this field.
Currently, when the user adds a row, I check to see if the user is an Employee or a Manager and then change the behavior on this column accordingly. I do this by statically rendering the field in my custom "ListForm Rendering Template", just before my custom ListFieldIterator. I simply use a standard SharePoint FormField (and FormLabel) control. In the markup of the FormField control, I specify the FieldName (Employee) and an event handler for the Load event. In this Load event, I will check to see if the current user is an Employee or Manager (using two different SharePoint groups). If the user is an Employee I set the value of the field to the current user (this part works perfectly). I also want to change the field so it can't be modified. I thought I might be able to just change the ControlMode on the field (in the code of the OnLoad Event Handler) to Display, but for some reason this has no effect. The field still renders with the full, people picker editor. Am I not changing the fields control mode soon enough? Or is this simply not the correct approach? The other logic I want to put in is if the user is a Manager, I would like to allow that user to select the person from a list (SharePoint group) of Employees. It may be easier to just use the people picker and limit the selectable users to that group. (I think I can do this with the SelectionGroup property.) Although, it would be better if I could just provide a dropdownlist of users, which I could possibly do with a hidden dropdownlist that I would show and event handlers that I could use (handle event selectedindexchanged) to pull the value selected and populate the (now hidden) Employee (user) field. Does this approach make sense? Assuming all that will work, the real difficulty I am having is with changing the ControlMode (rendering) on the field (when the user is an employee) to a label or some kind of read only control, which is how that field renders when viewing the row, which is why I think if I can just trick the control into thinking it is in Display mode then it should work perfectly!
I am still learning SharePoint, but I am very proficient in ASP .Net. This is why I would like to keep my customizations in this Custom Rendering Template, using code behind and leverage my existing skill set as much as properly.
Any thoughts, opinions or advice? Does anyone know why I can't get the column to switch the "Control Mode"?
I do not think that I fully understand your scenario. Some code samples could help.
But anyway it sounds like you want some heavy customizations of the user field. In that case you might want to have a look at creating a custom field with all its advantages and disadvantages. Have a look at MSDN: http://msdn.microsoft.com/en-us/library/gg132914.aspx
Another option might be - in case you do not want to re-use this column in many list definitions - that you can get away with your custom rendering template and create a custom create/edit form where you implement the specific edit behaviour for the field (plain ASP.NET with some SharePoint controls). Here is a nice walk-through on how to grab a custom edit form from SharePoint designer: http://community.bamboosolutions.com/blogs/sharepoint-2010/archive/2011/05/12/sharepoint-2010-cookbook-how-to-create-a-customized-list-edit-form-for-development-in-visual-studio-2010.aspx
I hope this helps. Kr., Bernd.

Resources