CRM 2015 Scripting on Form Fields

I am trying to figure out how to set up a script to run when someone attempts to enter information into the subject line of an email. We have a mail security appliance that sends encrypted messages and one of the ways to bypass this is by adding a special tag at the end of the subject. For example

This is a subject - TAG

I had modified some of the scripts in our CRM 2011 environment but we recently deployed a CRM 2015 environment and none of the old scripts seem to be working. I am wondering if anyone could help me get this to work?

I went to Settings > Customizations > Customize the System > Web Resources

From here I went to New and crated a resource of type Script (JScript) named New_Email_Form_Library (it appended New not sure why, I don't see an existing one). I browsed out to my .js file and uploaded it. I then published all customizations.

Here is a screenshot of the properties of this solution.

 Picture of Web Resource "New_Email_Form_Library"
So I then went over to the Entites > Email > Forms section went to the Email Form and then selected the Subject field and went to the Events tab and added the library and then set up the event handler as I would have in CRM 2011.
Events tab of Field Props
So then I use the large + in the ribbon to create an email and when I attempt to input anything into the subject nothing happens. I added a test function which simply runs "alert" and that does not function either. Any ideas?

Below is my Javascript.
function subject_onchange()
{
// Get the field that fired the event.
var oField = Xrm.Page.getAttribute("subject"); // get subject attribute

// Validate the field information. 
if (oField.getValue() != null && oField.getValue() != undefined && oField.getValue() != "");
{
	var x = confirm("I confirm that there is not BLAHBLAH in this email");
	if (x == true);
	{
	oField = oField + " - TAG";
	}
}
}
function test_onchange()
{
alert("test");
}

Open in new window

aflukeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Feridun KadirPrincipal ConsultantCommented:
Everything you've done looks correct.

One thing to check, which form shows when you create an email? Is it email or wizard?
0
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
Hi,

You need to remove brackets "()" from the function call. You just have to pass the function name.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Feridun KadirPrincipal ConsultantCommented:
Well spotted!
0
aflukeAuthor Commented:
Yes thank you very much!

That was in fact the problem, removing the parens worked like a charm. Thank you all for your time!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Dynamics

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.