Wednesday 22 May 2019

Retrieve Local Option set metadata in java script using webapi, Dynamic 365

   function GetOptionSetOptionValue(optionText, optionSetLogicalName)
{
        debugger;
        var req = new XMLHttpRequest();
        req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/EntityDefinitions(LogicalName='ab_bid')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$filter=LogicalName eq '" + optionSetLogicalName + "' &$expand=OptionSet", false);
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
        req.send(null);
        if (req.readyState === 4) {
            req.onreadystatechange = null;
            if (req.status === 200) {
                var results = JSON.parse(req.response);
                debugger;
                for (var i = 0; i < results.value[0].OptionSet.Options.length; i++) {
                    debugger;
                    var Label = results.value[0].OptionSet.Options[i].Label.UserLocalizedLabel.Label;
                    if (Label.trim().toLowerCase() == optionText.trim().toLowerCase()) {
                        return results.value[0].OptionSet.Options[i].Value;
                    }
                    //alert(Label);
                }
            } else {
                Xrm.Utility.alertDialog(req.statusText);
            }
        }
    }

Thursday 16 May 2019

Retrieve note from opportunity and associate with custom entity note in C#



private void RetrieveRelatedNoteFromOppAndAttachWithBid(IOrganizationService orgService, Guid oppId, Guid bidId)
        {
            try
            {
                string fetchxml = @"<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
                                    <entity name='annotation'>
                                    <attribute name='subject'/>
                                    <attribute name='notetext'/>
                                    <attribute name='filename'/>
                                    <attribute name='annotationid'/>
                                    <attribute name='isdocument'/>
                                    <attribute name='filesize'/>
                                    <attribute name='mimetype' />
                                    <attribute name='documentbody'/>
                                    <order descending='true' attribute='createdon'/>
                                    <filter type='and'>
                                       <condition attribute='objectid' operator='eq' value='" + oppId + @"'/>
                                    </filter>
                                    </entity>
                                    </fetch>";
                EntityCollection results = orgService.RetrieveMultiple(new FetchExpression(fetchxml));
                if (results.Entities.Count > 0)
                {
                    Entity noteOpp = results.Entities[0];
                    Entity noteBid = new Entity("annotation");
                    noteBid["objectid"] = new EntityReference("ab_bid", bidId);
                    noteBid["objecttypecode"] = "ab_bid";
                    noteBid["subject"] = noteOpp["subject"];
                    noteBid["documentbody"] = noteOpp["documentbody"];
                    noteBid["mimetype"] = noteOpp["mimetype"];
                    noteBid["filename"] = noteOpp["filename"];

                    orgService.Create(noteBid);
                    orgService.Delete(noteOpp.LogicalName, noteOpp.Id);
                }
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
            }
        }

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 ...