Some of the things not working

Aug 2, 2016 at 4:40 PM
Hi,

Just wanted to see if I'm doing something wrong. I'm not a huge JS expert and I need to implement a custom dialog box in CRM (2015 on-prem). Few things I've tried didn't really work for me.

calbackFunction only works when you create the function in-line, but doesn't actually work when the function is defined outside Alert.show call.

setFocus and preventClose parameters are not working at all (changing them doesn't change the alert is rendered) when you define buttons

preventCancel parameter doesn't change anything (actually, Alert.show doesn't even take any parameters after baseUrl)

trying to run Alert.htmlEncode results in error (function isn't defined)

Can someone help with these please?

Regards,
-TS.
Coordinator
Aug 2, 2016 at 7:32 PM
Hey, which CRM version are you using? Also have you installed version 2 of Alert.js, and published customizations? It sounds like you're only seeing version 1, as the features you're missing were recently added in version 2. If you're on CRM 2013 you might need to clear your cache as CRM caches web resources. Let me know if that helps.
Coordinator
Aug 2, 2016 at 7:35 PM
Sorry just saw you're on 2015. Just double check version 2 is installed anyway and publish customizations and clear the cache if it is.
Aug 3, 2016 at 2:27 PM
Hi Paul,

I see it now. I think what happened was...I downloaded and installed version 1 and meanwhile you uploaded version 2 and related documentation. Then I was reading your documentation for version 2 while actually having version 1 :-) Appreciate your help and effort and will try to get all of the functionality working!
Aug 3, 2016 at 5:23 PM
So I imported version 2.0 and it's much better than the 1st one. I tested almost every functionality and everything works as expected with some exceptions.

setFocus: true doesn't always work. I'm yet to figure out in which cases it works and in which cases it doesn't.

Alert.htmlEncode doesn't work for me at all (unless I misunderstand its purpose). I want to inject some html into the message part of the dialog (like bold text, different font size, color and other fancy stuff). Will htmlEncode even do this?

Regards,
-TS.
Marked as answer by Liger on 8/4/2016 at 4:14 AM
Coordinator
Aug 3, 2016 at 8:41 PM
Hi Tony,

Glad to hear you got it working!

I did notice the setFocus not working sometimes as well, but I couldn't see why either, and thought it might have just been my browser or something. Now that I know it's not just me, I'll look into this further.

The HTML Encode method is intended to "display" html content as plain text, e.g. if you want to output an XML error message etc. If you want to actually use formatted html, you can simply pass in the html tags to the message parameter, e.g. "<b>Your message</b>".

Thanks
Paul
Marked as answer by Liger on 8/4/2016 at 4:14 AM
Aug 5, 2016 at 1:33 AM
Hey Paul,

I thought I did try html tags, but I'll give it another shot tomorrow and let you know.

Regards,
-TS.
Aug 5, 2016 at 7:32 PM
Hi Paul,

Happy to report that injecting html tags did indeed work! Thanks for all your help.

Regards,
-TS>
Feb 23 at 7:10 PM
Hey Paul,

Hope you're doing well.

I have a quick question. How do I make your alert box halt the execution and wait for the user to respond? It's just falling through not waiting for a reply, but if I ask a user a question and then build the logic depending on the answer, I want to wait until a button is clicked. So in short, I want to mimic behavior of js CONFIRM function (just make the box look nicer with all the customization alert.js provides). Is that even possible?

Best regards,
-Tony Suslovich.