Solved

CRM 2011 Age

Posted on 2013-05-29
5
812 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

738 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