Wednesday, September 28, 2011

How to retrieve the optionset text and value in CRM 2011

var selectedOptionSet = Xrm.Page.getAttribute("fieldname");

var textVal= (selectedOptionSet.getSelectedOption().text);
var val=(selectedOptionSet.getSelectedOption().value);

Tuesday, September 20, 2011

CRM 2011 - Moniker

To Map Many To Many Relation Ship Use Moniker Like This in Crm 2011
User EntityReference instead of Moniker
-------------------------------------------------------------------

Microsoft.Xrm.Sdk.EntityReference Moniker1 = new Microsoft.Xrm.Sdk.EntityReference { Id = new Guid ( contactID ), Name = "contact" };
Microsoft.Xrm.Sdk.EntityReference Moniker2 = new Microsoft.Xrm.Sdk.EntityReference { Id = new Guid ( id ), Name = "fia_newsletter" };


string strManyToManyRelationshipName = "fia_contact_fia_newsletter";


isSuccess = newsLetterBO.AssociateManyToManyEntityRecords ( Moniker1, Moniker2, strManyToManyRelationshipName );


--------------------------------------------------------------------------------

public bool AssociateManyToManyEntityRecords ( EntityReference moniker1, EntityReference moniker2, string strEntityRelationshipName )
{
try
{
// Create an AssociateEntities request.
AssociateEntitiesRequest request = new AssociateEntitiesRequest ( );


// Set the ID of Moniker1 to the ID of the lead.
request.Moniker1 = new EntityReference { Id = moniker1.Id, LogicalName = moniker1.Name };


// Set the ID of Moniker2 to the ID of the contact.
request.Moniker2 = new EntityReference { Id = moniker2.Id, LogicalName = moniker2.Name };


// Set the relationship name to associate on.
request.RelationshipName = strEntityRelationshipName;


// Execute the request.
this.Service.Execute ( request );


return true;
}


catch ( SoapException ex )
{
return false;
}

}

-----------------------------------------------------------------
This is solution for the error
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Crm.Sdk, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Thursday, September 15, 2011

CRM 2011 - Retrieve Entity Metadata C#

// Get the name of the entity
// Note: We have to convert this to lower because RetrieveEntityMetadata expects the schema name
string entityName ="contact";

// Get the metadata for the currently list's entity
// This metadata is used to create a "Property Descriptor Collection"
RetrieveEntityRequest mdRequest = new RetrieveEntityRequest ( )
{ EntityFilters = EntityFilters.All,
LogicalName = entityName,
RetrieveAsIfPublished = false
};


// Execute the request
RetrieveEntityResponse entityResponse = ( RetrieveEntityResponse ) this.ServiceProxy.Execute ( mdRequest );

EntityMetadata entityData = entityResponse.EntityMetadata;




//To Get Option Set Data
var preferdList= ( entityData.Attributes.Where ( p => p.LogicalName == "preferredcontactmethodcode" ) ).ToList ( ).FirstOrDefault ( ); ;

if ( preferdList != null ) {

PicklistAttributeMetadata optionList= preferdList as PicklistAttributeMetadata;
OptionSetMetadata opValues= optionList.OptionSet;
foreach ( var op in opValues.Options ) {

preferedMethod.Add ( new OptionSet { Value = op.Value.Value, Text = op.Label.LocalizedLabels[0].Label.ToString() } );
}

}

Monday, September 12, 2011

ssrs 2005 multi value parameters allow null values

Create dataset and map with parameter and set multi value.
Like
Select UserId, UserName from user


Then create other data set same feild names and Set as a Default data set
like -------------
Select '11111111-1111-1111-1111-111111111111' as UserId, '' as UserName

Validate your sql.....

IF (@User ='11111111-1111-1111-1111-111111111111' )
.....

Now it works fine :)

Thursday, September 8, 2011

Blank page at end in PDF -SQL 2005 Reporting Services

To Resolve This
Add page margins to zero:
topmargin = 0, rightmargin = 0, leftmargin = 0 and bottommargin = 0
In the Report