Saturday, July 4, 2009

Hide buttons in menu bar

Hi,
Here is an example how to hide buttons in crm menu bar

function FideButton(buttonName){
var list = document.all.tags('SPAN');
for (var i = 0; i < list.length; i++) {
if (list[i].className.indexOf('ms-crm-Menu-Label') >= 0)
if ((list[i].title == buttonName || list[i].innerText == buttonName))
list[i].style.display = 'none';
}
}

Enjoy,
Rami Heleg.

Friday, June 26, 2009

Get Field value

Here is an example to get field value in microsoft crm

function GetFieldValue(name) {
var element = document.getElementById(name);
return element == null ? null : element.DataValue;
}
Enjoy,
Rami Heleg

Get Field value

here is an example to get field value for microsoft CRM

Picklist - get title for value

Hi friends,
how to get picklist value,title

here example to create picklist title for specific value.

function GetPicklistTitle(name, value) {
if (value != '') {
var element = document.getElementById(name);
return element == null ? null : element.options[value].text;
}
return "";
}
enjoy
Rami Heleg.

Wednesday, June 24, 2009

Rename Organization name

Hi,
To rename organization name for CRM 4.0...
1. Open database MSCRM_CONFIG, table Organization.
2. This table contains information for all organization.
3. Rename columns UniqueName, FriendlyName to the new organization name.
3. Open ORG_MSCRM database table OrganizationBase.
4. Add to column name the new organization name.

Enjoy,
Rami Heleg.

Thursday, May 7, 2009

Return column label from plugin

this function used to return label for field.
can be used for plugin,audit etc...

public static string GetColumnLabel(IPluginExecutionContext context, string entityTypeName, string columnName)
{
IMetadataService metadataService = context.CreateMetadataService(false);
Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeRequest request = new Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeRequest();
request.EntityLogicalName = entityTypeName;
request.LogicalName = columnName.ToLower();
Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeResponse response = (Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeResponse)metadataService.Execute(request);
AttributeMetadata am = response.AttributeMetadata;
if (am != null)
return am.DisplayName.UserLocLabel.Label;
return "";
}

Enjoy,
Rami Heleg

Retrieve Entity field value

This function used to return field value inside plugin,

public static object GetEntityFieldValue(IPluginExecutionContext context,string entityName, Guid instanceId,string fieldName){
ICrmService pservice = context.CreateCrmService(false);
TargetRetrieveDynamic targetRetrieve = new TargetRetrieveDynamic();
targetRetrieve.EntityName = entityName;
targetRetrieve.EntityId = instanceId;
RetrieveRequest retrieve = new RetrieveRequest();
retrieve.Target = targetRetrieve;
retrieve.ColumnSet = new AllColumns();
retrieve.ReturnDynamicEntities = true;
RetrieveResponse retrieved = (RetrieveResponse)pservice.Execute(retrieve);
DynamicEntity entity = (DynamicEntity)retrieved.BusinessEntity;
return entity.Properties[fieldName];
}

Enjoy,
Rami Heleg