Solved

CRM 2011 Age

Posted on 2013-05-29
5
806 Views
Last Modified: 2013-05-30
In CRM 2011, I am calcuating Age from a birthday field using java than runs onchange and onload. I would like to be able to run this at night also so that the Age field is updated.
 Is there a way to trigger this via a workflow?  Or is there another option?
This is very frustrating as the person that I work for feels that CRM does these types of things in his words, "out of the box"

{
/* ---------Calculates age --------------- */
if(crmForm.FormType!=1)
{
if(crmForm.all.new_dateofbirth.DataValue!=null)
{
var DOB=crmForm.all.new_dateofbirth.DataValue;
var currDate=new Date();
var age=currDate.getFullYear()-DOB.getFullYear();
age=age-1;
if(currDate.getMonth()>DOB.getMonth())
{
age=age+1;
}
crmForm.all.new_age.DataValue=age;
}
}
0
Comment
Question by:maryigr
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39206683
Hi maryigr,

Doing this via workflow will be an expensive operation(in terms of resource consumption and performance) if you have a large volume of records. Also we are talking about a recursive workflow here. So everyday it will spawn n number of instances(n is the number of records against which you are executing this workflow).

You can follow this article and instead of a month you can set 1 day to achieve a recurring workflow. Also read the article carefully to understand performance implications I have just mentioned.

http://crmbusiness.wordpress.com/2011/05/24/crm-2011-how-to-schedule-recurring-workflows-in-crm-2011/

Feel free to ask me if you have any further questions/doubts/concerns.

Regards,
Chinmay.
0
 

Author Comment

by:maryigr
ID: 39207837
Thanks for your suggestion.  I had actually seen this example of setting up a timer for a recurring workflow and I had already tried it.  I had been searching all over the internet for a solution and had not been able to find one.  For my dateofbirth/age scenario it doesn’t work.  What I did was change the date of birth to one day before and then to one day after and to attempt to trigger the onchange of the javascript.  The javascript failed to trigger which is probably because it is attached to a form and there is no way to reference the form.  As you have pointed out, the performance issues that this workflow would cause CRM would make this not a worthwhile solution anyway.  What I did instead was create a sql query to update the Age field and then create a .bat file to run as a scheduled task.  Do you see a downside to this solution?  Do you think that writing a plugin would be a better solutioin?
0
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
ID: 39207863
Of course there is a downside in updating a field in CRM database directly. It is a long debate but I'd answer it in a single statement - It is not supported(for many legit reasons) also you'd never know what you'd affect basis on this. I'd strongly recommend to stay away from this approach. Rather write a simple C# command line application that uses CRM SDK and do the exact same thing(i.e. update Age) and run it via Task Scheduler. I'd not suggest a plugin as plugin would also have an overhead of execution which I don't see a necessary in this case.
0
 

Author Closing Comment

by:maryigr
ID: 39207878
Thank you very much for your help.
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39208201
No problem. :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

13 Experts available now in Live!

Get 1:1 Help Now