Mention height and width in Percentage instead of Pixels – Modal Popups in Dynamics 365 CE – NavigateTo

Hi Everyone,

Today a bug was created by the user saying the popup window is too small and we were using below code to show the HTML Webresource as a popup.

var pageInput = { pageType: "webresource", webresourceName: "WebResourceName" };
        var navigationOptions = {
            target: 2,
            width: 400,
            height: 300,
            position: 1
        };
        Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
            function success() {
                // Handle dialog closed
            },
            function error() {
                // Handle errors
            }
        );

When we have checked the code was working fine and able to see the window normally. After some checks with the users came to know that User has 19 inches monitor and that has opened doors to fix the issue. We all know that we have to use percentage instead of pixels for height and width and here is the way to use the same in NavigationOptions of NavigateTo function.

Here is the modified code of the same.

var pageInput = { pageType: "webresource", webresourceName: "WebResourceName" };
        var navigationOptions = {
            target: 2,
            //width: 400,
            //height: 300,
            width: { value: 90, unit: "%" },
            height: { value: 90, unit: "%" },
            position: 1
        };
        Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
            function success() {
                // Handle dialog closed
            },
            function error() {
                // Handle errors
            }
        );

Hope this helps.


Happy 365’ing
Gopinath

Create Email record in Dynamics 365 CE using JavaScript

Hi Everyone,

I know this could be very simple as we are doing this from ages but somehow I couldn’t get this piece of code very easily.

Code for creating email record using JavaScript in Dynamics 365 Customer Engagement. Important thing here to understand more on Activity Party Participation Type Mast. Go through Microsoft Docs for more information on the same.

var activityParties = []
    var Sender = {};
    var Receipent = {};

    var userId = "21EFAD11-353B-4238-93BB-65015F448E8A";

    // From - Participation Type Mask = 1
    Sender["partyid_systemuser@odata.bind"] = "/systemusers(" + userId + ")";
    Sender["participationtypemask"] = 1;
    activityParties.push(Sender);

    // To - Participation Type Mask = 1
    Receipent["partyid_systemuser@odata.bind"] = "/systemusers(" + userId + ")";
    Receipent["participationtypemask"] = 2;
    activityParties.push(Receipent);

    var createEmailRequest = {
        "description": "This email is created using JavaScript Code",
        "regardingobjectid_account@odata.bind": "/accounts(bec28e1e-ab87-ea11-a817-000d3a19245f)",
        "subject": "Email using JavaScript",
        "email_activity_parties": activityParties
    }

    Xrm.WebApi.createRecord('email', createEmailRequest).then(
        function success(Email) {
            console.log("Email has been created");
        },
        function Error(e) {
            console.log(e.message);
        }
    )

Hope this helps.


Happy 365’ing
Gopinath