Wednesday 31 July 2019

Show Hide Control on form in JavaScript on record status Changed dynamic 365

One of our client requirements to show custom entity grid on opportunity form when opportunity is closed as won otherwise hide the grid.
To achieve the requirement, I add the custom entity grid to section on form and register a custom JavaScript function with statuscode field.

JavaScript code of function

function showHidSubGridProjectSectionOnStatusChange ()
{
        var oppStatus = Xrm.Page. getAttribute("statuscode"). getValue();                   
        if (oppStatus == 3) {   //3 is for Won opportunity
            Xrm.Page.ui.tabs.get("Summary"). sections.get("section_subgridProjects"). setVisible(true);                
        } else {
            Xrm.Page.ui.tabs.get("Summary"). sections.get("section_subgridProjects"). setVisible(false);                             
        }
 }



To trigger the JavaScript function, click on close As won button and when click on Ok button the function will called.



I am showing the highlighted section when opportunity status become won otherwise I hide it.



This method works for any entity if you want to trigger JavaScript function on record status change.
Every entity in CRM has OOB field statuscode register JavaScript function with statuscode field.
When record status the JavaScript code will execute.

That’s it for today, I hope it helped you.

Change Display name of Managed Field in Dynamic 365


Sometime we need to change the Display name of Managed field in Dynamic 365.

The following code is used to change the Display name of Managed field.  

IOrganizationService orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;


RetrieveAttributeRequest attributeRequest = new RetrieveAttributeRequest

                {
                    EntityLogicalName = Opportunity.EntityLogicalName,

                    LogicalName = "parentaccountid",

                    RetrieveAsIfPublished = true

                };

                // Execute the request

                RetrieveAttributeResponse attributeResponse =

                   (RetrieveAttributeResponse)orgService.Execute(attributeRequest);

                Console.WriteLine("Retrieved the attribute {0}.",

                   attributeResponse.AttributeMetadata.SchemaName);

                // Modify the retrieved attribute

                AttributeMetadata retrievedAttributeMetadata =

                   attributeResponse.AttributeMetadata;

                retrievedAttributeMetadata.DisplayName =

                   new Label("Bidding To", 1033);

                // Update an attribute retrieved via RetrieveAttributeRequest



                UpdateAttributeRequest updateRequest = new UpdateAttributeRequest

                {

                    Attribute = retrievedAttributeMetadata,
                   

                    EntityName = Opportunity.EntityLogicalName,

                    MergeLabels = false
                   

                };

                // Execute the request

                orgService.Execute(updateRequest);

Numbering Table Parent group and child group ssrs report

 Recently I have faced a scenario to numbering parent group and subgroup in the following formate 10 parentGroupRow1    10.1 childGroupRow1 ...