Dynamics CRM MessageBox - dynamics-crm

I have some JavaScript in Dynamics that does some work and needs to prompt the user with a Yes/No question.
I'd like to have the popup themed like the rest of Dynamics. Is there any page I can use with window.ShowModalDialog or some part of the API to provide a standard looking Dynamics message box?
Thanks.

there isn't a built-in feature to prompt the user in Dynamics CRM using javascript, however, you could build one the use the OpenDialog function to prompt it like Dynamics CRM does using one of these JS functions
Xrm.Utility.openDialog //2016
Xrm.Internal.openDialog //2015 - 2013
Hope it helps

No, CRM doesn't have any function like that built in. You'll have to create your own page.

Maybe you can use a managed solution here https://alertjs.codeplex.com/

The latest Javascript API has the following method, its simple and amazing.
var confirmStrings = { text:"This is a confirmation.",cancelButtonLabel:"No", title:"Confirmation Dialog" };
var confirmOptions = { height: 200, width: 450 };
Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
function (success) {
if (success.confirmed)
console.log("Dialog closed using OK button.");
else
console.log("Dialog closed using Cancel button or X.");
});

Maybe you can use "dialogs" and trigger that to open by using a javascript?

You can use the dialog template found in the SDK to create a dialog with CRM 4.0 look and feel:
(SDK Path)\visualstudiotemplates\cs\addonwebpage

Hope that the below code snippet would be helpful
protected void doBatch()
{
if (Box::yesNo("Vent radioactive gas?", DialogButton::No) == DialogButton::Yes)
{
super();
}
}

Related

dynamics 365 change default from field in email

I'm looking to change the default from user when an email is created. Setting it through a workflow doesn't work, and business rules does not allow to set the default from behavior. Has anyone been able to do this successfully?
I found this answer by stringing together a few different answers. Note: I couldn't find any documentation on official Microsoft Dynamics functionality, so although it worked for me on version 8 of Dynamics 365 (cloud) it could stop working in the future.
I created a javascript file that ran on load. If the form had form state, create, then I would use the following script to change the value:
function _setFromUser() {
var legalQueueID = "00000000-0000-0000-0000-000000000000";
var recordName = "Legal Contracts Queue";
var entityName = "queue";
Xrm.Page.getControl("from").getAttribute().setValue([{ id: legalQueueID, name: recordName, entityType: entityName }]);
}
Hope this helps someone else!

Dynamics 365 Get Guid Button

Does anyone know of a managed solution to import into Dynamics 365 that adds functionality for a custom button to copy the Guid of any entity to your clipboard?
In a previous environment we used this one
Of course this can't be imported into the newer Dynamics 365.
I know how to parse out the Guid from the URL, but the button to autocopy it to the clipboard was amazing.
The Chrome Extension Level Up has button for Record Id, or you can use the bookmarklet code. Just add the below code to a bookmark in your browser:
//get record id
javascript: (function () { var form = $("iframe").filter(function () { return $(this).css("visibility") == "visible" })[0].contentWindow; window.prompt("Copy to clipboard: Ctrl+C, Enter", form.Xrm.Page.data.entity.getId().slice(1, -1)) })();
Try Level Up for Dynamics 365 Chrome Extension, it provides a great variaty of common JScript actions and shortcuts to help with extensibility, diagnostics and administration
if what you need is to pulish an option to your user to get the GUID of a record and prevent the execution of other JS logic such as display all hidden attributes, then you will have to create a ribbon button and execute JS logic contained in a webresource, to make it compatible with CRM v9 and forward, past the execution context to your function (PrimaryControl) and call the native Xrm function executionContext.getFormContext().data.entity.getId()
Another extremely useful Chrome called Dynamics Power Pane. Use it together with Level Up for Dynamics 365 will be very powerful.

CRM: What is the difference between update Plugin and Update in XrmServiceToolkit

Is there any difference between updating an entity using a Plugin vs Updating an entity using XrmServiceToolkit?
var entityA= new XrmServiceToolkit.Soap.BusinessEntity("entA", id);
entityA.attributes["attrA"] = { value: attrValue1, type: "OptionSetValue" };
entityA.attributes["attrB"] = { value: attrValue2, type: "Money" };
XrmServiceToolkit.Soap.Update(entityA);
I know plugin can be used to connect to external databases but for a very basic update, is there any difference?
Thank you!
Operations in plugins are seemless integrated with the business logic of your CRM platform. Plugins are invoked in any scenario, regardless if they are triggered by a webpage (Javascript calls, e.g. using XrmServiceToolkit), workflow, external systems, integration tools or even other plugins.
An update done on your web page by Javascript only works on that form. If you only need it there, it's fine. If you need to cover other scenarios as well, you may have to look for another solution.

MSCRM Addcustom filter

I am using MS CRM 2013 and created a custom filter on ownerid. It works ok but just that it returns both team and user. I just want to have user. If I provide the entityname as below:
Xrm.Page.getControl("ownerid")
.addCustomFilter(thisfetch, "systemuser");
Then it filters on user and returns filtered users and all teams.
How can I fix it?
thisfetch is my filter criteria.
Please help.
Instructing the Lookup dialog to only allow SystemUser is currently not supported.
There are unsupported workarounds but as pointed out in the linked article they can easily break due to changes in the DOM.
plain js
function setToFieldFilter()
{
document.getElementById("to_i").setAttribute("lookuptypenames", "systemuser:8:User");
document.getElementById("to_i").setAttribute("lookuptypes", "8");
}
function onLoad()
{
Xrm.Page.getControl("ownerid").addPreSearch(setToFieldFilter);
}
jquery
$("#to_i").attr("lookuptypenames", "systemuser:8:User");
$("#to_i").attr("lookuptypes", "8");
Sources
CRM 2013 : Change default entity for a Lookup field
Filter PartyList entities Lookup using Jscript in Microsoft Dynamics CRM 2011

Add-on sdk : Message passing from contentscript to panel

How can I emit an event from content script to panel add-on script and vice versa? And how can I dynamically update the panel content. Please help. An example in this regard will be greatly helpful for beginners. The basic example given here is not working the example is:
var panel = require("panel").Panel({
contentScript: "self.port.emit('showing', 'panel is showing');"
});
panel.port.on("showing", function(text) {
console.log(text);
});
panel.show();
Nothing is shown in console
This example is given in Add-on SDK tutorial but still it is not working. Any one please Help?
That example works for me. I see the panel and I see the console.log messages.

Resources