Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CRM 2011 Age

Posted on 2013-05-29
5
Medium Priority
?
817 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

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…
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
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.
Suggested Courses

721 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