Dynamics 365





Wednesday, June 1, 2022

google maps Overlapping Marker Spiderfier

 <!doctype html>

<html>
<head>
    <meta charset="utf-8">
    <title>MarkerClusterer v3 Simple Example</title>
    <style>
        body {
            margin: 0;
            padding: 10px 20px 20px;
            font-family: Arial;
            font-size: 16px;
        }

        #map-container {
            padding: 6px;
            border-width: 1px;
            border-style: solid;
            border-color: #ccc #ccc #999 #ccc;
            -webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
            -moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
            box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px;
            width: 600px;
        }

        #map {
            width: 600px;
            height: 400px;
        }
    </style>

    <script src="https://maps.googleapis.com/maps/api/js"></script>
    <script src="data.json"></script>
    <!-- <script type="text/javascript" src="../src/markerclusterer.js"></script> -->
    <script type="text/javascript" src="../src/jquery.min.js"></script>
    <script type="text/javascript" src="../src/jquery-ui.js"></script>
    <script type="text/javascript" src="../src/oms.min.js"></script>


    <script>
        //function initialize() {
        //  var center = new google.maps.LatLng(37.4419, -122.1419);

        //  var map = new google.maps.Map(document.getElementById('map'), {
        //    zoom: 3,
        //    center: center,
        //    mapTypeId: google.maps.MapTypeId.ROADMAP
        //  });

        //  var markers = [];
        //  for (var i = 0; i < 100; i++) {
        //    var dataPhoto = data.photos[i];
        //    var latLng = new google.maps.LatLng(dataPhoto.latitude,
        //        dataPhoto.longitude);
        //    var marker = new google.maps.Marker({
        //      position: latLng
        //    });
        //    markers.push(marker);
        //  }
        //  var markerCluster = new MarkerClusterer(map, markers, {imagePath: '../images/m'});
        //}

        function initialize() {


            const image_building = {
                url: "../images/ico_building.png",
                size: new google.maps.Size(37, 50),
                origin: new google.maps.Point(0, 0),
                anchor: new google.maps.Point(0, 50),
            };

            var center = new google.maps.LatLng(23.4241, 55.8478);

            var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 7,
                center: center,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });
           


            $.ajax({
                url: 'https://aaa.dsc.com' + '/api/api/Maps/bind/auh',
                "method": "GET",
                "headers": {
                    "conte": "application/json",
                    "cache-control": "no-cache",

                }
                , success: function (response) {
                    debugger
                    lstMaps = response;
                    var markers = [];
                    var infowindow = [];
                    const sightingIcon = {
                    path: "M 0 0 L 4 -4 L 4 -16 L 26 -16 L 26 -34 L -26 -34 L -26 -16 L -4 -16 L -4 -4 Z",
                    fillOpacity:1,
                    fillColor:"#ffcc00",
                    strokeWeight:1,
                    strokeColor:"#000",
                    scale:1,
                    labelOrigin: {x:0, y:-25}
                };
                //var bounds = new google.maps.LatLngBounds();
                var oms = new OverlappingMarkerSpiderfier(map,
                        {markersWontMove: true,
                        markersWontHide: true,
                        basicFormatEvents: true,
                        nudgeRadius: 20,
                        nearbyDistance: 40,
                        circleSpiralSwitchover: 8,
                        spiralFootSeparation:20,
                        spiralLengthStart: 16,
                        spiralLengthFactor: 12,
                        circleFootSeparation:50,
                        circleStartAngle: 180});
                    for (let i = 0; i < lstMaps.length; i++) {
                        //debugger
                        //alert(lstmaps.length);
                      //  const locationItem = locationsArray[i];

                        let mapIcon = image_building.url;

                        let latt = 0;
                        let long = 0;

                        if (response[i].Attributes[2] != null && response[i].Attributes[2] != undefined && response[i].Attributes[3] != null && response[i].Attributes[3] != undefined) {
                            latt = parseFloat(response[i].Attributes[3].Value.Value);
                            long = parseFloat(response[i].Attributes[2].Value.Value)
                        }
                        // console.log(mapIcon);
                       /*  markers[i] = new google.maps.Marker({
                            position: {
                                lat: latt,
                                lng: long
                            },
                            map,
                            icon: mapIcon,
                            // shape: shape,
                            title: response[i].Attributes[0].Value,
                            //zIndex: locationItem[3],
                        }); */
 
                        //start
                       // bounds.extend(response[i]);
                        var markerData = response[i];
                        var marker = new google.maps.Marker({position:{lat:latt,lng:long}, title: response[i].Attributes[0].Value, label: response[i].code, opacity: 1, icon: image_building.url});
                        markers.push(marker);
                        marker.addListener('spider_click', function(e) {});
                        oms.addMarker(marker);

                        //end

                    }
                   // var markerCluster = new MarkerClusterer(map, markers, { maxZoom: 19, imagePath: '../images/m' });
                    var markerCluster = new MarkerClusterer(map, markers,{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m',maxZoom:18});
                   // var iw = new google.maps.InfoWindow()
                   // map.fitBounds(bounds);

                },
                error: function (jqXHR, exception) {
                    var msg = '';
                    if (jqXHR.status === 0) {
                        msg = 'Not connect.\n Verify Network.';
                    } else if (jqXHR.status == 404) {
                        msg = 'Requested page not found. [404]';
                    } else if (jqXHR.status == 500) {
                        msg = 'Internal Server Error [500].';
                    } else if (exception === 'parsererror') {
                        msg = 'Requested JSON parse failed.';
                    } else if (exception === 'timeout') {
                        msg = 'Time out error.';
                    } else if (exception === 'abort') {
                        msg = 'Ajax request aborted.';
                    } else {
                        msg = 'Uncaught Error.\n' + jqXHR.responseText;
                    }
                    alert(msg);
                }

            });

        }
         google.maps.event.addDomListener(window, 'load', initialize);
         
       
       
    </script>
    <script>
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-12846745-20']);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();



    </script>
     

     <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/OverlappingMarkerSpiderfier/1.0.3/oms.min.js"></script> -->
</head>
  <body>
    <h3>A simple example of MarkerClusterer (100 markers)</h3>
    <div id="map-container"><div id="map"></div></div>
  </body>
</html>

Thursday, April 22, 2021

dynamics 365 filter sub grid lookup on add - D365 Onpremise lookup filter on subgrid using Java script


Dynamics 365 filter sub grid lookup on add - D365 On-premise lookup filter on subgrid using Java script






///////////////////////////
// START

// JScript source code

function setSubgridLookupFiltering() {
    var subgridAddButtonId = "Requirements_addImageButton";

    //Try to get the element from both the current and the parent document.
    var subgridAddButton = document.getElementById(subgridAddButtonId) || window.parent.document.getElementById(subgridAddButtonId);

    //This script may run before the subgrid has been fully loaded on the form. If this is the case,
    //delay and retry until the subgrid has been loaded.
    if (subgridAddButton == null) {
        setTimeout(setSubgridLookupFiltering, 2000);
        return;
    }

    //Local function to retrieve the lookup control and apply the filter. We will queue this function in the click event handler of the
    //Add button's click event.
    var getSubgridLookupAndAddFilter = function () {
        debugger;
        var subgridLookup = Xrm.Page.getControl("lookup_Requirements");

        //Delay and retry until we can locate the lookup.
        if (subgridLookup == null) {
            setTimeout(getSubgridLookupAndAddFilter, 200);
            return;
        }

        //This is a custom property we are tagging on to the lookup control to ensure that we will
        //apply the custom filter only once when the Add button is first clicked.
        if (subgridLookup.customFilterAdded) {
            return;
        }

        subgridLookup.addPreSearch(function () {
            debugger;
            //Standard logic to build up the filter query string
            var filterQuery = "";
            // var Property = Xrm.Page.getAttribute("").getValue();
            var lookupfield = new Array;
            lookupfield = Xrm.Page.getAttribute("msdyn_account").getValue();//lookup name which lookup values need to be filters where sub grid is placed
            if (lookupfield != null) {
                var lookupid = lookupfield[0].id;
            }

            filterQuery = "<filter  type='and'><condition attribute='has_property' operator='eq' value='" + lookupid + "'/></filter>";


            //Standard call to add filter to the lookup control
            subgridLookup.addCustomFilter(filterQuery, "has_pointmapping");//subgrid entity schema name
        });

        //Mark the fact that we have already added the filter so that we won't do it again the next time the user clicks the Add button.
        subgridLookup.customFilterAdded = true;
    };

    //Attach the function to retrieve the lookup and apply the filter to the Add button's click event. Remember that we
    //can only get the lookup after the user has clicked the Add button.
    subgridAddButton.addEventListener("click", function () {
        debugger;
        setTimeout(getSubgridLookupAndAddFilter, 200);
    });
}

//END

/////////////////////////

Sunday, December 13, 2020

Dynamics 365 Power Map change icons color

 

Dynamics 365 Power Map change icons color



Click on Map Pointer icon which will show multiple icon where you can choose from List if icons.
and save the Current Legend as map again.





Here is the updated map with new icon







Thursday, November 12, 2020

MB 901 Microsoft Dynamics 365 Fundamentals MB-901 certification

Which three unique user experiences are offered by Dynamics 365 Fraud Protection? Each
correct answer presents a complete solution.
A. Diagnose
B. Protect
C. Feedback
D. Evaluate
E. Analyze
F. Assign
Answer: A,B,D

Thursday, July 23, 2020

Dynamics 365 - condition to check owner is team or user while send email

In dynamics 365 while sending emails on assigning Case or any other entity record  Required to send an email to user. here We may assign case to team initially and then to user manually . CRM may not send email to team . It can send email to user., so in work flow we need to check for the whether owner is team or user .

we can check using below condition as shown in below figure.




Saturday, March 14, 2020

Multiple SLAs in Dynamics 365 for Work Order entity

Multiple SLAs in Dynamics 365 for Work Order Entity

This post will explain how to create multiple SLAs with SLA items

Requirment: Need to have 2 SLAs with different time lines and different conditions.

Solution: we can create 2 SLAs and only once can make default(only default SLA will effect on entity) , But we can acheieve this by adding two lookup fields to SLA KPI Instance entity.

Enitity: Work Order


ATE       SLA 1       SLA 2
CAT 1 2 Working days    3 Working days
CAT 2 2 Working days   4 Working days
CAT 3 2 Working days   5 Working days
CAT 4 2 Working days   8 Working days
CAT 5 2 Working days  14 Working days


Here we enable SLA on work order entity as shown below

Screenshot of Enable SLA on Work Order

and create 2 Look up fields to SLA KPI Instance entity

new Lookup 1 on work order entity for SLA1 (name it SLA1 for better understanding )



















new Lookup field on work order entity for SLA2 (name it SLA2 for better understanding )





















Now add SLA in ( Settings ==> Service Management ==> Service Level Aggrements)



















On Applicable From  select on which Date field you need to apply SLA .


















Now add SLA Items for SLA
for SLA 1 work order category : any category(CAT1,2,3,4,5) , Fail: 2 working days
Applicable on first assignment date contains data and category of any type(so not choosing any category)

SLA KPI is SLA1 we created previousely as SLA KPI Instance.

Add SLA Failure condition and Warning  Condition.



SLA 2:
Add SLA 2 item for  category 1 - failire time is 3 days
















failure is 3 days means 9 hours X 3 which means 27 Hours (1.13 days)

If we set for 27 hours ,it will calculate set to 1.13 days automatically as below













Now test this.



Tuesday, January 7, 2020

Reading data from Microsoft Excel sheet using C#.net code

<script data-ad-client="ca-pub-7202621014932746" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

Below code will help you to reading data rows from excel sheet and fetch data from CRM .

Reading data from Microsoft Excel sheet using C#.net code 

sample excel data


//Name space need to use
using Excel = Microsoft.Office.Interop.Excel;

public void ReadInvoiceFromExcelAndUpdate()
        {
            Excel.Application xlApp = new Excel.Application();
            Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@"C:\MyData\Sample.xlsx");
            try
            {
                AppLogger logger = new AppLogger();
                Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets[1];
                Excel.Range xlRange = (Excel.Range)xlWorksheet.UsedRange;
                int rowCount = xlRange.Rows.Count;
                int colCount = xlRange.Columns.Count;
// Excel rows count will start form 1 , not from zero (0) ,  1 will be header
                for (int i = 2; i <= rowCount; i++)
                {
                    logger.LogInfo(i.ToString());


                    string invoieID = ((Excel.Range)xlWorksheet.Cells[i, 1]).Value;
                    if (invoieID != null)
                    {
                        UpdateInvoiceFromExcel(invoieID);
                    }
                }

            }
            catch (Exception ex)
            {
                string err = ex.Message;
            }
            finally
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();


                xlWorkbook.Close();


                //quit and release
                xlApp.Quit();
            }

        }

//Fetch invoice data from CRM
public void UpdateInvoiceFromExcel(string invoiceID)
        {


            try
            {
                QueryExpression qe = new QueryExpression("invoice")
                {
                    ColumnSet = new ColumnSet("name", "statuscode", "statecode"),

                };

                qe.Criteria.AddCondition("invoicenumber", ConditionOperator.Equal, invoiceID);

                var result = _CrmService.RetrieveMultiple(qe);
                if (result.Entities != null && result.Entities.Count > 0)
                {
                    //result.Entities[0];

                    int invoiceStatusValue = result.Entities[0].GetAttributeValue<OptionSetValue>("statuscode").Value;
                    int invoiceStateValue = result.Entities[0].GetAttributeValue<OptionSetValue>("statecode").Value;
                    Guid _invoiceID = result.Entities[0].Id;
                    if (invoiceStatusValue == 100001 && invoiceStateValue == 2)
                    {
                        SetStateRequest request = new SetStateRequest()
                        {
                            EntityMoniker = new EntityReference
                            {
                                Id = _invoiceID,
                                LogicalName = "invoice",
                            },
                            State = new OptionSetValue(0),
                            Status = new OptionSetValue(1),
                        };

                        _CrmService.Execute(request);

                        // end set invoice active
                        //

                        //
                        Entity invoiceToUpdate = new Entity("invoice");
                        invoiceToUpdate.Id = result.Entities[0].Id;

                        invoiceToUpdate["new_issend"] = true; //has_issend //new_issend
                        _CrmService.Update(invoiceToUpdate);
                        //

                        // set back invoice status

                        SetStateRequest invocieRequest = new SetStateRequest()
                        {
                            EntityMoniker = new EntityReference
                            {
                                Id = _invoiceID,
                                LogicalName = "invoice",
                            },
                            State = new OptionSetValue(invoiceStateValue), // State = new OptionSetValue(2),
                            Status = new OptionSetValue(invoiceStatusValue), //Status = new OptionSetValue(100001),
                        };

                        _CrmService.Execute(invocieRequest);

                    }
                    else
                    {
                        Entity invoiceToUpdate = new Entity("invoice");
                        invoiceToUpdate.Id = _invoiceID;

                        invoiceToUpdate["new_issend"] = true;
                        _CrmService.Update(invoiceToUpdate);

                    }
                }
            }
            catch (Exception ex)
            {

                // log.Error(ex);
                //throw;
            }
        }