CRM Dynamics javascript to autoload date upon resolve case

    Question by:
    On

    Topics:

    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
    Good Question?
    0
     

    ?

    The member who asked this question verified this comment provided the solution that solved their problem.

    Accepted Solution on 2009-03-14 at 09:31:05ID: 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.

    verified

    answer

    Enjoy your free answer!

    Join now to get more tech resources.

    Become a member

    Comments

     
    Biffster007

    Expert Comment

    2009-03-10 at 17:09:17ID: 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
    Good Comment?
    0
     
    crm_info

    Expert Comment

    2009-03-10 at 17:37:46ID: 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.
    Good Comment?
    0
     
    biotec

    Author Comment

    2009-03-11 at 10:22:58ID: 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?
    Good Comment?
    0
     
    biotec

    Author Comment

    2009-03-11 at 10:29:49ID: 23859879
    Actually it says the object is read only.
    Good Comment?
    0
     
    biotec

    Author Comment

    2009-03-11 at 10:58:29ID: 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?
    Good Comment?
    0
     
    Biffster007

    Expert Comment

    2009-03-11 at 12:55:22ID: 23861627
    Hi,

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

    MH
    Good Comment?
    0
     
    biotec

    Author Comment

    2009-03-11 at 17:20:32ID: 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?
    Good Comment?
    0
     
    crm_info

    Expert Comment

    2009-03-11 at 19:11:36ID: 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).
    Good Comment?
    0
     
    biotec

    Author Comment

    2009-03-12 at 08:11:06ID: 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?
    Good Comment?
    0
     
    biotec

    Author Comment

    2009-03-12 at 08:18:32ID: 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.
    Good Comment?
    0
     
    crm_info

    Expert Comment

    2009-03-12 at 13:17:16ID: 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.
    Good Comment?
    0
     
    biotec

    Author Comment

    2009-03-13 at 14:31:48ID: 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?  
    Good Comment?
    0
      

    Accepted Solution

    2009-03-14 at 09:31:05ID: 23887568Best
    crm_info earned 500 total points
    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.
    Good Solution?
    0

    Featured Post

     Java Android Coding Bundle

    Whether you're an Apple user or Android addict, learning to code for the Android platform is an extremely valuable, in-demand skill. It all starts with Java, the language behind the apps and games that make Android the top platform it is today.

    Ask Your Tech Question. Get Expert Solutions.We will email you as soon as we have your answer.

    We will never share this with anyone.

    Select topics

    You may select up to five topics.

    Top Expert Contributor

    Essential articles and videos from the Experts

    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
    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…

    More valuable questions with Expert answers

    Question: Here's the code I'm working on: (CODE) As it stands right now, it's throwing an error saying "Cannot read property 'claims' of null" In an effort to do some troubleshooting, I tried to enter a comment and got this error: "Invalid or...

    Answer: I don't see any JSON or JAVA here at all. But there is jQuery and javascript. My first question is why are you attempting to express your function instead of declaring it?(CODE) Secondly, there are problems with line 2. I don't know why it's...

    Question: I tried: $("a #RtMgn_DomRatePlan")[0].click() ;, but got VM87:558 Uncaught TypeError: Cannot read property 'click' of undefined. Also tried: (CODE) And other options / variations. Seems links are not jQuery triggerable events, but it...

    Answer: The selector a #RtMgn_DomRatePlan will select the descendant element of an <a> tag which has the id of RtMgn_DomRatePlan. What type of element is it that has the id RtMgn_DomRatePlan and is a descendant of an <a> tag and why would it have a click...

    Question: Hi Experts How to obtain a Codeigniter's form_radio value to be used in Javascript? By using this code, the default value for $sinal = 1 (CODE) The value $sinal is undefined in Javascript. Could you point what is needed? ...

    Answer: This should do the trick. But why you say are you change code with no success? (CODE)

    Question: I have this input (CODE) Where i use isnumberkey1 function in onkeypress to validate that the input only accept float numbers this is the function "isnumberkey1" (CODE) I would like to know how to call a second function after...

    Answer: Not really. The best way to handle this would be to create another function that performs both tasks and bind that to the onkeypress event.(CODE)(CODE)

    201607-LO-Qu-086

    Extend your technology team with the Experts Exchange community.

    — trusted by —

    Who answers my questions?Our community has technology experts around the world.

    feridun

    3

    Articles

    973

    Solutions

    Expert in:

    • MS Dynamics
    • Enterprise Software
    • MS Applications
    • Exchange
    • JavaScript

    Rgonzo1971

    1

    Articles

    2,572

    Solutions

    Expert in:

    • MS Excel
    • MS Office
    • VBA
    • Visual Basic Classic
    • MS Access

    Rikin Shah

    488

    Solutions

    Expert in:

    • MS Dynamics
    • JavaScript
    • .NET Programming
    • ASP.NET
    • C#

    Damon Repton

    21

    Solutions

    David Johnson, CD, MVP

    5

    Articles

    7,874

    Solutions

    Expert in:

    • MS Legacy OS
    • Windows 7
    • Windows Server 2008
    • .NET Programming
    • ASP.NET

    whoajack

    312

    Solutions

    Expert in:

    • MS SharePoint
    • MS Dynamics
    • Microsoft IIS Web Server
    • Windows Server 2003

    stacko111

    1

    Articles

    67

    Solutions

    Expert in:

    • MS Dynamics

    Jeff Wight

    1

    Articles

    136

    Solutions

    Expert in:

    • MS Dynamics
    • Enterprise Software

    ScienceSoft

    RELATED TOPICS view all topics

    1. Enterprise Software
      (5,481)
    2. MS Applications
      (43,061)
    3. MS SQL Server
      (155,366)
    4. Tax / Financial Software
      (1,757)
    5. Outlook
      (93,660)
    6. MS SQL Server 2005
      (71,260)
    7. MS SQL Server 2008
      (48,062)
    8. JavaScript
      (118,143)
    9. SSRS
      (8,579)
    10. MS SharePoint
      (36,700)
    Receive Monthly Emails of Tech News and Trends from Experts Exchange