Solved

CRM Dynamics javascript to autoload date upon resolve case

Posted on 2009-03-10
3,046 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
Question by:biotec
    13 Comments
     
    LVL 9

    Expert Comment

    by:Biffster007
    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
    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
    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
     

    Author Comment

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

    Author Comment

    by:biotec
    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
    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
    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
    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
    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
    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
    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
    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:
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Lean Six Sigma Project Manager Certification

    There are many schools of thought around successful project management, but few as highly regarded as the Six Sigma and Lean methods. With 37 hours of learning, this training will explain concrete processes for increasing efficiency and limiting wasted time and effort.

    In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    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…

    913 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

    17 Experts available now in Live!

    Get 1:1 Help Now