Solved

CRM 2011 Age

Posted on 2013-05-29
5
813 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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