Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all 46379 articles
Browse latest View live

Default lookup view in dynamics account lookup field

$
0
0

Hi all,

I have a sandbox and a live environment of dynamics. 

On the contact form in my sandbox, I can add an account to the contact using the company name field. ("Company name" is the table column and "parentcustomerid" is the schema name of this column) 

The sandbox view gives me the option to look up either "accounts" or "contacts" 

In my live environment which is a copy of my dev sandbox, the same field only shows the users the option of "contacts" but I want the users to add company names and not people really. 

The image here shows our dev sandbox with both the accounts and contacts lookup available:

Does anyone know why the live site wouldn't show the default or how I might fix this?

Many thanks in advance.

Matt


Two Identical Delete Plugins | One works, one doesn't

$
0
0

Hi experts,

 

I have a issue on my delete plugins. I have 2 delete plugins. Both are identical.

  • Delete of ExtraCost
  • Delete of Duration

 

As you can see both are identical. Both having the same pre Image with the ID, TrainingID and Cost/Hours.

Both plugins also have the same code running. Only difference is that Extra Costs will update Remaining Budget and Duration will update Remaining Days.


Here's a code snippet of Extra Costs:

 

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Collections.Generic;
using System.Linq;

namespace TrainingBudget.Plugin
{

    public class DeleteExtraCost : IPlugin
    {
        private static IOrganizationService _service;
        private IOrganizationServiceFactory _serviceFactory;
        private IPluginExecutionContext _context;

        public void Execute(IServiceProvider serviceProvider)

        {
            _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            if (_context.Depth > 1)
            {
                return;
            }

            if (_context.MessageName != "Delete")
            {
                return;
            }
            _serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            _service = _serviceFactory.CreateOrganizationService(_context.UserId);

            UpdateBudgets();
        }
        private void UpdateBudgets()
        { 
                var extraKost = EntityMapper.Map<ExtraKost>(_context.PreEntityImages.FirstOrDefault(q => q.Key == "cref8_extrakost").Value);
                EntityReference extraKostERef = ((EntityReference)_context.PreEntityImages.FirstOrDefault(q => q.Key == "cref8_extrakost").Value.Attributes["cref8_extrakosttraining"]);
                var training = EntityMapper.Map<Training>(_service.Retrieve("cref8_opleiding", extraKostERef.Id, new ColumnSet("cref8_jaarstartopleiding")));

                var cursists = GetCursists("cref8_cursist", "cref8_extrakost_cref8_cursist", "cref8_cursistid", "cref8_extrakostid", training.Id);

                foreach (var cursist in cursists)
                {
                    var traineeBudget = GetTraineeBudget(cursist, training);

                    double nieuwBudget = traineeBudget.RemainingBudget + extraKost.Price;

                    Entity budget = new Entity("cref8_jaarlijkbudget");
                    budget["cref8_jaarlijkbudgetid"] = traineeBudget.Id;
                    budget["cref8_overigebudget"] = nieuwBudget;

                    _service.Update(budget);
                }
        }
        private static List<Cursist> GetCursists(string entityName, string linkToEntityName, string linkAttributeName, string attributeName, Guid id)
        {
            var query = new QueryExpression()
            {
                EntityName = entityName,
                ColumnSet = new ColumnSet("cref8_cursistid")
            };
            var link = query.AddLink(linkToEntityName, linkAttributeName, linkAttributeName);
            link.LinkCriteria = new FilterExpression()
            {
                Conditions =
                                    {
                                        new ConditionExpression(attributeName, ConditionOperator.Equal, id)
                                    }
            };

            return _service.RetrieveMultiple(query).Entities.Select(e => EntityMapper.Map<Cursist>(e)).ToList();
        }
        private static TraineeBudget GetTraineeBudget(Cursist cursist, Training training)
        {
            ConditionExpression ceYearlyBudgetFromTrainee = new ConditionExpression("cref8_cursist", ConditionOperator.Equal, cursist.Id);
            ConditionExpression ceYearlyBudgetYear = new ConditionExpression("cref8_jaar", ConditionOperator.Equal, (int)training.Year);
            FilterExpression filter = new FilterExpression();
            filter.Conditions.Add(ceYearlyBudgetFromTrainee);
            filter.Conditions.Add(ceYearlyBudgetYear);
            QueryExpression qeYearlyBudget = new QueryExpression("cref8_jaarlijkbudget");
            qeYearlyBudget.ColumnSet = new ColumnSet("cref8_jaarlijkbudgetid", "cref8_overigebudget");
            qeYearlyBudget.Criteria.AddFilter(filter);
            EntityCollection yearlyBudgetResult = _service.RetrieveMultiple(qeYearlyBudget);

            return EntityMapper.Map<TraineeBudget>(yearlyBudgetResult.Entities.First());
        }

    }
}

 

Here's code snippet of Duration:

 

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System;
using System.Collections.Generic;
using System.Linq;

namespace TrainingBudget.Plugin
{
    public class DeleteDuration : IPlugin
    {
        private static IOrganizationService _service;
        private IOrganizationServiceFactory _serviceFactory;
        private IPluginExecutionContext _context;

        public void Execute(IServiceProvider serviceProvider)

        {
            _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            if (_context.Depth > 1)
            {
                return;
            }

            if (_context.MessageName != "Delete")
            {
                return;
            }

            _serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            _service = _serviceFactory.CreateOrganizationService(_context.UserId);

            UpdateBudgets();
        }

        private void UpdateBudgets()
        {
            var duration = EntityMapper.Map<Duration>(_context.PreEntityImages.FirstOrDefault(q => q.Key == "cref8_duratie").Value);
            EntityReference duratieERef = ((EntityReference)_context.PreEntityImages.FirstOrDefault(q => q.Key == "cref8_duratie").Value.Attributes["cref8_opleidingduratie"]);
            var training = EntityMapper.Map<Training>(_service.Retrieve("cref8_opleiding", duratieERef.Id, new ColumnSet("cref8_jaarstartopleiding")));

            var cursists = GetCursists("cref8_cursist", "cref8_opleiding_cref8_cursist", "cref8_cursistid", "cref8_opleidingid", training.Id);

            foreach (var cursist in cursists)
            {
                var traineeBudget = GetTraineeBudget(cursist, training);

                double nieuwAantalDagen = traineeBudget.RemainingDays + (duration.Hours / 8);
                Entity budget = new Entity("cref8_jaarlijkbudget");
                budget["cref8_jaarlijkbudgetid"] = traineeBudget.Id;
                budget["cref8_overigedagen"] = nieuwAantalDagen;

                _service.Update(budget);
            }
        }
        private static List<Cursist> GetCursists(string entityName, string linkToEntityName, string linkAttributeName, string attributeName, Guid id)
        {
            var query = new QueryExpression()
            {
                EntityName = entityName,
                ColumnSet = new ColumnSet("cref8_cursistid", "cref8_fullname")
            };
            var link = query.AddLink(linkToEntityName, linkAttributeName, linkAttributeName);
            link.LinkCriteria = new FilterExpression()
            {
                Conditions =
                                    {
                                        new ConditionExpression(attributeName, ConditionOperator.Equal, id)
                                    }
            };

            return _service.RetrieveMultiple(query).Entities.Select(e => EntityMapper.Map<Cursist>(e)).ToList();
        }
        private static TraineeBudget GetTraineeBudget(Cursist cursist, Training training)
        {
            ConditionExpression ceYearlyBudgetFromTrainee = new ConditionExpression("cref8_cursist", ConditionOperator.Equal, cursist.Id);
            ConditionExpression ceYearlyBudgetYear = new ConditionExpression("cref8_jaar", ConditionOperator.Equal, (int)training.Year);
            FilterExpression filter = new FilterExpression();
            filter.Conditions.Add(ceYearlyBudgetFromTrainee);
            filter.Conditions.Add(ceYearlyBudgetYear);
            QueryExpression qeYearlyBudget = new QueryExpression("cref8_jaarlijkbudget");
            qeYearlyBudget.ColumnSet = new ColumnSet("cref8_jaarlijkbudgetid", "cref8_overigedagen");
            qeYearlyBudget.Criteria.AddFilter(filter);
            EntityCollection yearlyBudgetResult = _service.RetrieveMultiple(qeYearlyBudget);

            return EntityMapper.Map<TraineeBudget>(yearlyBudgetResult.Entities.First());
        }

    }
}

 

As you can see both Plugins do the same thing. They get the TraineeBudget of all Trainees and refund the ExtraKost or the Duration.

  • ExtraKost Plugin is firing but no calculations are done (I think Cursists are empty when Plugin code is executing)
  • Duration Plugin is firing and calculations are done correctly.

How can one Plugin work, and basically an identical Plugin does not work?

EDIT:

  • If I put the ExtraKost Delete plugin on Update message for ExtraKostname field for example and I trigger it the plugin works fine.
  • I Tried changing the Plugin to Prevalidation but also the plugin does not do any calculations

 

Best Regards,

Anthony

Create record using excel file from onedrive path in MS flow

$
0
0

Hi,

Is anyone tried to create MS Dynamics record (including all data types) using excel file which is on OneDrive or sharepoint ?

Please share reference links if anyone knows.

We can't find any apps for your role

$
0
0

Hi,

We have few model driven apps in my organization. All these apps are showing only for system admin security roles, for any other security roles we are getting a message as "We can't find any apps for your role. To check for recently-added apps, select Refresh". We have tried with Basic User security for a user, also we made sure that

1. Apps are assigned to Basic User security role

2. Basic User security role has Read access on Model Drive App under customization

3. Also tried by assigning the app to a user

4. Also check that user licenses are not an issue as it is working fine with System Administrator security roles.

Any ideas, suggestions to resolving this issue are most welcome.

Populate a many to many subgrid inside a form using Javascript

$
0
0

Hello I have a a many to many subgrid inside a form 

I want to populate this subgrid with some existing records using javascript

I can't use "Xrm.WebApi.createRecord" and give it the id of the form i want to link it with since it creates new records while I want to use some existing records 

How can I do that please

Masking email fields in UAT instance

$
0
0

Hi,

I have a UAT instance of Dynamics 365 online that I need to mask data in certain entities. I have managed to do bulk updates using Bulk Data Updater in XrmToolBox and made changes to annotation, appointment, task, incident and opportunity. But when I try to change any fields in the email entity it fails. I want to change the subject, description, to and from fields, but it seems not possible.

Is it possible to change these fields or some of them? How can it be done?


Regards
Frode

Using text email in workflow

$
0
0

Hi,

I have created a code activity that returns email address in string format. Now I need to send email to this address using workflow, But in To, I am not getting this email. Screenshot below. 

 Let me know on how to fix this.

Does IOrganizationService.(Dis)Associate not trigger (Dis)Associate plugins?

$
0
0

Hello,

I have two entities, Events and Missions that have a N:N relationship. I registered a plugin (let's call it NewPlugin) to run on both associate and disassociate between these two entities. NewPlugin works just fine when a user manually associates a Mission to an Event via a subgrid, and same when disassociating.

The issue is that we also have OldPlugin that, among other things, can potentially associate several Missions to an Event at once via the IOrganizationService.Associate method. Unfortunately, the associations made via OldPlugin don't appear to trigger NewPlugin at all. I have some tracing in NewPlugin, but I'm not seeing any trace logs being created after OldPlugin runs, which tells me that NewPlugin doesn't get triggered at all.

Is this an instance of Microsoft half-assing their implementation of the (dis)associate messages/plugins, or am I doing something stupid? Would I be better off swapping my plugin to run on an Event's update instead?

Note: we're running version 1612 (9.0.32.3) on-premises if it helps. 


How I can Convert MBOX file to DOC document?

$
0
0

I have an MBOX file and I want to migrate MBOX to DOC document. But, I do not know the process of how can I convert?. If you know about any method so please explain for me. 

Error message appears: Page can't be displayed

$
0
0

When trying to edit columns in Advanced filter error message "Page can't be displayed" appears and "Contact support for additional information". 

As a result, I can not proceed with my tasks. Any ideas what the problem is and how it can be solved? 

Absolute URLs detected during SharePoint upgrade (2016 on-prem)

$
0
0

Hey All, I am currently running 2016 on prem and we are upgrading our sharepoint server from 2007 to SharePoint Online. The documents have been moved, all thats left is to change the integration in CRM to server based.

I have updated every single document location (~1800 of them) from an absolute URL to a relative one. The trouble here is when I open the server based integration wizard I get the absolute URLs detected message. I checked my document locations and filtered for absolute URL contains data and got no results back. There isn't a single document location with an absolute URL left.

I am thinking this is being triggered because the parent sites are absolute URLs but there is no choice here the top level sharepoint sites need to be absolute URLs. I can't remove these without taking out hundreds of child records.

Is anyone able to assist here?

On Change Event does not trigger on the column/field if the column gets set the value by another script

$
0
0

I have the web resources ( HTML + Script 1)  which used for search Addresses in Australia and the retrieved value/chosen value will be autocomplete and set to the fields as below. This web resources was developed by the previous vendor.

Now I build another webresource (Script 2)  and build a function called OnChange_Address1 State/Province which gets trigger on change of the Address 1 State/ Province. It perfectly trigger/fire if I manually go and update the Address 1 State/Province

But If the user search for the address and Script 1 populate the changed value to Address 1: State/Province, The Script 2's function OnChange_Address1 State/Province does not get trigger.

I was able to solve this issue by modifying the Script 1 and add the fireOnChange Method to the attribute. which I do not want to modify anything in Script 1 as it developed by previous Vendor. 

Kindly, If there is any solution to trigger Address1: State /Province column when user search get populate to the field without modifying the Script 1 and add some code in Script 2 ?

Why does the AddExistingAssoc button not appear after the dynamic CRM subgrid control writes the addLoad event?

$
0
0

I want to listen subgrid can only add one data, after I use addOnLoad, the AddExistingAssoc button is hidden, but I don't want it to be hidden, I am confused for a long time why the AddExistingAssoc button is hidden,There is no clear answer.I need your help. Thank you

This is my code:

function onLoad() {
var _rowCount = Xrm.Page.getControl("subgrid").getGrid().getTotalRecordCount();
Xrm.Page.getControl("subgrid").addOnLoad(onGridLoad);
}

steps:

1. A sub-grid is a many-to-many situation

2. The ribbon shields other new buttons. Only AddExistingAssoc buttons are open

3. No JS control button

4. The addOnLoad button is still blocked

Image:

How to convert Entity Image Byte Data to Base 64 Workflow MSCRM

CRM 2016 On Prem to SharePoint Online Integration Failing During Verification

$
0
0

Hey All, I am currently running 2016 on prem and we are upgrading our sharepoint server from 2007 to SharePoint Online. The documents have been moved, all thats left is to change the integration in CRM to server based.

I am following the instructions in this document: https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/admin/on-prem-server-based-sharepoint-online?view=op-9-1

I am currently at the stage where I am running through the integration wizard. When I run the integration wizard I get to the stage where the sites are verified. Unfortunately I get this error at this stage:

<errorlog><sites><site><url>https://mycompany.sharepoint.com/Sales</url><exception>The underlying connection was closed: An unexpected error occurred on a send.Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.</exception></site></sites></errorlog>


Other sources I have found talking about this issue point to the TLS version being used as a problem. On the Dynamics CRM server I have TLS1.0, 1.1, and 1.2 enabled, 1.2 is set up as the default for .NET. I cannot disable 1.0 and 1.1 completely without breaking CRM all together. I have verified that CRM is using TLS 1.2 to connect to sharepoint with a wireshark capture as shown here:

Does anyone know what else might be the issue?


Portal Entity List Show/Hide Custom Button Using Java Script on column value

$
0
0

I am adding a custom button to an Entity List

I want to hide/show the button depending on a specific column value of each row.

The red below code works on the ID of the row = ????, but I need to replace the data-id with a whole number column called [Count] so that if this [Count] column is 0 it wont display the button, anything above it will

$(document).ready(function () {

$(".entitylist.entity-grid").on("loaded", function () {

$(this).children(".view-grid").find("tr[data-id]").each(function (i, e){
var id = $(this).attr("data-id");

if ($(this).attr("data-id") == "996b793b-f675-ec11-8943-00224807089a"){
$(this).append("<td><input type='button' style='background-color:lightgreen' onclick='callPowerAutomateInPerson(\"" + id + "\");' value='Attend The Gym' /></td>");
}
});
});
});

Ribbon Workbench Woes

$
0
0

I have a smart button "Run Webhook".  It works great and it runs on the Home Main Tab (the first option).  If I select one or many records on the grid it loops through them and works on all records.  I used a webhook as it is calling a power automate flow.

My issue is, I want to limit the access to this button to a security role, or on the view name.  Either would work.

I have been going through everything I can find, I cannot seem to get anything to work.

I think it is because it has to run on the Home Main Tab(the first option).

Or maybe because it is a smart button. 

Does anyone have a sample or a link that works.

I am using Dynamics 365 online.

Using a client side JSON field in a serverside plugin.

$
0
0

Hello,

I'm trying to solve the following problem: I want to implement the new in-app notification functionality in one of our systems. Microsoft shows a large number of examples on how this can be solved on the client side using Javascript:

Send in-app notifications within model-driven apps (preview)

My implementation requires server-side execution using C#, which I haven't had much experience with yet. I was able to implement and successfully test the following logic:

void CreateNotification(PluginContext context, Guid userId, EntityReference EntityRef)
        {
            var referenceName = EntityRef.LogicalName;
            var referenceId = EntityRef.Id;

            var notification = new Entity("appnotification");
            notification["title"] = "New access.";
            notification["body"] = $"You have received new access rights to FirstLetterToUpper(referenceName)}";

            notification["icontype"] = new OptionSetValue(100000004);
            notification["toasttype"] = new OptionSetValue(200000000);
            notification["ttlinseconds"] = 120;

            // data (button with title and url
            var url = "?pagetype=entitylist&etn=" + referenceId + " & viewid=" + referenceId + "& viewType=1039";
            // I assume the JSON should be here?

            notification["ownerid"] = new EntityReference("systemuser", userId); 

            context.OrganizationService.Create(notification);
        }

My notification is shown to the correct system-user as expected.

I would now like to extend my code so that the user is also shown a button that leads him to the post. Microsoft published an example on how to do this using Javascript in their documentation: 

Notification with one action

A JSON String is used to show the title of the button and the url that should be opened when the button is clicked: 

"data": JSON.stringify({"actions": [
	  {"title": "View cases","data": {"url": "?pagetype=entitylist&etn=incident&viewid=00000000-0000-0000-00aa-000010001028&viewType=1039"
		}		
	  }
	 ]
	})

I haven't worked with JSON before. Is there a "replacement" for JSON in C#? I've seen examples using JSON.Stringify, but my attempts to implement it just threw errors.

So before I try my luck any further, I would like to ask for help as to whether such a functionality can be implemented at all with C# on the server side. Or whether it is necessary to write a script for such a notification and to trigger it on the server side.

I'm grateful for any advice!

Overwriting a modifiedon date when status changed

$
0
0

Hi,

I have a requirement, where after updating the status of the record from open to complete, modified on date should be same as before the status update . We tried it using the plugin at the pre Operation stage and registered Pre-image to get the modified on date before status update. The date we got from preimage has been set to the modifiedon date to the target entity form the plugin context.

modified on date is not updating with the modified on date that obtained from the preimage, where it is updating with the current date&time when status is updated. When I debugged the code it's showing that preimage modifiedon date is getting passed to the "activity["modifiedon"]".we have checked with the other plugin if any plugin is getting triggered after status updated, there are no plugins or other activities are getting triggered or updating the entity as we checked in the audit history. In audit history it's showing status update information and no other field is getting updated after status update.

Overwriting modifiedon date is working and reflecting for other fields update except status update.

Can one help me regarding this issue, why overriding modifiedon on status change is not working?

Hide a Command bar button

$
0
0

Hello members,

I am trying to hide the command bar of a custom entity I managed to Hide all the buttons using ribbon workbench but unfortunately I cannot hide those two buttons

is there anyway I can hide them or Hide the command bar entirely

Viewing all 46379 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>