Solved

CRM Dynamics javascript to autoload date upon resolve case

Posted on 2009-03-10
13
3,060 Views
Last Modified: 2012-06-27
I have a field called new_enddate that is not a required field but does need to be populated if someone forgets to put a date in once the case is completed or resolved. How would I do this in javascript. Thanks
0
Comment
Question by:biotec
  • 7
  • 4
  • 2
13 Comments
 
LVL 9

Expert Comment

by:Biffster007
ID: 23852879
Hi,

You can't achieve this using javascript as you can't tell whether the case is being resolved from any of the available events.  You can achieve what you want either using a plugin or workflow.  You'll find everything you need to know in this article.

http://www.experts-exchange.com/Microsoft/Applications/Microsoft_Dynamics/Q_24176730.html

Cheers,
MH
0
 
LVL 10

Expert Comment

by:crm_info
ID: 23853004
You also havea some other options:
(1) use JavaScript to hide the resolve case button until the new_enddate is set.
(2) Use workflow to set the new_enddate (if it is still blank) after the case status is set to resolved.
0
 

Author Comment

by:biotec
ID: 23859780
I'm getting field is read only error but the end_date field is not read only. I also have a quesion about reactivating the case and what happens to the date that was entered?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:biotec
ID: 23859879
Actually it says the object is read only.
0
 

Author Comment

by:biotec
ID: 23860197
Is there a way to throw an alert pop up if the case is trying to be resolved and no End Date is put in?
0
 
LVL 9

Expert Comment

by:Biffster007
ID: 23861627
Hi,

What exactly are you trying to do when you are getting the error that says the field is readonly??

MH
0
 

Author Comment

by:biotec
ID: 23863698
It's not generating the error when I'm on the Case. It  shows the error on the workflow in the system jobs. I get  a bunch of waiting statuses for workflow and none of them work. I think it would be easiest to just throw an alert if someone tries to resolve a case without the End Date. Any ideas for that?
0
 
LVL 10

Expert Comment

by:crm_info
ID: 23864186
When a case is resolved, the entire record is set to read only. It's a major problem with cases that was introduced with CRM 4.0 (3.0 did not have the same "feature").  Some possible workarounds:
(1) In your workflow, you can re-activate the case (change status to active), change the enddate, and the re-resolve the case.  Problem with this is that CRM will then have two "Case Resolution" records (these are activity types).  If you're not using case resolutions to bill your hours, or for other reporting purposes, then this isn't a problem.  If you are, then using this first appraoch, you'll need to delete the first resolution -- I don't have a clever way that you can do that off the top of my head.
(2) I think there is probably a way that you can get your desired outcome using a workflow - but it's tricky.  You can probably hook into the resolve case button click event and set the enddate to required.  Most likely this is not "supported" - but I believe it can be done.
(3) You could probably (I'm not sure on this one) write a .NET plugin that fires when the resolve case event is fired, but before the status is set to resolved.
(4) Here's an idea that may be the most workable:
* Create a custom field called "Resolve Case" - make it a bit field
* When the user checks the box, use javascript to change the enddate to required.  
* Setup a workflow that fires when the case is saved - check to see of "resolve case" is checked - if it is, then use the workflow to resolve the case automatically
* If you can get the above to work, you can then hide the Resolve Case button on the case form (tricky, but it can be done with JavaScript I think).
0
 

Author Comment

by:biotec
ID: 23869242
Thanks but that is quite a bit of work. I think it would be much simpler to just be able to set up an alert that if they click on resolve and the End Date is blank an alert pops up or something like that. Is that doable?
0
 

Author Comment

by:biotec
ID: 23869353
I actually need quite a few pop up alerts such as if a field needs to be whole number only how would you pop up an alert to say that you've entered a decimal or just to say whole numbers only etc.
0
 
LVL 10

Expert Comment

by:crm_info
ID: 23872996
Unfortunately, what you are trying to do is simply not an easy thing to do in Microsoft CRM.  In essence, you would like to trigger an event when a user clicks a button (i.e. Resolve Case) BEFORE CRM does what it would normally do (i.e. open the Resolve Case dialog box).  There may be some tricky way to do this using JavaScript, but I am not sure of how to do it and I am certain that it would not be supported.
Attach this JavaScript to the OnChange event of your EndDate field:
if (crmForm.all.new_enddate.DataValue != null)
      resolve();
What that will do is to open the case resolution form automatically when the enddate field is filled in by the user.  If that works, then you can use some separate JavaScript to hide the Resolve Case button from the user, so the only way the user can resolve the case is to enter an enddate - at which point the case will automatically be resolved.
There are a number of other variations on this concept that you can use, depending on what specific user experience you are after - the above was the simplest solution I could think of.
----
For your second question, alerts, you can use JavaScript like this (in the OnChange event behind the field in question):
if (crmForm.all.{your field name}.DataValue >= 100)
     alert("You can only enter values of less than 100 into this field");
You'll need to change the if statement to reflect the value that you're testing for.
0
 

Author Comment

by:biotec
ID: 23883761
Thanks. How would I just hide the Resolve Case button if the End Date was not filled in? Also what I wanted to do was to do an alert if a filedtype was not a whole number, is there anyway to do that?  
0
 
LVL 10

Accepted Solution

by:
crm_info earned 500 total points
ID: 23887568
You can setup a field to be a whole number only using the Attributes settings in CRM - just set it to be an Integer and that will allow only whole numbers to be entered for that field.
Hiding the button is a separate question.  If you get the first part of this to work, then close out the question and ask another regarding hiding the button and I'll answer.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Automatically creating a Trello card using data from a Microsoft Dynamics CRM record turned out to be an easy project that yielded great results.  Here's how I did this for an internal team at General Code.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now