Friday, 18 October 2019

How to retrieve Attribute Display Name in Dynamics CRM using C#

How to retrieve Attribute Display Name in Dynamics CRM using C#



To retrieve the Label name of attributes which can give you the label of attribute if you pass it the schema name of entity, schema name of attribute and Iorganisation service object.
Class to include: 
“using Microsoft.Xrm.Sdk.Messages;”


public static string RetrieveAttributeDisplayName(string EntitySchemaName, string AttributeSchemaName, IOrganizationService service)
        {

            RetrieveAttributeRequest retrieveAttributeRequest = new RetrieveAttributeRequest
            {
                EntityLogicalName = EntitySchemaName,
                LogicalName = AttributeSchemaName,
                RetrieveAsIfPublished = true
            };
            RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
            AttributeMetadata retrievedAttributeMetadata = (AttributeMetadata)retrieveAttributeResponse.AttributeMetadata;

            return retrievedAttributeMetadata.DisplayName.UserLocalizedLabel.Label;
        }







Wednesday, 2 October 2019

User does not have send-as privilege to send Emails in MSCRM

User does not have send-as privilege to send Emails



User need to check "Allow other Microsoft Dynamics 365 users to sent email on your behalf " option from user's personal option.


Personal settings  >> Email tab >> "Allow other Microsoft Dynamics 365 users to send email on your behalf "







Tuesday, 1 October 2019

Get OptionSet Text and Value using Javascript for CRM 2011/2013/2015/2016/D365

Get OptionSet Text and Value using Javascript


For MSCRM 2011/2013/2015/2016 & D365(Deprecated) -


//Get OptionSet Text
Xrm.Page.getAttribute("fieldSchemaName").getText();



//Get OptionSet Value
Xrm.Page.getAttribute("fieldSchemaName").getValue();


For D365 - 
As you probably know, the Xrm.Page command usage is slowly becoming obsolete.
The execution context is an optional parameter that can be passed to a JavaScript library function through an event handler. Use the Pass execution context as first parameter option in the Handler Properties dialog while specify the name of the function to pass the event execution context. 
The execution context is the first parameter passed to a function as below screenshot - 







Example -
function testFn(executionContext) {
var formContext = executionContext.getFormContext();
// Get OptionSet Text
formContext.getAttribute("fieldSchemaName").getText();
// Get OptionSet Value
formContext.getAttribute("fieldSchemaName").getValue();
}