Hi everyone
I've been asked if I can implement some sort of pop-up window that will contain important warning information (e.g. "DO NOT SPEAK TO THIS CONTACT!!") if someone opens a certain contact record in CRM.
Has anyone successfully done this? If so, could you please offer me some tips / a solution?
I'm guessing that the text would need to be stored in a specific field on the Contact Entity which would then be displayed in the pop-up box, but only if the text field contained data of course.
Any help would be much appreciated.
Many thanks
Jon
Hi Leco Lv
Thank you SO much for your help with this. The revised Javascript completely fulfilled my requirements.
Best wishes
Jon
Hi partner,
Don't worry. there are only two places that need to be modified.
function Alert(executionContext) { const formContext = executionContext.getFormContext(); let cr429_alert= formContext.getAttribute("cr429_alert").getValue(); if(cr429_alert != null) { var alertStrings = { confirmButtonLabel: "Yes", text: cr429_alert, title: "!!!!!!" }; var alertOptions = { height: 120, width: 260 }; Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then( function (success) { console.log("Alert dialog closed"); }, function (error) { console.log(error.message); } ); } }
Hi Leco Lv
I'm now back from my holidays and have tested the Javascript that you sent me (thank you!).
The process seems to work OK, but I just have a couple of queries please:
1. I need to show whatever text is put into the alert field, so it could say anything and not just "DO NOT SPEAK TO THIS CONTACT". What do I need to change in the script in order to achieve this? I assume that I need to change the if(new_alert== part of the script.
2. The line below this also mentions this text string, so what do I need to do in order to change that too?
Many thanks once again,
Jon
Hi Leco Lv
Thank you so much for sending this to me. I'm just about to fly away on holiday for a week, so I'll try this when I get back.
Many thanks once again.
Jon
Hi partner,
Here's the details:
function Alert(executionContext) { const formContext = executionContext.getFormContext(); let cr429_alert= formContext.getAttribute("cr429_alert").getValue(); if(cr429_alert == "DO NOT SPEAK TO THIS CONTACT") { var alertStrings = { confirmButtonLabel: "Yes", text: "DO NOT SPEAK TO THIS CONTACT!!!.", title: "!!!!!!" }; var alertOptions = { height: 120, width: 260 }; Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then( function (success) { console.log("Alert dialog closed"); }, function (error) { console.log(error.message); } ); } }
Hi Leco Lv
Many thanks for your reply.
Here is what I'm trying to achieve:
- not all contact / organisation records will need an alert box to pop up when the record is opened
- for those that do, I would like an alert box to to pop up each time the record is opened by any user
- I will create a new text field on the Contact Entity called Warning
- in the Warning field I will put any text that is required in the pop up (for example. DO NOT SPEAK TO THIS PERSON!)
- so, if text exists in the Warning field then the Contact / Organisation record should have a pop up alert box showing the contents of the Warning field
- conversely, if the Warning field is blank then the Contact / Organisation record should not have a pop up alert box showing
Many thanks
Jon
Hi partner,
Could you tell me what the specific conditions are, what conditions need to be met by the contact will be typed into the fields?
There is enough information to work it out however you will just need to add this to the code:
var warning = formContext.getAttribute("new_warning").getValue();
if(warning != null)
{
// Do the alert here..
}
Hi there Leco Lv
Thanks so much for your reply.
This seems as though it will definitely work, but I'm not sure how to show the content of a specific field instead of the text "DO NOT SPEAK TO THIS CONTACT!!".
What I need to do is the following:
- have a field on the Contact Entity / Contact Form called "Warning" in which I can type a string of text (e.g. "PLEASE BE CAREFUL" or "DO NOT SPEAK TO THIS CONTACT" etc.
- most Contacts will have no text in this box as most Contacts do not require a warning to be shown on-load
- the alert box should therefore only show on-load of the Contact if there is text in the "Warning" field
Do you know if this is possible?
Many thanks
Jon
Hi partner,
Both partners above are right. you can add an onload event to the contact table. here's the details:
Refer link: How to add JavaScript to form on load in Dynamics 365 - Fredrik Engseth
My example:
Save&Publish
My codes:
var alertStrings = { confirmButtonLabel: "Yes", text: "DO NOT SPEAK TO THIS CONTACT!!!", title: "Sample title" }; var alertOptions = { height: 120, width: 260 }; Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then( function (success) { console.log("Alert dialog closed"); }, function (error) { console.log(error.message); } );
result:
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156